I trade auto strategies via IG and from time to time I get the following message
“order status: rejected order rejected by the broker or the market
The order level you have requested is too close to current market level , The minimum distance is X points ”
As the broker has widened the the limit level for the market to X points.
When this happens the strategy is stopped and I have to manually make it active
This usually happens during economic releases but can happen at other times. Also they can change the level it is widened to , for example for S&P 500 it can be a low as 1 point but it can be as wide as 40 points
I would like to know if there are any lines of code that can be added to prevent this from happening within the strategy coding , hence prevent the order being rejected and the strategy being stopped ?
Ideally, it would be great having something in the ‘ProOrder AutoTrading’ screen that allows you to click a check box to allow such instances to be executed at market when PRT receives such a rejectiom request or even better would be for the limit to be widened by y Points each time it is rejected until it gets executed
Thanks
Are you ticking / enabling the ‘Auto-Adjust stops’ box when you start your Algos?
If No, then try it.
Yes I am, but from my understanding of this functionality it only changes the stops once the order has executed. So if a live order has to adjust its stop and the broker has widened the minimum distance then it will adjust accordingly.
My issue is similar but on the actual order being executed in the first instance. Ticking this box does not resolve this for the parent order being initially executed if the limit is less than that set by the broker for the instrument
Yes, you need to set a minimum distance large enough to prevent that error when using pending orders (STOP and LIMIT ones), as for AT MARKET orders there’s no such issue. If the required distance for an instrument is, say, 6 pips, you can set that distance to 10+ to try to prevent your strategy from being stopped. Unfortunately there’s no way to know when the broker modify that limit and by how many points. So, there’s no guarantee that setting that distance to twice the regular requirement will do.
Anyway, this is the code you can use:
ONCE Distance = 10*PipSize //set a 10-point distance
IF myLongConditions THEN
IF close > (myEntryPrice + Distance) THEN
BUY 1 CONTRACT AT myEntryPrice LIMIT
ELSIF close < (myEntryPrice - Distance) THEN
BUY 1 CONTRACT AT myEntryPrice STOP
ELSE
BUY 1 CONTRACT AT Market
ENDIF
ELSIF myShortConditions THEN
IF close > (myEntryPrice + Distance) THEN
SELLSHORT 1 CONTRACT AT myEntryPrice STOP
ELSIF close < (myEntryPrice - Distance) THEN
SELLSHORT 1 CONTRACT AT myEntryPrice LIMIT
ELSE
SELLSHORT 1 CONTRACT AT Market
ENDIF
ENDIF
you will have to set your SL and TP as usual.
You may comment out the two lines with the AT MARKET entry to skip opening a trade when there is a tight distance. As it is now, a position will always be opened when your conditions are met.
Thanks- this is exactly what I have coded as a work around to the problem but as you said you never know how when or by how much the broker will widen by