Hello all,
I am trying to build a screener based on monthly ATR. since I cannot use monthly time frame, I coded an indicator for the weekly timeframe which i intend to use as a function .
nbrWeeksInMonth = 4
if barindex > nbrWeeksInMonth then
weekIndex = barindex mod nbrWeeksInMonth
if weekIndex = 0 then
weekindex = 4
endif
monthlyHigh = highest[weekIndex](high)
monthlyLow = lowest[weekIndex](low)
closePrevMonth = close[weekIndex]
a = monthlyHigh - monthlyLow
b = abs(monthlyHigh - closePrevMonth)
c = abs(monthlyLow - closePrevMonth)
atrCurrent = max(max(a,b),c)
atrMonthly = ((19 * atrMonthly[weekindex]) + atrCurrent) / 20
endif
when I look on graph of the indicator it provides pretty good results for me.
My problem is that when I call this indicator from the screener code using “CALL” function I get different values from those I see on the graph.
Please assist.
I think that the problem is that ProScreener have a max history of 254 bars available. So it’s possible that the data is not sufficient for your monthly ATR to be calculated. On which timeframe on ProScreener did you test the code? Did you try to include the code directly into the screener code rather than using it with a CALL instruction?