A bot is disconnected because It tries to send an order to place stop below the Minimum stop required by the broker.
A Solution?
Find what is the minimum stop distance allowed by the broker for that particular instrument and adapt your code or use the stop adjustement function available when you launch a ProOrder code (checkbox). See below attached picture, sorry in French.
And how to include on the Code?
JSParticipant
Senior
Once MinStopDist = 10
If StopDist < MinStopDist then
StopDist = MinStopDist
EndIf
Set Stop Loss StopDist
Once MinStopDist = 10
If StopDist < MinStopDist then
StopDist = MinStopDist
EndIf
Set Stop Loss StopDist
It can also be written this way:
Once MinStopDist = 10
StopDist = max(MinStopDist,StopDist)
Set Stop Loss StopDist
JSParticipant
Senior
Yes, there are many different ways to code it…
Ask Terminator if you dont know 😆
below the Minimum stop required by the broker.
I’m sure your SL’s are > 10 anyway, so what is probably happening is that your code is trying to place a SL during periods of high volatility? This is when IG increases min stop distances to 30, 50, 100 or even many 100’s at times … daft though it sounds.
To guarantee never to be rejected then we would need to use a value for SL that is > the maximum value IG has ever set the minimum distance. So being rejected at times is something we have to live with.
I have ticked the ‘Guaranteed Stop’ AND ‘Readjust Stop’ boxes when starting my Algos and they still get rejected!
if longonmarket AND c2 and c6 and close<positionprice then
sell at market
endif
If shortonmarket and c1 and c5 and close>positionprice then
exitshort at market
endif
I need what this instruction close the operation, but only if price save the minstoploss of broker
I can’t understand what you mean by
“I need what this instruction close the operation, but only if price save the minstoploss of broker”.
Can you explain better?
The bot launches an order to close the operation, but when the price is below the minimum stop required by the broker, the bot is deactivated.
That is the code to close the operation, I need the instruction to save the minimum stop required by the broker.
The bot has its own stop loss.
These orders are separate from that stop loss.
If the operation goes wrong, the operation can be closed with those orders, but the price has to be saving the minimum stop required by the broker, depending on the index it can be 5 pips, 8 pips, 10 pips …
To exit using a pending order you have to:
- set a DISTANCE to be taken into account when placing a pending order
- choose among STOP, LIMIT and AT MARKET orders according to the position of the current price compared to the exit price (stop loss in this case).
There you go:
ONCE Distance = 6 * PipSize //Distance required by the broker (pips)
//
// StopLoss must have been defined elsewhere in your code (and cleared when not OnMarket)
//
IF StopLoss > 0 THEN
IF LongOnMarket THEN //LONG trades
IF (close + Distance) > StopLoss THEN
SELL AT StopLoss STOP //exit at a worse price than the current one
ELSIF (close - Distance) < StopLoss THEN
SELL AT StopLoss LIMIT //exit at a better price than the current one
ELSE
SELL AT Market //exit at market if not within the DISTANCE (you may comment out his line not to exit at market, thus waiting for the next bar to close)
ENDIF
ELSIF ShortOnmarket THEN //SHORT trades
IF (close + Distance) < StopLoss THEN
EXITSHORT AT StopLoss STOP //exit at a worse price than the current one
ELSIF (close - Distance) > StopLoss THEN
EXITSHORT AT StopLoss LIMIT //exit at a better price than the current one
ELSE
EXITSHORT AT Market //exit at market if not within the DISTANCE (you may comment out his line not to exit at market, thus waiting for the next bar to close)
ENDIF
ENDIF
ENDIF