Close operation and open a new operation.
Forums › ProRealTime English forum › ProOrder support › Close operation and open a new operation.
- This topic has 20 replies, 7 voices, and was last updated 3 years ago by Monochrome.
-
-
04/01/2021 at 6:28 PM #165975
I am in the market with an operation for several days.
I see that these days the conditions have been given several times to re-enter the market.
What I want is that if I am in the market and the conditions to enter are met, the operation is closed and a new operation is opened.
Thanks.
04/01/2021 at 6:53 PM #165982It makes no sense, as the reopening price will be the closing price of the old trade and there are no advantages.
Even overnight fees won’t change.
You can easily do this by exiting and reopening after 30 bars have elapsed:
1234IF MyLongConditions AND LongOnMarket AND ((BarIndex - TradeIndex) >= 30) THENSELL AT MarketBUY AT MarketENDIF04/01/2021 at 7:56 PM #165990or you could try “cumulative orders = true” to add to your position each time conditions are met
04/01/2021 at 8:04 PM #16599104/02/2021 at 12:56 PM #166043It makes no sense, as the reopening price will be the closing price of the old trade and there are no advantages.
Even overnight fees won’t change.
You can easily do this by exiting and reopening after 30 bars have elapsed:
1234IF MyLongConditions AND LongOnMarket AND ((BarIndex – TradeIndex) >= 30) THENSELL AT MarketBUY AT MarketENDIFWhen you code “sell at market” and “buy at market” in the same bar, ProRealtime won’t do anything. At least not in a backtest, and I think neither in reality with IG. It will just leave the old position open, because in effect, nothing changes. No orders will be executed.
I think what was implied in the original question is : How do you get a new entry price for an old position on whose basis exits (trailing stops, target profits, and so on) are being calculated. Instead of taking “positionprice” for that purpose, you can remember the closing price of a certain bar as “newpositionprice” and do all exit calculations with this one from then on.
04/02/2021 at 3:07 PM #16605304/02/2021 at 4:13 PM #16605504/02/2021 at 4:54 PM #166062What is the point of closing a position and immediately opening a new one? You will just have to pay the spread to the broker each time just to be in exactly the same position as you were (except now holding at a worse price than you were before). This is why if a buy order and a sell order are sent to the broker at the same time by a strategy they just cancel each other out.
04/02/2021 at 6:54 PM #166064Maybe he wishes to lock in profit and start a new trade with a fresh stoploss.
04/02/2021 at 7:28 PM #16606504/02/2021 at 7:46 PM #166068Close and reentry in same direction in the same bar can happen with cumulated orders and maintaining 1 position-size I believe.
Some code will run into a problem, because i.e. a trailingstop won’t reset unless it’s modified for this specific issue. I use it with these adjustments for backtesting only.
04/02/2021 at 8:09 PM #16607104/02/2021 at 9:35 PM #166078When you close a position and re-open it again in the same bar, nothing happens.
Yes – each order cancels out the other.
04/02/2021 at 9:37 PM #166079Maybe he wishes to lock in profit and start a new trade with a fresh stoploss.
Then just move the stop loss – it achieves exactly the same thing but without paying the spread.
04/03/2021 at 9:14 PM #166131‘set stoploss’ can’t be moved right? You’d have to code in a separate exit which only activates on bar close.
I mean I personally wouldn’t do that but I can see reasons for it
-
AuthorPosts
Find exclusive trading pro-tools on