Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Stop percent optimization

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

    Stop percent optimization

    Hi

    i try a simple code with a stop calculation.mode percent

    i would like to optimize the percent of the stop, but i don't know how to do it.

    when i write :

    #region Varaibles
    privateint stop = 1;

    OnBarUpdate
    SetStopLoss("X pourcent", CalculationMode.Percent, stop/100, false);

    it is not working... when a trade is initiated, it is directly stopped

    if i write
    #region Varaibles
    privateint stop = 0.01;

    it is not working as well (error CS0266)


    In the 2 cases on the #region Properties i write

    [Description("stop en pourcentage")]
    [GridCategory(
    "Parameters")]
    publicint Stop
    {
    get { return stop; }
    set { stop = Math.Max(1, value); }
    }


    can you help ?
    thx

    #2
    Hello Thomas79,

    Thank you for your post.

    Set the variable as a double. Below is an example that will optimize properly:
    Code:
            #region Variables		
            private double stop = 0.1;
            #endregion
    
            
            protected override void Initialize()
            {
               	SetStopLoss("entry", CalculationMode.Percent, stop, false);
            }
    		
    		protected override void OnBarUpdate()
    		{
    			if(Close[0]>Close[1])
    			{
    				EnterLong(1,"entry");
    			}
    		}
    
    		
            #region Properties
            [Description("Percent Stop")]
    		[GridCategory("Parameters")]
    		public double Stop
    		{
    			get { return stop; }
    			set { stop = Math.Max(0.1, value); }
    		}
    Please let me know if you have any questions.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Hwop38, 05-04-2026, 07:02 PM
    0 responses
    160 views
    0 likes
    Last Post Hwop38
    by Hwop38
     
    Started by CaptainJack, 04-24-2026, 11:07 PM
    0 responses
    307 views
    0 likes
    Last Post CaptainJack  
    Started by Mindset, 04-21-2026, 06:46 AM
    0 responses
    244 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by M4ndoo, 04-20-2026, 05:21 PM
    0 responses
    348 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by M4ndoo, 04-19-2026, 05:54 PM
    0 responses
    178 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Working...
    X