Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Optimize exit time

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

    Optimize exit time

    Hi all,

    Is there any way to optimize exit time using strategy analyzer or any other tool??

    Regards,

    Fernando

    #2
    Hello,

    Thank you for the question.

    This would certainly be possible using the Strategy Analyzer, mainly you can optimize most any property that you make so long as it is of a type the optimizer can optimize.

    An example would be making a public user input of int type. This could be optimized and is also the type ToTime() uses in NinjaScript. You could utilize the int value to control what time the condition exits.

    I see this was posted in the automated trading section so I did not want to overwhelm you with NinjaScript in the case you are not writing the strategy. If you are, I could certainly provide a sample of the code needed.

    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Hi Jesse,

      Thanks a lot for your answer. Yes, I am writing script but I have never programmed time variables. Could you please provided me a code sample?.

      By the way, Is Exit_On_Close_Seconds a Ninjatrader function and can be used, as for instance, Enterlong()?

      Regards,

      Fernando

      Comment


        #4
        Hello,

        For a Time condition to be optimized, you would need to use an int variable.

        The Time functions in NInjaTrader convert a DateTime such as Time[0] to a integer like: 134500 which you could then optimize. :http://ninjatrader.com/support/helpG...ightsub=totime

        For example, you could make a StartTime input that could be optimized:


        Code:
        private int myInputTime;
        
        protected override void OnBarUpdate()
        {
        	if(ToTime(Time[0]) > MyInputTime)
        	{
        		//some strategy action	
        	}
        }
        
        [Description("Numbers of bars used for calculations")]
        [GridCategory("Parameters")]
        public int MyInputTime
        {
        	get { return myInputTime; }
        	set { myInputTime = value; }
        }
        In the optimizer, this property could be used with settings like the following:

        Min Value: 134500
        Max Value: 135000
        Increment: 100

        this would run an iteration on 134500, 134600, 134700, 134800, 134900, 135000

        This is a simple example but you could expand this in any direction depending on the NinjaScript item you want to optimize, so long as you make a Int value you could optimize any property. Mainly you would just need to make that value equate to a int somehow.

        Regarding Exit_On_Close_Seconds, you could use this as well but it is not able to be optimized. Exit_On_Close_Seconds simply defines the amount of seconds before close to exit, to truly optimize a close you would need to program the logic to do that.

        I look forward to being of further assistance.
        JesseNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by benmarkal, Yesterday, 12:52 PM
        3 responses
        22 views
        0 likes
        Last Post NinjaTrader_Gaby  
        Started by helpwanted, Today, 03:06 AM
        1 response
        17 views
        0 likes
        Last Post sarafuenonly123  
        Started by Brevo, Today, 01:45 AM
        0 responses
        11 views
        0 likes
        Last Post Brevo
        by Brevo
         
        Started by aussugardefender, Today, 01:07 AM
        0 responses
        6 views
        0 likes
        Last Post aussugardefender  
        Started by pvincent, 06-23-2022, 12:53 PM
        14 responses
        244 views
        0 likes
        Last Post Nyman
        by Nyman
         
        Working...
        X