All Custom Indicators return ZERO!
- This topic has 6 replies, 3 voices, and was last updated 1 year ago by .
Viewing 7 posts - 1 through 7 (of 7 total)
Viewing 7 posts - 1 through 7 (of 7 total)
Similar topics:
Forums › ProRealTime English forum › ProBuilder support › All Custom Indicators return ZERO!
Sure, originally I think the code was called hyper trend? So I added some code to count the bars in a down or up trend and use that to determine a high or low level within the specific trend…the code returns the correct value within a strategy but not within a indicator. It was working before today so I do not really know why it suddenly returns a zero value?
mult = 5
slope = 14
width = 80
once avg = close
once hold = 0
if barindex > 200 then
atr = AverageTrueRange[200] * mult
endif
If abs(close – avg) > atr then
avg = (close+avg)/2
//avg = avgN
else
avg = avg + os*(hold/mult/slope)
//avg = avgN
endif
os = sgn(avg – avg[1])
If os <> os[1] then
hold = atr
else
hold = hold[1]
endif
greenbarcount = 0
if avg[2] > avg[1] and avg[1] < avg Then
greenbar = barindex
endif
if avg[1] < avg Then
greenbarcount = barindex – greenbar
endif
if greenbarcount >=1 then
Longhigh = highest[greenbarcount](high)
endif
if greenbarcount =1 then
Longlow = low
endif
Return Longhigh
Hi..
I’ve got a theory, any preloaded bars in a strategy my give a valid ATR value for the logic.
In indicator, it needs 200 bars before valid ATR value available, since starting at bar zero.
This might have found a never ‘true’ condition in the logic so no output.
If you move the ‘ENDIF’ keyword, for the ‘BARINDEX>200 ‘IF’ block, to the end of the code just before ‘RETURN’, then something happens!
Not sure if this ‘something’ is the desired outcome.
Seems strange to use ‘ATR’ later in the code run but it may be ‘UNDEFIND’ till 200 bars up.
Moving this ‘ENDIF’ means all code inside new code block waits till valid ‘ATR’ value before executing.
Regards druby
Find exclusive trading pro-tools on