Hi,
I’m trying to draw/plot a zone between two daily-timeframe values on a 5-minute chart. In general, everything seems to work except for the last candle, where the fill function produces a noticeable spike.
Additionally, the text labels do not appear; when I don’t use the timeframe function, they show up on the right side as expected (see cursor information, it seems to be correct floats).
defparam drawonlastbaronly=true
// 1 DAY (1D)
TIMEFRAME(1 DAY)
dema1 = DEMA[1](close)
dema2 = DEMA[2](close)
DRAWTEXT(" dema 1", BarIndex, dema1, Dialog, Bold, 12) COLOURED(1,1,1)
DRAWTEXT(" dema 2", BarIndex, dema2, Dialog, Bold, 12) COLOURED(1,1,1)
colorbetween(dema1, dema2, 1,1,1, 50)
return dema1 coloured(1,1,1) style(line,1) as "dema 1", dema2 coloured(1,1,1) style(dottedline,2) as "dema 2"
Hi!
The issues you are encountering are due to how Multi-Timeframe (MTF) instructions handle the BarIndex and the data aggregation. To hide the visual artifact on the forming candle you coudl manipulate transparency.
try this:
defparam drawonlastbaronly=true
TIMEFRAME(daily,updateonclose)
dema1 = DEMA[1](close)
dema2 = DEMA[2](close)
once alpha=50
if islastbarupdate then
alpha=0
endif
timeframe(default)
DRAWTEXT(" dema 1", BarIndex, dema1, Dialog, Bold, 12) COLOURED(1,1,1)
DRAWTEXT(" dema 2", BarIndex, dema2, Dialog, Bold, 12) COLOURED(1,1,1)
colorbetween(dema1, dema2, 1,1,1, alpha)
return dema1 coloured(1,1,1) style(line,1) as "dema 1", dema2 coloured(1,1,1) style(dottedline,2) as "dema 2"
Thank you very much for all your help!
What I was able to verify (by printing the value of the last candle) was that the value of dema2 was N/A. However, the lines can be drawn and dema1 is allways defined. Why does the function work fine on the first calculation but not on all subsequent ones?