Replies

TaoCTID
25 Aug 2022, 15:03 ( Updated at: 25 Aug 2022, 15:07 )

RE:

Of course, excuse this obvious oversight. I have reduced the code as much as possible in order to reduce the number of factors. Strangely the bug does not seem to occur if the SL is equal to 2 pips or less (I just tested more precisely and the maximum value without bug is 2.2).
 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using cAlgo.API;
using cAlgo.API.Collections;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;

namespace cAlgo.Robots
{
    [Robot(AccessRights = AccessRights.None)]
    public class BBBug : Robot
    {
        
        [Parameter("SL", DefaultValue = 2.0, Step = 0.1, MaxValue = 22.0, MinValue = 0.2)]
        public double SL { get; set; }
        
        readonly DateTime TargetTime = new DateTime(2022, 8, 17, 17, 48, 0);
        
        protected override void OnBar()
        {
            if (Bars.LastBar.OpenTime == TargetTime)
            {
                ExecuteMarketOrder(TradeType.Sell, "EURUSD", 1000, "Test", SL, null);
            }

        }
        
    }
}

The version of cTrader used is 4.3.9


@TaoCTID

TaoCTID
23 Mar 2022, 09:05

RE:

PanagiotisCharalampous said:

We cannot know what each strategy provider does. However, if you need to protect your account, you can use your own equity based stop loss.

Thanks for your answer, so can't we make it so that when a SL is provided, cTrader calculates the position size so that when the SL is triggered the loss is a predefined amount?


@TaoCTID