Drawing the straight line

 
Hello,
I need some help with lines on the charts.
Lets say, I found high of the day, or whatever, markered a support or resistance level from H or L of this Candle. 
Then, is it possible to set kind of loop which allow this support/resistance line/area to extend pararel with every bar which appears on the chart? 
It means, straight line has to extend like a ray maximal to the right side in real time after every single bar appears. Of course, until one of the future bars won't break it out but this couldnt be a problem. 
I wonder if TimeCurrent should work or rather kind of "future" time? 
Thx in advance for tips. 
 
djarturos:I need some help with lines on the charts. Lets say, I found high of the day, or what ever, markered a support or resistance level from H or L of this Candle. Then, is it possible to set kind of loop which allow this support/resistance line/area to stretch pararel with every bar which appears on the chart? It means, line must be drawed in real time in the chart, after every single bar appears. Thx in advance for tips. 

Your questions seems similar to the following thread, so it should help if you read it — Horizontal Line between two candles

 
djarturos:
Hello,
I need some help with lines on the charts.
Lets say, I found high of the day, or whatever, markered a support or resistance level from H or L of this Candle. 
Then, is it possible to set kind of loop which allow this support/resistance line/area to extend pararel with every bar which appears on the chart? 
It means, straight line has to extend like a ray maximal to the right side in real time after every single bar appears. Of course, until one of the future bars won't break it out but this couldnt be a problem. 
I wonder if TimeCurrent should work or rather kind of "future" time? 
Thx in advance for tips. 

Yeah . If you want to extend it beyond then you can take the most recent time Time[0] and add the duration of the timeframe in seconds  x  bar slots to the right .

(PeriodSeconds()*bars_to_the_right)

If you are in a "past" or initialization loop then you just extend to the newest bar until it breaks 

 
Lorentzos Roussos #:

Yeah . If you want to extend it beyond then you can take the most recent time Time[0] and add the duration of the timeframe in seconds  x  bar slots to the right .

(PeriodSeconds()*bars_to_the_right)

If you are in a "past" or initialization loop then you just extend to the newest bar until it breaks 

Thx, I will try! 
 
Lorentzos Roussos #:

Yeah . If you want to extend it beyond then you can take the most recent time Time[0] and add the duration of the timeframe in seconds  x  bar slots to the right .

(PeriodSeconds()*bars_to_the_right)

If you are in a "past" or initialization loop then you just extend to the newest bar until it breaks 

Yes, it helped and everything is fine right now. There is a "Ray" - line is extented until it's not broken by candlestick. Thx
 
djarturos #:
Yes, it helped and everything is fine right now. There is a "Ray" - line is extented until it's not broken by candlestick. Thx

awesome

 
Hello again,
Is it possible to add "simple" button with ON/Off options to hide/show these lines? 

 
 
Thanks a lot for this answer! This helped me a lot! 

Well, now case no. 2:
I have this button created. Now I wonder which function code should I use to "refresh" the indicator (not the chart!) as if it starts again with default settings? For example: I press ON button, indicator shows me 5 lines, then I delete 2 of them manually, and then after clicking OFF  lines (3 lines at this moment) dissappear. Then I press ON again but there are only 3 lines, not 5 like at the beginning. How can I solve this problem and restore the indicator to the default settings (after clicking the button)? 
 
djarturos #:
Thanks a lot for this answer! This helped me a lot! 

Well, now case no. 2:
I have this button created. Now I wonder which function code should I use to "refresh" the indicator (not the chart!) as if it starts again with default settings? For example: I press ON button, indicator shows me 5 lines, then I delete 2 of them manually, and then after clicking OFF  lines (3 lines at this moment) dissappear. Then I press ON again but there are only 3 lines, not 5 like at the beginning. How can I solve this problem and restore the indicator to the default settings (after clicking the button)? 

Are the price levels (or trendlines) stored anywhere ? 

Your alt could be placing the initial line draw/calculation within a function and so when you hit the button and it turns to on you go to this calc function instead of the show function. 

 
Lorentzos Roussos #:

Are the price levels (or trendlines) stored anywhere ? 

Your alt could be placing the initial line draw/calculation within a function and so when you hit the button and it turns to on you go to this calc function instead of the show function. 

Thanks for answer. price levels from HIGHs and LOWs and objects are not stored, just created from OnCalculate function. I can't add this function to the button second time. In other words, I can't assign this function to the button. 
And I can't use code somewhere else than OnCalculate cause it uses it too (there are many input and referencje values).
I have these lines and arrows on the chart too. But these objects, like I said above, are not stored anywhere.

I have also separate settings in indicator's panel like showSupports, show Resistance etc. But I understand these are only initialization parameters. It means if I set up this value to "false", no lines on the chart, then I can press button On/Off like I want. And after I close mt4 and open it again, this internal value should be on "false" as before. 

But button is the main problem. 

Reason: