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

Disabling strategy event because of Data Connection loss

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

    Disabling strategy event because of Data Connection loss

    Hello,

    I'm having a hard time finding a suitable solution.
    I'm running a strategy which disable itself sometimes, due to some failure of the data stream of my broker.
    In fact it loses the data connection every day around 06:30 in the moring, sometimes for couple of minutes, but sometimes for more than 15 (which is too much)
    If it hits +15min it disables itself.
    How can I fetch this "disable" event?
    I tried the terminate but it did not suit the situation.
    PS I'm sending emails when events occure.

    All the best





    #2
    Hello fernlicht,

    Connection losses can be detected in OnConnectionStatusUpdate, but this would only be if the strategy is not disabled.


    If the Strategy is disabled, only OnStateChange will run with State.Terminated.
    (You can use a bool that is set to true once the strategy reaches State.DataLoaded to know that the instance of the strategy was previously enabled)
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      I'm already using OnStateChange like you've described
      it sends me a mail but only if the strategy is closed means CTRL+W

      here the sample code
      .....
      else if (State == State.DataLoaded)
      {
      IsDisabled = true;
      }
      ........
      else if (State == State.Terminated)
      {
      if(IsDisabled == true && State == State.Realtime) // IsDisabled is uesed in DataLoded
      {
      SendTextMail("STRATEGY TERMINATED:");
      Print(Time[0]+" Strategy terminated");
      }
      }
      ......

      Comment


        #4
        Hello fernlicht,

        Other traders are finding success with this.
        https://ninjatrader.com/support/foru...gy-is-disabled

        However, the State will not be State.Reatime when the State is State.Terminated. That condition will never be true.
        The State property cannot have two values at the same time.

        With an indicator you could detect when the connection is re-established in OnConnectionStatusUpdate() and send an email then..
        Chelsea B.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by algospoke, Yesterday, 06:40 PM
        2 responses
        20 views
        0 likes
        Last Post algospoke  
        Started by ghoul, Today, 06:02 PM
        3 responses
        14 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Started by jeronymite, 04-12-2024, 04:26 PM
        3 responses
        45 views
        0 likes
        Last Post jeronymite  
        Started by Barry Milan, Yesterday, 10:35 PM
        7 responses
        21 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Started by AttiM, 02-14-2024, 05:20 PM
        10 responses
        181 views
        0 likes
        Last Post jeronymite  
        Working...
        X