Announcement

Collapse
No announcement yet.

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.

    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.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by NullPointStrategies, Yesterday, 05:17 AM
        0 responses
        62 views
        0 likes
        Last Post NullPointStrategies  
        Started by argusthome, 03-08-2026, 10:06 AM
        0 responses
        134 views
        0 likes
        Last Post argusthome  
        Started by NabilKhattabi, 03-06-2026, 11:18 AM
        0 responses
        75 views
        0 likes
        Last Post NabilKhattabi  
        Started by Deep42, 03-06-2026, 12:28 AM
        0 responses
        45 views
        0 likes
        Last Post Deep42
        by Deep42
         
        Started by TheRealMorford, 03-05-2026, 06:15 PM
        0 responses
        50 views
        0 likes
        Last Post TheRealMorford  
        Working...
        X