Set a trailing stop x percent from average position price.
Syntax:
1 |
SET STOP %TRAILING x |
Example:
We are setting here a trailing stop at 1.5 percent from the current average price
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
//indis i1 = average(close)[100] i2 = average(close)[5] tradeinitiate = Close>i1 AND Close<i2 AND Low[3]>Low[2] AND Low[2]>Low[1] AND Low[1]>Low tradeclose = Close>Close[1] IF NOT LongOnMarket AND tradeinitiate THEN BUY 1 CONTRACTS AT MARKET ENDIF If LongOnMarket AND tradeclose THEN SELL AT MARKET ENDIF //set stop loss trailing at 1.5 percent from the current average price SET STOP %TRAILING 1.5 |
Hello, I am quite new in backtest and i would like to test a % trailing stop. I see that accuracy of this function depends on the % defined in the commande : a bigger % drives to a fewer accuracy of the exit. Is it normal ? Thank you for your help
Hello Pierre, you should open a topic in the forum to discuss about what you think is an accuracy problem of the instruction. Please share your code and pictures there in order to get a perfect picture of what may cause this issue. Thanks.