Hi community,
I want to create a varible that would be used as length of average window
LengthWindow = round(average[20](close) )
RetIndicator = average[LengthWindow](close)
return RetIndicator
Such solution wouldnt work because LengthWindow is not defined for the first 20 numbers. The program will yield an error: A positive integer filed is expected with average
A first solution would be to fill the LengthWindow with any nunber for the first 20 elements and things will work
if BarIndex < 20 then
LengthWindow = 1
else
LengthWindow = average[20](close)
endif
RetIndicator = average[LengthWindow](close)
return RetIndicator
This solution does not work as well
Any idea please
Many thanks
Anouar
Anouar – Welcome to the forums. I moved your topic to the ProBuilder forum as the ‘Welcome New Members’ forum is not the place for it. Please try to post any future topics in the correct place.
Post your topic in the correct forum:
_ ProRealTime Platform Support: only platform related issues.
_ ProOrder: only strategy topics.
_ ProBuilder: only indicator topics.
_ ProScreener: only screener topics
_ General Discussion: any other topics.
_ Welcome New Members: for new forum members to introduce themselves.
Try this:
if barindex >= 20 then
LengthWindow = round(average[20](close) )
RetIndicator = average[LengthWindow](close)
endif
return RetIndicator
Thank You very much for Answer,
It worked for this example, for some reason it still does not work for the next example:
HVWindow=100
if (BarIndex > HVWindow) then
ProxyWindow = historicvolatility[HVWindow](close)
Window = round(ProxyWindow)
RetIndicator=average[Window](close)
endif
return RetIndicator
Do you have any idea please?
Many thanks,
Anouar
Because the Historic Volatility indicator can return values below 0.5 and when any value below 0.5 is rounded this equals zero and zero is not a positive integer.