Drawing a horizontal line at the close of a H1 candle on the Dow
07/19/2017 at 9:40 AM #41051
Is there any code available for drawing a simple horizontal line across a chart, based upon the close of a candle at a set time each day? For example, a horizontal line at the close of the 1pm H1 candle on the Dow? The line would need to ‘expire’ (delete itself) when the next days line is drawn.
Many thanks07/19/2017 at 10:15 AM #41053
I think this code should work correctly for this purpose:123456789defparam drawonlastbaronly=trueif time=130000 thenvalue=closeendifdrawhline(value)return
You must be logged in to access attached files.07/20/2017 at 7:55 PM #4118807/24/2017 at 2:11 PM #4150607/24/2017 at 2:27 PM #41510
Because the separate don’t adapt automatically its scale with plotted object like horizontal line. If you change the last line of the code with:1return value
it should adapt itself automatically.
Why it doesn’t show on the main pane? .. be sure the instrument has quote at time it saves the value (1 pm in the code).07/24/2017 at 2:49 PM #41511
Thanks Nicolas. That works, just as the original one works.
I wish to plot the Open, High and Low of the first 30 minutes of trading and want it to be displayed on a 5 or 10 min chart. Is this possible?
Also, I wish to plot yesterday’s Open, High and Low on continuous data ie will have to be able to specify open hours and should also be able to display in various time frames. Is this possible?
I realize the requests are much more than the original topic – would it be preferable to start these requests as separate ?
Thank you.07/24/2017 at 3:31 PM #4151401/17/2018 at 12:31 PM #5970801/17/2018 at 12:35 PM #5970901/17/2018 at 1:15 PM #59712
Yes you can store a time in a variable, it’s nothing more than a number 🙂1234567891011defparam drawonlastbaronly=truemytime = 150000if time=mytime thenvalue=closeendifdrawhline(value)return
1 user thanked author for this post.01/17/2018 at 7:01 PM #59732
thanks for getting back.. what i meant was.. adding two lines on the chart one at 130000 and one at 150000. and a way to switch those times (add on the variables- like tick or untick) so we can either see two lines on the chart or we can untick to see one?!?! tried below but its a big failure!!12345678910defparam drawonlastbaronly=truemytime = 150000mytime1 = 130000if time=mytime and mytime1 thenvalue=closeendifdrawhline(value)return01/18/2018 at 10:08 AM #59783
Ok, here is the modified code for that purpose:(draw0 and draw1 boolean variables been introduced)123456789101112131415161718192021defparam drawonlastbaronly=truemytime0 = 150000draw0 = 1 //1=true, 0=falsemytime1 = 130000draw1 = 0 //1=true, 0=falseif time=mytime0 thenvalue0=closeendifif draw0 thendrawhline(value0)endifif time=mytime1 thenvalue1=closeendifif draw1 thendrawhline(value1)endifreturn
1 user thanked author for this post.01/18/2018 at 11:09 AM #5979201/18/2018 at 2:05 PM #5980201/22/2018 at 2:39 AM #60115
still stuggling to get the two lines it only show mytime0 on the chart and mytime1 doesnt show..
please cant you see attached pic? is that the correct way to add boolean???
You must be logged in to access attached files.