Set a stop loss x% from the average position price.
Note: the % loss is calculated and placed individually for each order with IG or PRT-CFD.
Syntax:
1 |
SET STOP %LOSS x |
Example :
1 2 3 4 5 6 7 8 9 |
myMACD = MACD[12,26,9](close) long = myMACD crosses over 0 IF NOT LongOnMarket AND long THEN BUY 1 CONTRACTS AT MARKET ENDIF //set stop loss at 2% from the average position price SET STOP %LOSS 2 |
Hi Nicolas. How is the %loss calculated, I’m a bit confused here. In the Rem it says 2% but is is coded as 0.1. also it states the average position price. If I buy x contracts at market- isn’t that at next open candle price and what is the average price then? sorry for the newbie questions, but I think it is important to know exactly what I’m risking 🙂
Sorry, it’s a mistake, I have changed the code accordingly to the text.
The average position price is the whole orders open price, if you have currently several ones on market.