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

Remember A Value After Disabling Strategy

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

    Remember A Value After Disabling Strategy

    Good evening support staff,

    I was wondering if it's possible to have an integer or double value in the script of a strategy that the strategy is able to remember even if the strategy is disabled and then enabled. For an example, I want the strategy to remember that the most recently filled trade by the strategy was a short or long entry when I enable it again.

    Thank you in advance for your time, I look forward to your reply.

    Kind regards,

    GLFX005

    #2
    Hello GLFX005,

    Thank you for your post.

    You could consider using static variables in a NinjaScript AddOn that the strategy could access and update. See the MySharedMethodsAddOnExample script in the forum thread below which demonstrates creating static methods in an AddOn.

    MySharedMethodsAddOnExample: https://ninjatrader.com/support/foru...est#post733956

    Let us know if we may assist further.
    Kate W.NinjaTrader Customer Service

    Comment


      #3
      Hello Kate, thank you for your reply.

      Would it be possible to use State.Terminated to check what the last Position.MarketPosition (or an integer) was, to then use that information to change the value of a Public Integer of the strategy that is loaded on a chart?

      Comment


        #4
        Hello GLFX005,

        Thank you for your reply.

        You could check for an existing position in State.Terminated and assign a value to a static variable in an addon as in my prior post, but a public variable contained within the strategy itself would only be accessible during that particular run of the strategy and would not be retained on the next enablement.

        Please let us know if we may be of further assistance to you.
        Kate W.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by pechtri, 06-22-2023, 02:31 AM
        10 responses
        124 views
        0 likes
        Last Post Leeroy_Jenkins  
        Started by judysamnt7, 03-13-2023, 09:11 AM
        4 responses
        59 views
        0 likes
        Last Post DynamicTest  
        Started by ScottWalsh, Yesterday, 06:52 PM
        4 responses
        36 views
        0 likes
        Last Post ScottWalsh  
        Started by olisav57, Yesterday, 07:39 PM
        0 responses
        7 views
        0 likes
        Last Post olisav57  
        Started by trilliantrader, Yesterday, 03:01 PM
        2 responses
        22 views
        0 likes
        Last Post helpwanted  
        Working...
        X