CT 4.2 - Reverse Order Bug
CT 4.2 - Reverse Order Bug
17 May 2022, 11:22
Hi,
There seems to be an issue with reversing a trade direction using cTrader beta 4.2, I ran this basic test.
namespace cAlgo.Robots
{
[Robot(AccessRights = AccessRights.None)]
public class ReverseTest : Robot
{
[Parameter(DefaultValue = "Hello world!")]
public string Message { get; set; }
protected override void OnStart()
{
ExecuteMarketOrderAsync(TradeType.Buy, SymbolName, 50);
}
protected override void OnBar()
{
foreach (var position in Positions.Where(x => (x.SymbolName == Symbol.Name)).Where(x => x.TradeType == TradeType.Buy))
{
position.Reverse();
}
}
}
}
What happens is that the order opens for BTCUSD with 50 lots, but when the candle closes (1-min TF) and the position is reversed, a notification states that the order was abnormal and attempted to reverse with double the original trade size.
I also tried ReversePosition(position), and had the same issue.
This works ok with 1 lot
Replies
amusleh
18 May 2022, 10:20
Hi,
After discussing this with our team we found that it's not a bug but the expected behavior, when you reverse a position platform opens an opposite direction position with double the volume of original position, if this doubled volume was larger than symbol maximum allowed volume then you will receive an error message and the operation will fail.
In your case as you are using Automate API, you can manually first close the position and then open a new position with same exact volume, this will avoid the issue you are facing.
@amusleh
amusleh
17 May 2022, 14:42 ( Updated at: 17 May 2022, 14:48 )
Hi,
It's because your order request volume is higher than symbol maximum allowed volume, in your case the reverse order request volume is 100 while the symbol maximum allowed volume is 50.
It's a bug, thanks for reporting.
@amusleh