Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Optimizing Stop Loss and Profit Target

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

    Optimizing Stop Loss and Profit Target

    Hi,

    I'm trying to optimize the Stop Loss and Profit Target I use in my strategy. Can someone from reading the below explain why when I try to optimize the strategy in 'Strategy Analyzer' it only lets me optimize DMX_len, T3_boost, T3_length and not StopLoss and ProfitTarget?

    Code:
    #region Using declarations
    using System;
    using System.ComponentModel;
    using System.Diagnostics;
    using System.Drawing;
    using System.Drawing.Drawing2D;
    using System.Xml.Serialization;
    using NinjaTrader.Cbi;
    using NinjaTrader.Data;
    using NinjaTrader.Indicator;
    using NinjaTrader.Strategy;
    #endregion
    
    namespace NinjaTrader.Strategy
    {
    	#region Header
    		[Description("trades triggered by T3 on DMX")]
    		public class Jurik_DMX_and_T3 : Strategy
    		#endregion
    	{
    		#region Variables	// default values
    			private int dmx_len = 10 ; 
    			private double t3boost = 0.0; 
    			private double t3len = 37; 
    			// --------------------------------
    			private double T3_value = 0;
    		    private int profitTarget = 12; // Default setting for ProfitTarget
            	private int stopLoss = 6; // Default setting for StopLoss
    			private DataSeries T3_series;
    			#endregion
    		
    		#region Input Parameters
    			[Description("DMX length, any integer > 2")]
    			[GridCategory("Parameters")]
    			public int DMX_len
    			{
    				get { return dmx_len; }
    				set { dmx_len = Math.Max(3, value); }
    			}
    			
    			[Description("Profit Target > 2")]
    			[GridCategory("Parameters")]
    			public int ProfitTarget
    			{
    				get { return profitTarget; }
    				set { profitTarget = Math.Max(3, value); }
    			}
    			
    			[Description("Stop Loss > 2")]
    			[GridCategory("Parameters")]
    			public int StopLoss
    			{
    				get { return stopLoss; }
    				set { stopLoss = Math.Max(3, value); }
    			}
    			
    			[Description("T3 boost, any value between 0 and 1")]
    			[GridCategory("Parameters")]
    			public double T3_boost
    			{
    				get { return t3boost; }
    				set { t3boost = Math.Min(Math.Max(0, value),1); }
    			}
    			
    			[Description("T3 length, any value >= 1")]
    			[GridCategory("Parameters")]
    			public double T3_length
    			{
    				get { return t3len; }
    				set { t3len = Math.Max(1, value); }
    			}
    			#endregion
    
            protected override void Initialize()
            {
    			#region Chart Features
    				Add(Jurik_DMX_and_T3( DMX_len, T3_boost, T3_length));		
    				CalculateOnBarClose	= false ;
    				#endregion
    			
    			#region Series Initialization
    				T3_series = new DataSeries(this);	// sync dataseries to historical data bars
    				#endregion
    			
    			SetStopLoss(CalculationMode.Ticks, StopLoss);
    			SetProfitTarget(CalculationMode.Ticks, ProfitTarget);
    			}
    
            protected override void OnBarUpdate()
            {
    			#region Strategy Formula
    				T3_value = Jurik_DMX_and_T3( DMX_len, T3_boost, T3_length).T3_series[0];
    				T3_series.Set(T3_value);
    				
    				if (CrossAbove(T3_series, 0, 1))
    					EnterLong(1, "L");
    				else if (CrossBelow(T3_series, 0, 1))
    					EnterShort(1, "S");
    				#endregion
            }
        }
    }
    Any help would be greatly appreciated. Thank you.

    Kindest Regards,
    Harry Seager

    #2
    Hello Harry,
    To assist you further can you tell me what settings you are using to optimize the strategy.

    I look forward to assisting you further.
    JoydeepNinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_Joydeep View Post
      Hello Harry,
      To assist you further can you tell me what settings you are using to optimize the strategy.

      I look forward to assisting you further.
      Settings? What exactly do you mean? I have attached a screen shot of what I think you're after. You'll be able to see the top 3 parameters, what I want to do is have an additional 2 parameters for TP and SL but my efforts to do this so far haven't been successful!

      Cheers,
      Harry
      Attached Files

      Comment


        #4
        Hello Harry,
        I cannot test the strategy fully at my end as the strategy refers to an 3rd party indicator. So that I may test it further can you please send the indicator Jurik_DMX_and_T3 to support[AT]ninjatrader[DOT]com


        Please append Attn:Joydeep in the subject line of the email and give a reference of this thread in the body of the email.

        I look forward to assisting you further.
        JoydeepNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        656 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        371 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        109 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        574 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        579 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X