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 after validating UI Properties

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

    Disabling Strategy after validating UI Properties

    I have some UI properties and want to make sure the strategy does not move forward if two UI properties are not equal to each other.

    I am validating the two UI properties in the Configure state (this state is reached once the user clicks in the OK or Apply button in the Strategy Configuration window).

    Is there an easy way to prevent/stop the execution of the strategy if these two UI properties are not the same?

    Example:

    if (UIProperty1 != UIProperty2)
    CANCEL the Strategy execution

    I would like it to continue in the Strategy Configuration window. I don't think this is possible based on some posts that I found. If that is the case, how can I stop the strategy from executing and also close the Strategy Configuration window?

    Thanks,

    #2
    Hello GARZONJ,

    As long as the properties are the same type thats fine to compare them to each other.

    A return in OnBarUpdate() when this condition is true, would prevent the code below the return from executing.

    if (UIProperty1 != UIProperty2)
    {
    return;
    }

    Alternatively, if you want to disable the strategy you can call CloseStrategy();.


    There are no supported methods to close the Strategies window. That would be unexpected behavior that looks like a bug to many people.
    Last edited by NinjaTrader_ChelseaB; 12-08-2020, 03:15 PM.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Just to clarify, if I do the first the technique, the strategy is not disabled.
      Technique 1:
      if (UIProperty1 != UIProperty2)
      {
      return;
      }

      If I do technique 2, the strategy is disabled.
      Technique 2:
      CloseStrategy()


      Sound like technique 2 is the only way to disable a strategy.

      So to validate UI properties, I add my logic to a method. This method I can run it either at Configure state or at the beginning of the OnBarUpdate(). If the validation is not in accordance to my logic, I can set a boolean like haltProcess. If halProcess is true (because the validation is not in accordance to my logic), then CloseStrategy().


      At a high level, is this the only way to validate UI properties?

      Comment


        #4
        Hello GARZONJ,

        If you would like to run logic like a comparison, or a return, or CloseStrategy(), this must done in a method after State reached State.DataLoaded.
        Chelsea B.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by rajendrasubedi2023, Today, 09:50 AM
        2 responses
        14 views
        0 likes
        Last Post rajendrasubedi2023  
        Started by geddyisodin, Today, 05:20 AM
        4 responses
        29 views
        0 likes
        Last Post geddyisodin  
        Started by geotrades1, Today, 10:02 AM
        2 responses
        8 views
        0 likes
        Last Post geotrades1  
        Started by ender_wiggum, Today, 09:50 AM
        1 response
        5 views
        0 likes
        Last Post NinjaTrader_Gaby  
        Started by bmartz, Today, 09:30 AM
        1 response
        10 views
        0 likes
        Last Post NinjaTrader_Erick  
        Working...
        X