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 Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    579 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    334 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    101 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    554 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    551 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X