Question about comment handling in mt4
Results 1 to 4 of 4

Thread: Question about comment handling in mt4

  1. #1
    I have an EA comment I would like just posted on the chart, the first time it's true. Currently it repeats.

    Anyhow the code is similar to this...

    Inserted Code if ((BuySignalA) ((Ask-Bid) lt;= AvgSpreadHigh)) Comment(TimeToStr(TimeCurrent(),TIME_SECONDS), BUY SIGNAL-A gt;gt; BUY POSITION SHOULD BE OPENED OR PREVIOUSLY OPENED ); // Print(TimeToStr(TimeCurrent(),TIME_SECONDS), BUY SIGNAL-A gt;gt; BUY POSITION SHOULD BE OPENED OR PREVIOUSLY OPENED );
    I had it printing too at first, but while the BuySignal is active it prints every tick!! Too much

    I'd like it to comment on the original first BuySignal and dismiss others until a NEW BuySig is generated or a SellSig is generated.

    How can I get it not to replie an energetic sign and just post on the initial activation of this sign? The way it's at the moment, it is hard to tell by the comments once the sign was active since it keeps repeating while busy. Do the EA comments become saved in a file somewhere? Because if so, it will gradually occupy quite a little memory I think.

  2. #2
    You may use a global var
    bool PrintComment

    Set it to false after the print of the remark and change it to true when there is a new sign

    if ((BuySignalA) ((Ask-Bid) lt;= AvgSpreadHigh) PrintComment)
    Comment(TimeToStr(TimeCurrent(),TIME_SECONDS), BUY SIGNAL-A gt;gt; BUY POSITION SHOULD BE OPENED OR PREVIOUSLY OPENED ); //
    PrintComment=false;
    Printing (TimeToStr(TimeCurrent(),TIME_SECONDS), BUY SIGNAL-A gt;gt; BUY POSITION SHOULD BE OPENED OR PREVIOUSLY OPENED );

  3. #3
    Assess for a Shift in Condition:
    Inserted Code static bool SignalWas=false; bool SignalIs=(BuySignalA) ((Ask-Bid) lt;= AvgSpreadHigh); if (SignalIs !SignalWas) Opinion (TimeToStr(TimeCurrent(),TIME_SECONDS), BUY SIGNAL-A gt;gt; BUY POSITION SHOULD BE OPENED OR PREVIOUSLY OPENED ); SignalWas=SignalIs; (uncompiled, untested)

  4. #4
    Once activated (placed on), the comment will stay on until cleared or changed i.e. Comment();
    Thus, you have to decide when you wish to choose the comment down or change it.
    The EA runs from the tick, so it's possible to clear/change it from another tick, next candle, or set up a timer to clear/change it after a time, or from another (chart) event.
    The comment does not maintain a history. It is current string or not one.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
This website uses cookies
We use cookies to store session information to facilitate remembering your login information, to allow you to save website preferences, to personalise content and ads, to provide social media features and to analyse our traffic. We also share information about your use of our site with our social media, advertising and analytics partners.