Critical bot action error. Bankruption possible.

Created at 24 Jul 2024, 21:10
How’s your experience with the cTrader Platform?
Your feedback is crucial to cTrader's development. Please take a few seconds to share your opinion and help us improve your trading experience. Thanks!
PA

patrickandrade2

Joined 22.07.2024

Critical bot action error. Bankruption possible.
24 Jul 2024, 21:10


I had some issues while backtesting some strategies and found weird how some positions never closed, they were opened, got the bot into a HUGE debt and for some reason it was a reoccurring problem. Did not know what it was until a couple of moments ago:

This is a bot with a Macd & Rsi Strategy with a fixed 15 stop loss limit. What happens is: when putting the trade according to what it detected to be a position of trade there's a sudden massive movement, stop loss already happened in the same couple of seconds so the bot just go forward with it nonetheless. Now I'm in a huge negative position and will hold for long hoping for an upward position after session is open. The bot also does not close the position, since it will wait until forever and ever to get the take profit necessary.

This is a HUGE CRITICAL error that could actually bankrupt an account. I was in the middle of my FTMO Founding test while using Ctrader and guess what, just got eliminated. 

The bot NEEDS a double check before entering any position, if expected Stop Loss is still feasible, if yes, proceed, if not, cancel order.

I do hope this is fixed before bankrupting anyone.


@patrickandrade2
Replies

PanagiotisCharalampous
25 Jul 2024, 05:46

As explained in your other thread, this is an issue of your cBot, you need to handle this situation inside your cBot code


@PanagiotisCharalampous

patrickandrade2
25 Jul 2024, 14:36

RE: Critical bot action error. Bankruption possible.

PanagiotisCharalampous said: 

As explained in your other thread, this is an issue of your cBot, you need to handle this situation inside your cBot code

I saw that other people had the exact same problem, and the same issue happens even if you use an algo bot ctrader generated bot. I don't think it's a “me” problem, there's even a post on quora about someone who had the exact same issue and didn't find any answer here or in the ctrader database. Looks like it's something like a latency issue with ctrader while using bots, if there's a command to input a stop loss and the ctrader doesn't compute that command and proceeds with the order it doesn't look like something an external code should fix.


@patrickandrade2

PanagiotisCharalampous
26 Jul 2024, 06:05

RE: RE: Critical bot action error. Bankruption possible.

patrickandrade2 said: 

PanagiotisCharalampous said: 

As explained in your other thread, this is an issue of your cBot, you need to handle this situation inside your cBot code

I saw that other people had the exact same problem, and the same issue happens even if you use an algo bot ctrader generated bot. I don't think it's a “me” problem, there's even a post on quora about someone who had the exact same issue and didn't find any answer here or in the ctrader database. Looks like it's something like a latency issue with ctrader while using bots, if there's a command to input a stop loss and the ctrader doesn't compute that command and proceeds with the order it doesn't look like something an external code should fix.

Hi there,

I have explained why this happens and how it can be handled. If you have evidence that this is not what happens i.e. you set a stop loss outside the spread but it is not placed, then provide us with clear instructions on how to reproduce this and we will have a look.

Best regards,

Panagiotis


@PanagiotisCharalampous

firemyst
27 Jul 2024, 03:53 ( Updated at: 28 Jul 2024, 05:09 )

RE: RE: Critical bot action error. Bankruption possible.

patrickandrade2 said: 

PanagiotisCharalampous said: 

As explained in your other thread, this is an issue of your cBot, you need to handle this situation inside your cBot code

I saw that other people had the exact same problem, and the same issue happens even if you use an algo bot ctrader generated bot. I don't think it's a “me” problem, there's even a post on quora about someone who had the exact same issue and didn't find any answer here or in the ctrader database. Looks like it's something like a latency issue with ctrader while using bots, if there's a command to input a stop loss and the ctrader doesn't compute that command and proceeds with the order it doesn't look like something an external code should fix.

As @PanagiotisCharalampous explained, you need to explain exactly how to reproduce the issue and/or provide code that does.

Otherwise, you need to put checks in your code, which I'm guessing you haven't since you haven't posted any code?

This simple example checks the spread before an order is placed (you need to make sure it's smaller than the distance to your SL as well), and also checks that after an order is successful, if there's a stop loss:

if (Symbol.Spread < myMaxSpreadPipsAllowedToPlaceAnOrder)
{
    //Spread is less than our threshold, so you can place your order now
	TradeResult r = ExecuteMarketOrder(TradeType.Buy, s.Name, InitialPositionSize, _positionLabel, yourSL, yourTP, commentString, false);
	if (r.IsSuccessful)
	{
		//Get your new position and store in in a variable. In this case, I've named it "_p_".

		//Then check to make sure there's a stop loss
		if (_p.StopLoss.GetValueOrDefault() == 0)
		{
			Print("WARNING! There is no stoploss! Why?! \"{0} {1}\".", _p.Id, _p.Label);
			//close your position, or try implementing a new stop loss, or whatever.
		}
	}
}
else
{
	Print("WARNING! Spread {0} is too big! Not placing order", Symbol.Spread);
}

That should help get you going in the right direction.

 


@firemyst