Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Rearms of Email Alerts

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

    Rearms of Email Alerts

    Hi there.

    I'm wondering about the possibilities of rearming the sendemail() function. So right now we have the following as standard syntax:

    SendMail("[email protected]", "Trade Alert", "Buy ES");

    Unfortunately this provides few options. For example if the code is:

    If Close[0] > than say 1000

    else If Close [0]>2000

    SendEmail()

    the emails will be sent non stop once the Close[0] > 1000.

    Ideally this will only place a single time once Close[0] > 1000 then send another email once Close [0]>2000.

    I'm not seeing anything in the literature on this. I'm able to configure normal sound alerts with this code and was wondering if I could do something similar with the SendEmail() function:

    Alert(string id, Priority priority, string message, string soundLocation, int rearmSeconds, Brush backBrush, Brush foreColor)

    Thanks in advance
    DJ





    #2
    You likely will be best served by adding bool logic to control the irregularity of the occurrences,

    if (doit1000 && Close[0] > 1000)
    {
    doit1000 = false;
    SendEmail(...);
    }

    if (doit2000 && Close[0] > 2000)
    {
    doit2000 = false;
    SendMail(...);
    }

    doit1000 and doit2000 should be declared as private bool type and should be set to true.

    This will allow one and only one e-mail until you reset the bools back to true. You can reset the bools back to true with another set of conditions of your own or use something like:

    if (Bars.IsFirstBarOfSession)
    {
    doit1000 = true; // reset for new session
    doit2000 = true; // reset for new session
    }

    Comment


      #3
      Hi DJ, thanks for writing in.

      The SendEmail() method can be called as many times are you want in the script. The re-arm behavior is determined by your own C# code e.g. using boolean variables to control the flow of conditions. I liked an example for reference.

      Hi, To improve a strategy, I would like the condition to enter a trade to be triggered only after a second crossing happens. Meaning, for instance we have a sthocastics crossing, but the strategy would only trigger when a crossing between 2 emas happen. Would the looking back N bars work? Can it be done within the builder
      Chris L.NinjaTrader Customer Service

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by ftsc2022, 10-25-2022, 12:03 PM
      5 responses
      255 views
      0 likes
      Last Post KeyonMatthews  
      Started by ScottW, Today, 06:09 PM
      0 responses
      3 views
      0 likes
      Last Post ScottW
      by ScottW
       
      Started by Board game geek, 10-29-2023, 12:00 PM
      14 responses
      244 views
      0 likes
      Last Post DJ888
      by DJ888
       
      Started by Waxavi, 04-19-2024, 02:10 AM
      4 responses
      56 views
      0 likes
      Last Post sonia0101  
      Started by cmtjoancolmenero, Today, 03:58 PM
      0 responses
      9 views
      0 likes
      Last Post cmtjoancolmenero  
      Working...
      X