I have an indicator that draws a line at candle open of 1h timeframe. Then I switch to 5min timeframe. When 1h candle is closed and price moves,
the line that has been drawn previously is not deleted and a new one is drawn (still in 5 min tf). How can I delete it and recreate it? or rather
update it? (for update i would need to check when 1hour candle is closed before update. don't know how to do it)
Indicator is attached.
I tried it but still doesn't work.
Since you're drawing the entire line, you can just set i to start from 0... don't need the pos variable.
But bear in mind that your indicator goes through everything (including copyrates and update line buffer) every tick, which is
unnecessary... consider adding time check, or simply add:
before your first line in OnCalculate().
I tried that too, doesn't work either :)
I made a screenshot just to describe better what happens, see attachment.
As you can see, it's on the 1min timeframe, but i made the indicator to draw based on 5min-candle. For every 5 candles a new line is drawn and
that's just as it is meant to do. But the previous line is not removed and there are also slanting lines that connects the horisontal lines
(which should be removed too). Problem is it just doesn't update. But if I rightclick on the chart and choose Refresh then chart refreshes and
all previous lines are removed while a new one is drawn.
I don't know what you tried, but I'm sure you didn't read my post or implement my suggestion correctly. Because this is what I get:
Probably I didn't implement it correctly. I don't know much about MQL programming, niether about adding time check. Could you write the code in the
file I attached and upload it? I would greatly appreciate it.
Probably I didn't implement it correctly. I don't know much about MQL programming, niether about adding time check. Could you write the code in
the file I attached and upload it? I would greatly appreciate it.
for(int i=pos; i<rates_total; i++)
for(int i=0; i<rates_total; i++)
And add the time check lines I mentioned in my earlier post (affects efficiency rather than functionality).