Set a trailing stop x units from average position price.
Syntax:
1 |
SET STOP TRAILING x |
Example :
We are setting here a trailing stop at 10 points 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 10 points from the current average price SET STOP TRAILING 10 |
tradeclose when closeclsoe[1]?
tradeclose is a boolean variable to check if the current Close is superior to the previous one. If it is the case, then we exit the long order.