Draw Vertical Line at Specified Bar
9 replies
tomas262
8 years ago #115019
When you need to draw a vertical line on charts for better visual orientation you can use following code to do it:
Add this into EA Wizard / code / CustomFunctions.mq4 file. Then you can use it in Wizard as it is shown in example attached.
void drawVerticalLine(int barsBack) { string lineName = "Line"+MathRand(); if (ObjectFind(lineName) != 0) { ObjectCreate(lineName,OBJ_VLINE,0,Time[barsBack],0); ObjectSet(lineName,OBJPROP_COLOR, clrRed); ObjectSet(lineName,OBJPROP_WIDTH,1); ObjectSet(lineName,OBJPROP_STYLE,STYLE_DOT); } }
And use it as shown in the example attached.
The example draws a line on selected chart every day at 8 o’clock
krikri
6 years ago #143298
Hi Thomas262,
I have test your indicator to draw vertical line and I have not vertical line but red square , I have copied the code in Eawizard/code/customFunctions.mq4.
can you help me please
Regards
Christian
tomas262
6 years ago #143308
krikri
6 years ago #143414
tomas262
6 years ago #143546
krikri
6 years ago #143585
Hello Thomas,
when I export as an EA , It doesn’t work .
see attached log expert.
regards
Christian
tomas262
6 years ago #143664
Hello,
when I exported Drawverticalline.mq4 as an EA it works for me – see pic attached. I see an error on your screenshot in the bottom. Does it appear when you run the code?
krikri
6 years ago #143749
Hello Thomas262,
ok It works for me too as an EA but only in the strategy tester not when attached on a chart, I would like draw vertical line as an indicator, how can I do ?
regards
Christian
tomas262
6 years ago #143868
Hello,
when attached to a chart as an advisor it works correctly. Unfortunately drawing is not correct when attached as a signal indicator
krikri
6 years ago #143901
Viewing 9 replies - 1 through 9 (of 9 total)