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 kinfxhk, 07-14-2026, 09:39 AM
    0 responses
    123 views
    0 likes
    Last Post kinfxhk
    by kinfxhk
     
    Started by kinfxhk, 07-13-2026, 10:18 AM
    0 responses
    104 views
    0 likes
    Last Post kinfxhk
    by kinfxhk
     
    Started by kinfxhk, 07-13-2026, 09:50 AM
    0 responses
    82 views
    0 likes
    Last Post kinfxhk
    by kinfxhk
     
    Started by kinfxhk, 07-13-2026, 07:21 AM
    0 responses
    102 views
    0 likes
    Last Post kinfxhk
    by kinfxhk
     
    Started by kinfxhk, 07-11-2026, 02:11 AM
    0 responses
    83 views
    0 likes
    Last Post kinfxhk
    by kinfxhk
     
    Working...
    X