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

Dynamic Parameter Initialization

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

    Dynamic Parameter Initialization

    I need to be able to compute the initial value of a Strategy parameter. But the Initialization() method in indicators and strategies is invoked for both parameter initialization and indicator/strategy launching.

    For example, the Initialization() method for a strategy is invoked 3 times: (1) when the STRATEGIES menu is opened; (2) when the Strategy is selected as NEW and (3) when the Strategy is launched (APPLY).

    It would be very useful if the Initialization method had an optional parameter which indicated whether the invocation was for parameter initialization, (1) and (2) above, or for launching, (3) above.

    My customers are in the USA. The starting time for our trading is 09:30 EST. I need to prompt my users with a starting time consistent with their local time zone, e.g., 06:30 in California.

    Thanks,

    RVR

    #2
    Thanks for the suggestion. For now, you can use the first call in OnBarUpdate(), when CurrentBar == 0.
    RayNinjaTrader Customer Service

    Comment


      #3
      Why Didn't I Think of That?

      Ray,

      Thanks for the quick response.

      That does make life much simpler!

      RVR

      Comment


        #4
        That Doesn't Do It

        Ray,

        I think you missed my point. If I set the initial parameter value in Initialization() that is the only value ever seen in Initialization() or in OnBarUpdate(), regardless of the value of the CurrentBar.

        A solution is to declare and initialize a PRIVATE boolean variable ParamsNotSet to TRUE. In one of the PARAMETER definitions in the SET method, set ParamsNotSet to FALSE. So in Initialize() you can test ParamsNotSet to determine whether you should set the parameter's initial value or process the final parameter value.

        This should really be an optional parameter of Initialize() but the above solution is working fine for me in the current release.

        Thanks,

        RVR

        Comment


          #5
          I understood, thanks for clarifying.
          RayNinjaTrader Customer Service

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by suroot, 04-10-2017, 02:18 AM
          4 responses
          3,021 views
          0 likes
          Last Post truepenny  
          Started by Stanfillirenfro, Today, 07:23 AM
          1 response
          6 views
          0 likes
          Last Post NinjaTrader_Gaby  
          Started by cmtjoancolmenero, Yesterday, 03:58 PM
          2 responses
          22 views
          0 likes
          Last Post cmtjoancolmenero  
          Started by olisav57, Yesterday, 07:39 PM
          1 response
          9 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Started by cocoescala, 10-12-2018, 11:02 PM
          7 responses
          944 views
          0 likes
          Last Post Jquiroz1975  
          Working...
          X