Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

sending email continuously

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    sending email continuously

    Hi, I am generating a signal within onmarketdata() and sending an email. But it is continuously without stoping. I am following the below:

    private bool doitonce = false;
    private bool generateAlert = false:

    Within onmarketdata()
    {
    if (IsFirstTickOfBar)
    {
    if (generateAlert)
    {
    generateAlert = false;
    doitonce = true;
    }
    else if (doitonce)
    {
    generateAlert = true;
    doitonce = false;
    }
    else if (!generateAlert)
    {
    generateAlert = true;
    doitonce = true;
    }
    }
    }

    And then within OnBarUpdate()
    {
    if (condition && generateAlert && doitonce)
    {
    Print("Send email");
    //SendMail(EmailAddress, "Trade ", "Entry");
    doitonce = false;
    }
    }

    can you advise on how to avoid continuously sending email, I just needed it to fire once?

    #2
    Hello asmmbillah,

    Thanks for your post.

    I would suggest doing your bool resets under the control of OnBarUpdate() instead of OnMarketUpdate.

    In OnBarUpdate() you could further control how often you would accept an alert.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by CarlTrading, 03-31-2026, 09:41 PM
    1 response
    46 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 04-01-2026, 02:41 AM
    0 responses
    22 views
    0 likes
    Last Post CarlTrading  
    Started by CaptainJack, 03-31-2026, 11:44 PM
    0 responses
    33 views
    1 like
    Last Post CaptainJack  
    Started by CarlTrading, 03-30-2026, 11:51 AM
    0 responses
    50 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, 03-30-2026, 11:48 AM
    0 responses
    42 views
    0 likes
    Last Post CarlTrading  
    Working...
    X