Need help to code second entry with same stoploss level
Forums › ProRealTime English forum › ProOrder support › Need help to code second entry with same stoploss level
- This topic has 7 replies, 4 voices, and was last updated 4 years ago by
robertogozzi.
-
-
09/24/2021 at 7:31 AM #178264
Good morning
I need help to code an second entry after the first position is “x” points in minus. The sl of the second position must be the same as that of the first position.
For example:
1. position: SL 200
2. position: entry at -150 / sl -50
Could anybody help?
09/24/2021 at 8:32 AM #178266Need help to coding12345678910111213DefParam CUMULATEORDERS = TrueStopDistance = 200If LongOnMarket and TradePrice(1) - Close > 150 ThenBuy at MarketSet Stop pLoss StopDistance - (TradePrice(2) - TradePrice(1))ElsIf ShortOnMarket and Close - TradePrice(1) > 150 ThenSell at MarketSet Stop pLoss StopDistance - (TradePrice(1) - TradePrice(2))End09/24/2021 at 8:34 AM #17826709/24/2021 at 9:17 AM #178276Bear in mind that the stop loss is NOT separate for each position entered. It is calculated on PositionPrice (the average price). So there will only be ONE stop loss. If it’s hit, the first position entered will lose more than 200 pips and the second one will lose less than 200 pips. In the end you will suffer a 200-pip loss, anyway.
09/24/2021 at 10:04 AM #178281Thank you very much.
Thats true. In case of SL, i will catch the first entry with SL 200 and the second entry with SL 50. In total 250 SL
09/24/2021 at 10:48 AM #178286is this correct?
Correct?123456If LongOnMarket and TradePrice(1) - Close > 150 ThenBuy at MarketSet Stop pLoss StopDistance - (TradePrice(2) - TradePrice(1))endif// short omittedAs far as I know,
the buy order is executed at the start of the next candle. So TradePrice is not updated yet.09/24/2021 at 11:31 AM #178290Pls find attached two backtests. Left side is the origin one, right side ist the version with the second entry. But something went wrong. I dont see the second entrys in the orderlist and SL is to high.
09/24/2021 at 11:49 AM #178294Thats true. In case of SL, i will catch the first entry with SL 200 and the second entry with SL 50. In total 250 SL
Not exactly, it’s always 200 pips from POSITIONPRICE (the average price, see also my pic). Example:
- first LONG entry at 15600 – PositionPrice = 15600) (initial SL at 15400) – if hit, the position will lose 200 pips (200 pips per position)
- second LONG entry at 15520 – PositionPrice = 15560,(15600+15520)/2) (updated SL at 15360) – if hit, the 1st position will lose 240 pips, while the 2nd position will lose 160 pips (so it’s 200 pips per position)
-
AuthorPosts
Find exclusive trading pro-tools on