BobParticipant
New
I would find useful to have a trailing stop that will stay below the SAR indicator when buying and vice versa when selling. The same coding I guess would apply if using a Moving average or other indicator.
I used the below code that gives excellent result in back-testing but it appears is a sort of curve fitting as it does not work in real market.
SAR1 = SAR[0.02,0.02,0.2][1]
// Stops and targets
SET STOP pTRAILING SAR1
Hello Bob, pTRAILING is a pip/point distance between the STOP and the current price. So you have to find this distance by substracting the SAR value and the price one.
BobParticipant
New
Thanks Nicolas. Pity because it would have been nice to have a sort of dynamic trailing stop.
Do you know why when trading through IG with your platform it is not possible to have a stop loss and a trailing stop at the same time?
Example:
SET STOP LOSS 20 pTRAILING 10
Thanks
The example i shown to you is a dynamic trailing stop. It’s actually the same to have a fixed price or a price difference between 2 points.
Just to be clear :
SAR1 = SAR[0.02,0.02,0.2][1]
// Stops and targets
mytrailing = ABS(Open-SAR1)
SET STOP pTRAILING mytrailing
or you can also change dynamically your stoploss at each new bar :
SAR1 = SAR[0.02,0.02,0.2][1]
// Stops and targets
mystop = ABS(Open-SAR1)
SET STOP pLOSS mystop
Of course I made no conditional request to the server to test if the SAR is above or below your price, it will handle by itself if it can place the stoploss for a buy or a sell order.