Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Alerts not working

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

    Alerts not working

    I use a simple strategy that should send me an alert when the bar color changes at the close from the previous bar. Sometimes, I receive a few emails, and notifications show up in the alerts log, but then the alerts do not work anymore. Since they do not show up in the alerts log, and sometimes the alerts are working, I think this is an error of the alerts function in NT, not the email provider or the code. The alerts should be used with a custom bar type, but they also do not work on normal candle bars.

    The code of the strategy for the alerts upon bar color change is as follows:

    namespace NinjaTrader.NinjaScript.Strategies
    {
    public class Dynobarsalerts : Strategy
    {
    protected override void OnStateChange()
    {
    if (State == State.SetDefaults)
    {
    Description = @"Enter the description for your new custom Strategy here.";
    Name = "Dynobarsalerts";
    Calculate = Calculate.OnBarClose;
    EntriesPerDirection = 1;
    EntryHandling = EntryHandling.AllEntries;
    IsExitOnSessionCloseStrategy = true;
    ExitOnSessionCloseSeconds = 30;
    IsFillLimitOnTouch = false;
    MaximumBarsLookBack = MaximumBarsLookBack.TwoHundredFiftySix;
    OrderFillResolution = OrderFillResolution.Standard;
    Slippage = 0;
    StartBehavior = StartBehavior.WaitUntilFlat;
    TimeInForce = TimeInForce.Gtc;
    TraceOrders = false;
    RealtimeErrorHandling = RealtimeErrorHandling.StopCancelClose;
    StopTargetHandling = StopTargetHandling.PerEntryExecution;
    BarsRequiredToTrade = 20;
    // Disable this property for performance gains in Strategy Analyzer optimizations
    // See the Help Guide for additional information
    IsInstantiatedOnEachOptimizationIteration = true;
    }
    else if (State == State.Configure)
    {
    }
    }

    protected override void OnBarUpdate()
    {
    if (BarsInProgress != 0)
    return;

    if (CurrentBars[0] < 1)
    return;

    // Set 1
    if ((Close[0] > Open[0])
    && (Close[1] < Open[1]))
    {
    PlaySound(@"C:\Program Files (x86)\NinjaTrader 8\sounds\Alert1.wav");
    SendMail(@"blanked [email protected]", @"+Instrument.Fullname", "");
    }

    // Set 2
    if ((Close[0] < Open[0])
    && (Close[1] > Open[1]))
    {
    SendMail(@"blanked [email protected]", @"+Instrument.Fullname", "");
    PlaySound(@"C:\Program Files (x86)\NinjaTrader 8\sounds\Alert1.wav");
    }

    }
    }
    }


    #2
    Chris,
    I had a similar problem in NT7 and solved it by using the actual Alert method rather than PlaySound, i.e.:

    Alert("myAlert", NinjaTrader.Cbi.Priority.High, "MyLabelforAlertLog", "Alert1.wav", 10, Color.Black, Color.Yellow);

    Perhaps you want to try it, though you would need to check the exact code to be used for Alerts in NT8.
    sandman


    Comment


      #3
      sandman: is this a strategy, or where can I enter the command line? Thanks

      Comment


        #4
        For another strategy I am using the inbuilt Alert function (Right click on the chart > Alerts) for trendline breaks. This works, but I have to re-enable the alerts manually after each alert, or a few alerts. Is there a way to have the alerts not de-activating themselves?
        This actually is a bit strange since sometimes, alerts are automatically de-enabled after the first alert, but sometimes this happens after a few successful alerts. I do not really have an explanation for this, and it would make my life much easier if alerts were always "on", so I could miss one but still be alerted for the next trendline break, etc.

        Comment


          #5
          Hi, chris07 thanks for your post.

          I would suggest using Print statements to print out your conditions to debug the script that is using alerts. e.g.

          Code:
          if ((Close[0] > Open[0])
          && (Close[1] < Open[1]))
          {
              Print("First Condition True " + Time[0]);
          }
          
          // Set 2
          if ((Close[0] < Open[0])
          && (Close[1] > Open[1]))
          {
              Print("Second Condition True " + Time[0]);
          }
          Here you will see the exact time your conditions become true. Try this, do you get a print and no email or sound alert? If so I could test the script you are using. If you want you can send it to me at platformsupport at ninjatrader.com and reference "Attn ChrisL 2453451" in the body of the email.

          To re-arm alerts, you need to select the correct re-arm type for the alerts:
          https://ninjatrader.com/support/help...lertProperties - Alert Properties.
          Chris L.NinjaTrader Customer Service

          Comment


            #6
            ChrisL: I will try the print function.

            Regarding my other question, is there a way to have alerts not de-enable themselves after they have been triggered one or more times?

            Comment


              #7
              Hi chris07,

              The Rearm type will determine how the alert gets re-armed, see the various Rearm types in the link I posted above. By default, the alerts are set to disarm after they are activated.

              Kind regards.
              Chris L.NinjaTrader Customer Service

              Comment


                #8
                I did not see the links, my apologies. Thank you for your prompt replies and help.

                Comment


                  #9
                  I've noted myself while using alerts that they will NOT rearm on a regular enough basis to be very annoying...even if they are enabled and set to rearm ONBARCLOSE. There is something definitely bugged with them. I've only tested the built in Alert function (where you right click on a chart and select ALERTS). But there is definitely something buggy about it and it's quite frustrating. I think I will have to try disabling the alert then re-enabling it the next time I get an alert...perhaps that will force it to work every time...that's if I remember to do it...lol

                  Comment


                    #10
                    Hi Mike0405, thanks for your note.

                    I recommend testing your alerts with the Playback connection. If you do find something that is not working properly I can set up the same alert on my end and test.
                    Chris L.NinjaTrader Customer Service

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by junkone, Today, 11:37 AM
                    0 responses
                    1 view
                    0 likes
                    Last Post junkone
                    by junkone
                     
                    Started by quantismo, 04-17-2024, 05:13 PM
                    5 responses
                    34 views
                    0 likes
                    Last Post NinjaTrader_Gaby  
                    Started by proptrade13, Today, 11:06 AM
                    1 response
                    5 views
                    0 likes
                    Last Post NinjaTrader_Clayton  
                    Started by love2code2trade, 04-17-2024, 01:45 PM
                    4 responses
                    34 views
                    0 likes
                    Last Post love2code2trade  
                    Started by cls71, Today, 04:45 AM
                    2 responses
                    10 views
                    0 likes
                    Last Post eDanny
                    by eDanny
                     
                    Working...
                    X