Not logged in

Forums

Viewing 10 posts - 1 through 10 (of 10 total)

Forums>EA Wizard>Strategy Samples>Draw Vertical Line at Specified Bar

  • #115019 |
    Moderator
    2349 Posts

    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

    Attachments in this forum are visible only for registered users.
    #143298
    Participant
    50 Posts

    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

    Attachments in this forum are visible only for registered users.
    #143308
    Moderator
    2349 Posts

    Hello,

     

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

    #143414
    Participant
    50 Posts

    Hi Thomas262,

     

    sqw file attached

     

    best regards

     

    Christian

    Attachments in this forum are visible only for registered users.
    Attachments in this forum are visible only for registered users.
    #143546
    Moderator
    2349 Posts

    Hello,

     

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

    #143585
    Participant
    50 Posts

    Hello Thomas,

     

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

     

    see attached log expert.

     

    regards

     

    Christian

    Attachments in this forum are visible only for registered users.
    #143664
    Moderator
    2349 Posts

    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?

    Attachments in this forum are visible only for registered users.
    #143749
    Participant
    50 Posts

    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

    #143868
    Moderator
    2349 Posts

    Hello,

     

    when attached to a chart as an advisor it works correctly. Unfortunately drawing is not correct when attached as a signal indicator

    #143901
    Participant
    50 Posts

    Hello Tomas262,

     

    thanks a lot for your help

     

    regards

     

    Christian

Viewing 10 posts - 1 through 10 (of 10 total)

You must be logged in to reply to this topic.