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 JonesJoker, 04-22-2024, 12:23 PM
        6 responses
        32 views
        0 likes
        Last Post JonesJoker  
        Started by GussJ, 03-04-2020, 03:11 PM
        12 responses
        3,239 views
        0 likes
        Last Post Leafcutter  
        Started by AveryFlynn, Today, 04:57 AM
        0 responses
        5 views
        0 likes
        Last Post AveryFlynn  
        Started by RubenCazorla, 08-30-2022, 06:36 AM
        3 responses
        79 views
        0 likes
        Last Post PaulMohn  
        Started by f.saeidi, Yesterday, 12:14 PM
        9 responses
        25 views
        0 likes
        Last Post f.saeidi  
        Working...
        X