You can’t set multiple stops automatically.
You will have to deal with each one yourself. Besides, you can’t use pending STOP/LIMIT orders to partially close positions.
You will have to check when each candle closes if a price level has been hit, then exit AT MARKET:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
|
MyLongConditions = Not OnMarket AND Close CROSSES OVER average[100,0](close) IF MyLongConditions THEN BUY 3 Contracts at Market //assu,e the entry price is 1000 Stop1 = close - 350*PipSize Stop2 = close - 250*PipSize Stop3 = close - 150*PipSize Flag = 0 SET TARGET PRICE close + 900*PipSize ENDIF IF close <= Stop1 THEN //close all positions at this level SELL AT MARKET ELSIF close <= Stop2 AND OnMarket AND Flag = 0 THEN //close 1 position SELL 1 Contract AT MARKET Flag = 1 ELSIF close <= Stop3 AND OnMarket AND Flag = 1 THEN //close 1 position SELL 1 Contract AT MARKET Flag = 2 ENDIF graphonprice TradePrice graphonprice Stop1 coloured("Gold") graphonprice Stop2 coloured("Fuchsia") graphonprice Stop3 coloured("Red") |
Tested on DAX, 1-hour TF.
1 user thanked author for this post.