Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Overriding the strategy parameters (using values hardcoded)

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

    Overriding the strategy parameters (using values hardcoded)

    I see for the help on ExitOnClose that one can specify this in the initialize method:

    Code:
    protected override  void Initialize()  
    { 
        // Triggers the exit on close function 30 seconds prior to session  end 
        [COLOR=#ffffff]ExitOnClose[/COLOR]        = true; 
         ExitOnCloseSeconds = 30; 
    }
    When I do this, it seems that the value in the code is ignored and the value given in the strategy parameters (dialog box) is used. Is it possible to override these values? For example, sometimes I forget to change one of the values and I run my strategy and get unexpected results. If I can code them in the init method then I wouldn't have to worry about this.

    #2
    Whatever value you set for ExitOnClose you in Initialize() would make it to the strategy properties dialog and thus would be effective if you didn't change it.

    What probably confuses you is the fact, that the strategies property dialog maintains the last set of values. Unfortunately there is no way around.

    Comment


      #3
      Originally posted by NinjaTrader_Dierk View Post
      Whatever value you set for ExitOnClose you in Initialize() would make it to the strategy properties dialog and thus would be effective if you didn't change it.

      What probably confuses you is the fact, that the strategies property dialog maintains the last set of values. Unfortunately there is no way around.
      ok this makes sense that it retains the values so that one wouldn't have to override them every time. So I will code up the values I use the most and then exit NT and then restart and from then on it should use my values that I code in intialize right? This seems like a logical way to have this, to make it easy to override but not require the user to type in the values.

      Thanks

      Comment


        #4
        Yes, this makes sense

        Comment


          #5
          Exit Not On Close If strategy made profit

          Hello

          Is there a way within a strategy to change the ExitOnClose Flag
          depending on if the strategy made profit today, or would you recommend exiting all positions by a specific time and not use the Exit On Close = true at all in strategies?

          Regards
          tradereight

          Comment


            #6
            Hello,

            I recommend manually coding out your exit rather than using the ExitOnClose.
            DenNinjaTrader Customer Service

            Comment


              #7
              Can I set the session begin time? It's a pain having to do it by hand every time I do a backtest or start a strategy.

              Comment


                #8
                Hello,

                It may work but I recommend changing the code to exit at a certain time. Give it a try using a condition something like this:

                if(ToTime(Time[0]) >= 93000)
                {
                ExitLong(....);
                }

                This link may help:
                http://www.ninjatrader-support2.com/...ead.php?t=3226
                DenNinjaTrader Customer Service

                Comment


                  #9
                  So you're recommending leaving the session begin/end time at midnight and using a filter on the trading hours? This is a good idea because my strategy is multi-instrument and different instruments have different trading hours. The only problem I see is indicators would be calculated based on non-trading hours data, which I don't think is what I want.

                  Originally posted by NinjaTrader_Ben View Post
                  Hello,

                  It may work but I recommend changing the code to exit at a certain time. Give it a try using a condition something like this:

                  if(ToTime(Time[0]) >= 93000)
                  {
                  ExitLong(....);
                  }

                  This link may help:
                  http://www.ninjatrader-support2.com/...ead.php?t=3226

                  Comment


                    #10
                    Hello,

                    Then you may want to do both, however it is user preference.
                    DenNinjaTrader Customer Service

                    Comment


                      #11
                      Originally posted by NinjaTrader_Ben View Post
                      Hello,

                      Then you may want to do both, however it is user preference.
                      Ok, got it. Thanks.

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by Johnny Santiago, 10-11-2019, 09:21 AM
                      95 responses
                      6,193 views
                      0 likes
                      Last Post xiinteractive  
                      Started by xiinteractive, 04-09-2024, 08:08 AM
                      2 responses
                      11 views
                      0 likes
                      Last Post xiinteractive  
                      Started by Irukandji, Today, 09:34 AM
                      1 response
                      3 views
                      0 likes
                      Last Post NinjaTrader_Clayton  
                      Started by RubenCazorla, Today, 09:07 AM
                      1 response
                      5 views
                      0 likes
                      Last Post RubenCazorla  
                      Started by TraderBCL, Today, 04:38 AM
                      3 responses
                      25 views
                      0 likes
                      Last Post NinjaTrader_Jesse  
                      Working...
                      X