Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Alert not rearming correctly

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

    Alert not rearming correctly

    Hi,

    I use this code to alert, when the bar is drawn to 90% or greater.

    Code:
                #region Alert
                if (IsFirstTickOfBar) RearmAlert("PASuppResBreakoutTest_Resistance");
    
                if (showAlert && DrawObjects["BT_Swing_Low"+(CurrentBar)] != null)
                {
                    /*if (myrearmSeconds>1)
                        Alert("PASuppResBreakoutTest_Resistance", Priority.High, "PASuppResBreakoutTest Resistance " + swingStrength.ToString("N0"), soundFile, myrearmSeconds, Alert_Background, bear_Color);
                    else*/
                    if (Bars.PercentComplete >= percent/100)
                        Alert("PASuppResBreakoutTest_Resistance", Priority.High, "PASuppResBreakoutTest Resistance " + swingStrength.ToString("N0"), soundFile, 10000, Alert_Background, bear_Color);
                }
                #endregion
    this is the result:
    World's leading screen capture + recorder from Snagit + Screencast by Techsmith. Capture, edit and share professional-quality content seamlessly.


    The alert seems to rearm somehow despite the 10000 seconds set in rearmSeconds!?


    another question:
    The indicator draws lines, only when there is a change in price, but to catch the alerts for slow markets it needs to run on Calculate.OnEachTick. Is there another option like?

    set calculate to Calculate.OnPriceChange and do this:

    Code:
            protected override void OnMarketData(MarketDataEventArgs e)
            {
                      Alert logic here
            }
    Last edited by td_910; 03-13-2019, 05:31 AM.

    #2
    Hello td_910,
    Thanks for your post.

    Based on this snippet-- if that alert is rearming faster it is because of your first condition here:
    Code:
    if (IsFirstTickOfBar) RearmAlert("PASuppResBreakoutTest_Resistance");
    What Calculate setting was this for? OnPriceChange?
    What bar type and period was this?


    There are only three options for the Calculate setting. OnBarClose, OnPriceChange, and OnEachTick.


    Josh G.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_JoshG View Post
      Hello td_910,
      Thanks for your post.

      Based on this snippet-- if that alert is rearming faster it is because of your first condition here:
      Code:
      if (IsFirstTickOfBar) RearmAlert("PASuppResBreakoutTest_Resistance");
      What Calculate setting was this for? OnPriceChange?
      What bar type and period was this?
      Hi Josh,
      this was with OnEachTick on a 5min chart and market replay
      as far as I would read the snippet:
      the alert gets thrown when the bar is to 90% complete (30sec before bar close) with a rearm of 10000 seconds
      the RearmAlert in the snippet should not be executed unless there is the 1st tick of a new bar?!


      There are only three options for the Calculate setting. OnBarClose, OnPriceChange, and OnEachTick.
      https://ninjatrader.com/support/help...?calculate.htm
      yes, I know that
      but the indicator does complex calculations which would be resource consuming using Calculate.OnEachTick
      is there a way to use Calculate.OnPriceChange, but use this for the alert logic only

      protected override void OnMarketData(MarketDataEventArgs e)
      { Alert logic here }

      I also have problems with alerts using multiple instances of the indicator
      the alerts of the 2nd instance are missing

      Comment


        #4
        td_910,

        Are you using an increased speed for playback? Are you fast forwarding/rewinding in between these alerts?
        Does this occur when you are connected to a live data feed instead or just on the playback connection?

        is there a way to use Calculate.OnPriceChange, but use this for the alert logic only

        protected override void OnMarketData(MarketDataEventArgs e)
        { Alert logic here }
        You can use Calculate.OnPriceChange but it would have no impact on using OnMarketData or not. You can use OnMarketData for you alerts, but I do not have any advice on how to implement that. Seems to me the biggest hurdle would be recreating your rearm logic as there would no concept of FirstTickOfBar inside OnMarketData.


        I also have problems with alerts using multiple instances of the indicator
        the alerts of the 2nd instance are missing
        That is going to be another issue entirely as the two alerts would not interact with one another. Do you have errors on the Logs tab of the Control Center?
        Josh G.NinjaTrader Customer Service

        Comment


          #5
          Originally posted by NinjaTrader_JoshG View Post
          td_910,

          Are you using an increased speed for playback? Are you fast forwarding/rewinding in between these alerts?
          Does this occur when you are connected to a live data feed instead or just on the playback connection?

          You can use Calculate.OnPriceChange but it would have no impact on using OnMarketData or not. You can use OnMarketData for you alerts, but I do not have any advice on how to implement that. Seems to me the biggest hurdle would be recreating your rearm logic as there would no concept of FirstTickOfBar inside OnMarketData.
          it was with 1x playback speed https://www.screencast.com/t/CrVmqPcFPP
          the live data feed (IB) seems to work (only one alert per bar), very strange https://www.screencast.com/t/ZOO9d67QO

          putting FirstTickOfBar inside OnMarketData doesn't throw any compiler errors, so far

          That is going to be another issue entirely as the two alerts would not interact with one another. Do you have errors on the Logs tab of the Control Center?
          no errors in the log
          I remember, that I had drawing problems (the drawn objects changed on the chart) with objects created with the same tag with another indicator, where I also use more than one instance

          on this indi I used a unique identifier as part of the object tag
          unique = Guid.NewGuid().ToString("N");

          maybe I need to do that with the alert id as well?

          Comment


            #6
            I added an indicator property to the alert id, now it works, even IsFirstTickOfBar works within OnMarketData
            it seems, that the alert id is shared across all instances of an indicator, if that isn't unique per instance

            btw. that same behavior occurred on NT7 and is solved now

            Code:
                    protected override void OnMarketData(MarketDataEventArgs e)
                    {
                        #region Alert bull
                        if (IsFirstTickOfBar) RearmAlert("PASuppResBreakoutTest_Support"+ swingStrength.ToString("N0"));
            
                        if (showAlert && DrawObjects["BT_Swing_High"+(CurrentBar)] != null)
                        {
                            if (myrearmSeconds>1)
                                Alert("PASuppResBreakoutTest_Support"+ swingStrength.ToString("N0"), Priority.High, "PASuppResBreakoutTest Support " + swingStrength.ToString("N0"), soundFile, myrearmSeconds, Alert_Background, bull_Color);
                            else
                            if (Bars.PercentComplete >= percent/100)
                                Alert("PASuppResBreakoutTest_Support"+ swingStrength.ToString("N0"), Priority.High, "PASuppResBreakoutTest Support " + swingStrength.ToString("N0"), soundFile, 10000, Alert_Background, bull_Color);
                        }
                        #endregion
            World's leading screen capture + recorder from Snagit + Screencast by Techsmith. Capture, edit and share professional-quality content seamlessly.


            can you check/confirm, that it's ok to use IsFirstTickOfBar within OnMarketData
            Last edited by td_910; 03-13-2019, 01:19 PM.

            Comment


              #7
              td_910,

              It will not be possible to use IsFirstTickOfBar inside OnMarketData.
              Josh G.NinjaTrader Customer Service

              Comment


                #8
                Originally posted by NinjaTrader_JoshG View Post
                td_910,

                It will not be possible to use IsFirstTickOfBar inside OnMarketData.
                does the compiler just ignore the code or what does it do with it?

                Comment


                  #9
                  I think it should be fine to rearm the alerts in OnBarUpdate :-)

                  Comment


                    #10
                    td_910,

                    It will compile fine inside the indicator or strategy class, but will essentially be ignored as a condition in OnMarketData

                    Let me know if anything else comes up
                    Josh G.NinjaTrader Customer Service

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                    0 responses
                    649 views
                    0 likes
                    Last Post Geovanny Suaza  
                    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                    0 responses
                    370 views
                    1 like
                    Last Post Geovanny Suaza  
                    Started by Mindset, 02-09-2026, 11:44 AM
                    0 responses
                    109 views
                    0 likes
                    Last Post Mindset
                    by Mindset
                     
                    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                    0 responses
                    574 views
                    1 like
                    Last Post Geovanny Suaza  
                    Started by RFrosty, 01-28-2026, 06:49 PM
                    0 responses
                    576 views
                    1 like
                    Last Post RFrosty
                    by RFrosty
                     
                    Working...
                    X