AccDist Divergence Scan


Category:
0
0

Hey Pete!  Thanks for all your help as always.

 

You helped me on a previous AccDist scan and I’ve tried everyday I could think of to get the modified scan to work.

 

 

All I’m trying to get is the highest AccDist value from the previous 30 days and that day’s price and compare it against the current day’s price and it’s current AccDist value.  Below is a screenshot, the lime circles are the highest/accdist and the price and the white is the current accdist and its price.

 

I’ve fiddled around with the script below but it determines accdist off of price instead of price off of AccDist.

 

Hope this makes sense.

 

def yearlyLowPrice = Lowest(low, 251);
def accDist = TotalSum(volume * CloseLocationValue());
def accDistAtLowestLow = if low == yearlyLowPrice then accDist else 0;
plot accDistValue = HighestAll(accDistAtLowestLow) > accDist;

 

 

 

Attachments:
Marked as spam
Posted by (Questions: 10, Answers: 15)
Asked on May 3, 2020 9:23 am
102 views
0
Sorry this scan def accDist = TotalSum(volume * CloseLocationValue()); def highestThirtyDay = highest(accDist, 30); def priceCloseOfHighest = if highestThirtyDay == accDist then close else 0; plot scan = HighestAll(priceCloseOfHighest) < close and accDist > highestThirtyDay;
( at May 3, 2020 9:52 am)
0
Private answer

Sorry but I cannot think of a simple way to do this. Divergence takes a great deal of complexity to measure properly. But your approach is one that allows for a result that is far less precise than true divergence studies such as the ones we publish in our premium indicators page:

https://www.hahn-tech.com/premium-chart-indicators/

I was able to come up with a solution that finds the specific divergence pattern you have described in your question. Here is the code to achieve what you have requested:

input lookbackBars = 30;
def accDist = TotalSum(volume * CloseLocationValue());
def highestThirtyDay = Highest(accDist, lookbackBars);
def maxAccDistOffset = GetMaxValueOffset(accDist, lookbackBars);
def closeAtMaxAccDist = GetValue(close, maxAccDistOffset);
def valueDiffAccDist = highestThirtyDay - accDist;
def valueDiffClose = closeAtMaxAccDist - close;
plot scan = close > valueDiffClose and valueDiffClose < 0 and valueDiffAccDist > 0;

I am including two screenshots below. One that shows the result of this piece of code. (dashed yellow trendlines were drawn by hand). The blue line on the lower subgraph below the AccDist indicator shows the places where this scan will return a true result.

For reference I am also included a screenshot showing our premium divergence study based on the MACD. (solid yellow line is drawn by the code automatically) We can also make customized versions of these premium divergence indicators. AccDist is a candidate for just this sort of customization.

Attachments:
Marked as spam
Posted by (Questions: 37, Answers: 4087)
Answered on May 3, 2020 10:30 am
0
Holy cow..... Thanks Pete!
( at May 3, 2020 2:00 pm)
0
Would be it too much to ask how to plot it on the chart? Totally get it if it is. Thanks Pete!
( at May 3, 2020 2:17 pm)
0
You mean to plot the line like it does on our premium version? Yes, you would need to purchase the premium version and have us modify it to work with AccDist. It took me over a decade of practice to learn how to draw those divergence lines. Never going to give that away for free. The cost to acquire that knowledge was far to costly to give it away.
( at May 3, 2020 3:40 pm)