I am trying to run a script that I would like to have multiple different stops on it:
a hard stop loss of 10 points (in case of an immediate reversal upon entry)
a trailing stop of 20 points
a break even of 2 points to ensure some profit if gains are made but TS is still in the red but less than hard stop of 10
Everything I have tried I get OCO order failures and script disables OR I have an entry but the script immediately shuts down and I have a zombie trade running with 0 TP/SL.
Currently running a trailing only (which will suffice if I canāt do the above listed) but curious if what I want is even possible / any insight.
Iāll explain how I would do it in Unmanaged mode:
you should only have one Stop Loss order, which you would move according to your logic to handle trailing and breakeven.
You would execute the reverse when the price reaches that level. First, you would need to cancel the Stop Loss (and the broker will automatically cancel the Take Profit order as well, if it supports OCO). After receiving confirmation of the cancellation, you would submit the order for the new entry. Once the entry is filled, you would submit the SL + TP bracket with a new OCO tag.
Therefore, in practice there is only one Stop Loss order, and the OCO should not fail (unless you reuse OCO strings or exceed the maximum length supported by the brokerābe careful with this, because it may work fine in backtesting but fail in real time if the broker has OCO limitations).
To add to cls71 points, beware that for some brokers OCO orders are client side. I ran into this personally with Rithmic when my platform was offline and my stop was hit. The market then ran up to my target and put me back into a position.
Ah, I see what you are saying, treat each one broken out in separate commands of specific if than not doing a full ādo all of this upon entryā along with cancel replace logic type thing. Ill have to play around with this, thanks for the food for thought.
Thank you so much for this insight, I was able to get it to work because of your help!
I did get a new error ive never seen [havenāt gotten to this point yet], a rate limit error that shuts own the script, will have to tackle this next.