AlfyParticipant
Average
Good morning guys, I’m trying to colour the candlesticks in my charts using a momentum indicator and although it is working
DonchianMidline = (Highest[20](high)+Lowest[20](low)+Average[20](close) )/3
sma=close-(DonchianMidline)
Delta = linearregression[20](sma)
if delta>0 and delta>delta[1] Then
DRAWCANDLE(open, high, low, close)COLOURED(0,245,255)
colour=1
endif
if delta>0 and delta<delta[1] then
DRAWCANDLE(open, high, low, close)COLOURED(0,0,255)
colour=2
endif
if delta<0 and delta<delta[1] then
DRAWCANDLE(open, high, low, close)coloured(255,0,0)
colour=3
endif
if delta<0 and delta>delta[1] then
DRAWCANDLE(open, high, low, close)coloured(255,255,0)
colour=4
endif
RETURN colour
on the monthly and weekly charts, on the daily charts its doing something strange with all the prices squashed. Can someone take a look at my code and let me know what I’m doing wrong please?
Best regards and thank you
Appears to works fine on mine?
See attached on Monthly Chart
AlfyParticipant
Average
yep, works on weekly too but not on daily chart
Works fine on Daily Chart on mine, I checked up to 100K bars … very colourful! 🙂
AlfyParticipant
Average
Strange, ok, thanks for the feedback
Maybe your scale on your daily chart isn’t set up the same way as in the other charts, you can check with right click on price scale on right margin, then in the menu pick the one at the end about “configuration of the zone” (not sure the exact english name of it), then as in attached image you are in “scale” menu (left side) and on the right side of the panel check the box about using price only is checked, it will avoid making visible the values 1 to 4 of the returned “colour” variable of your indicator added to price, assuming it was that kind of squashing.
Maybe it wasn’t the problem at all, but the absence of screen capture also means absence of clues for those willing to help, we have to make hypothesis of what “squashed” means in the first place before wondering what might have done this. So maybe I got the wrong “squash”, and the wrong solution…
AlfyParticipant
Average
All fixed. If interested please see attached fixed code.
DonchianMidline = (Highest[20](high)+Lowest[20](low)+Average[20](close) )/3
sma=close-(DonchianMidline)
Delta = linearregression[20](sma)
if delta>0 and delta>delta[1] Then
DRAWCANDLE(open, high, low, close)COLOURED(0,245,255)
endif
if delta>0 and delta<delta[1] then
DRAWCANDLE(open, high, low, close)COLOURED(0,0,255)
endif
if delta<0 and delta<delta[1] then
DRAWCANDLE(open, high, low, close)coloured(255,0,0)
endif
if delta<0 and delta>delta[1] then
DRAWCANDLE(open, high, low, close)coloured(255,255,0)
endif
RETURN
values 1 to 4 of the returned “colour” variable of your indicator
To close the loop and so we all know for future on similar ‘squashings’ 🙂 … the amended code has removed the refs to colour 1 to 4.
AlfyParticipant
Average
thanks so much for all your help!