Hi,
I need help with the following code. I want to add an extra condition to the below code but don’t know what the code is for horizontal shift.
and WeightedAverage [17] horizontal shift -2 is above WeightedAverage[17](close) for the top line
and WeightedAverage [17] horizontal shift -2 is below WeightedAverage[17](close) for the bottom line
if close[0] > WeightedAverage[17](close) then
DRAWCANDLE(open,high,low,close)COLOURED(0,80, 0)
ENDIF
if close[0] < WeightedAverage[17](close) then
DRAWCANDLE(open,high,low,close)COLOURED(122, 85, 171)
ENDIF
RETURN
Hi,
you can use for your horizontal shift -2: WeightedAverage[17](close)[2]
or define a variable wa17, shift it, and simplify code script with added conditions with:
wa17=WeightedAverage[17](close)
if close[0] > wa17 and wa17[2]>wa17 then
DRAWCANDLE(open,high,low,close)COLOURED(0,80, 0)
ENDIF
if close[0] < wa17 and wa17[2]<wa17 then
DRAWCANDLE(open,high,low,close)COLOURED(122, 85, 171)
ENDIF
RETURN