Reply

Draw Vertical Line at Specified Bar

9 replies

tomas262

Administrator, sq-ultimate, 2 replies.

Visit profile

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

0

krikri

Subscriber, bbp_participant, community, 49 replies.

Visit profile

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

0

tomas262

Administrator, sq-ultimate, 2 replies.

Visit profile

6 years ago #143308

Hello,

 

can you attach or send the complete EA MQ4 code? I can revise it

0

krikri

Subscriber, bbp_participant, community, 49 replies.

Visit profile

6 years ago #143414

Hi Thomas262,

 

sqw file attached

 

best regards

 

Christian

0

tomas262

Administrator, sq-ultimate, 2 replies.

Visit profile

6 years ago #143546

Hello,

 

what happens if you export it as an EA instead of an indicator? Does it work then?

0

krikri

Subscriber, bbp_participant, community, 49 replies.

Visit profile

6 years ago #143585

Hello Thomas,

 

when I export as an EA , It doesn’t work .

 

see attached log expert.

 

regards

 

Christian

0

tomas262

Administrator, sq-ultimate, 2 replies.

Visit profile

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?

0

krikri

Subscriber, bbp_participant, community, 49 replies.

Visit profile

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

0

tomas262

Administrator, sq-ultimate, 2 replies.

Visit profile

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

0

krikri

Subscriber, bbp_participant, community, 49 replies.

Visit profile

6 years ago #143901

Hello Tomas262,

 

thanks a lot for your help

 

regards

 

Christian

0

Viewing 9 replies - 1 through 9 (of 9 total)