Two stop orders at high and low.
Forums › ProRealTime English forum › ProOrder support › Two stop orders at high and low.
- This topic has 5 replies, 2 voices, and was last updated 4 years ago by petermarton.
Tagged: position size
-
-
02/06/2020 at 6:44 PM #118866
Thanks a lot Nicolas, perhaps you could help out with the whole problem I have – running simultaneously more open orders at the same time and managing each separately.
I want to run strategy on 4h chart. After end of each 4h candle I want to open 2 orders:
- ByuStop order at High of ended candle
- SellStop order at Low of ended candle
StopLoss will be set in the middle of (previous i.e. ended candle) High and Low, TargetProfit will be 2* StopLoss size
If the TargetProfit is hit, its “twin” order will be cancelled. If StopLoss is hit, still the twin order can end up at Target of StopLoss.
At the end of the week
- all orders should be cancelled at 15:00 GMT (16:00 CET)
- all open trades should be closed at 20:00 GMT (21:00 CET)
That’s all.
Peter
02/06/2020 at 8:21 PM #118875Your question is on a completely different topic so you should have started a new thread in the forums and not just added onto an old one. I have split your new question into a new topic.
If you place a two sell stop orders then if one is filled the other one will not be cancelled until the candle is closed. You would need to use MTF and place the orders in a faster time frame to cancel one if the other is filled. This however has the disadvantage that you have very limited data to back test on.
02/06/2020 at 8:24 PM #118877This has been discussed several times before like here for example.
https://www.prorealcode.com/topic/how-can-i-cancel-a-stop-entry-order-intrabar/
Did you try a search?
02/07/2020 at 9:02 AM #118913Hi Vonasi,
I’m sorry for putting my issue into previous thread.
Yes, I tried this backtest in excel on 1H TF where about 5% of trades ended on TP and SL during the same bar, so I cannot identify what hit first. I think for the purpose of this a 15M TF would be more then enough.
Now, I’m not that much in the logic of this code yet (I miss the explanation of basic logic of this language in the instruction videos), so though coding is no problem for me in general, it take a lot of time for me to find and learn things. That’s why I ask for help. So here it the idea again (edited):
The strategy is aimed at working on 4h chart, but for the purpose of backtesting I want to run this on 15M chart.
After end of each 4h bar i.e. in this case after each 16 15m bars) I want to open 2 orders:- BuyStop order at High of ended 4H bar (=highest[16]? as it will ru normally on 4H TF) – I think we should take Ask price
- SellStop order at Low of ended 4H bar (=lowest[16]?) – I think we should take Bid price
StopLoss will be set in the middle of BuyStop and SellStop, TargetProfit will be 2* StopLoss size
Trade size should be 1% of equity.
If the TargetProfit is hit, its “twin” order will be cancelled. If StopLoss is hit, still the twin order can end up at Target of StopLoss.
At the end of the week
- all orders should be cancelled at 15:00 GMT (16:00 CET)
- all open trades should be closed at 20:00 GMT (21:00 CET)
Assuming we have max 42 4H bars during the week, there will be more open orders at the same time and the program should manage each separately and each order will have different trade size, stops and targets.
That’s all. Thanks for any help.
Peter
02/07/2020 at 3:32 PM #118949Assuming we have max 42 4H bars during the week, there will be more open orders at the same time and the program should manage each separately and each order will have different trade size, stops and targets.
This part of your code is very difficult to code as managing an unknown quantity of open positions individually is not possible. Once we have arrays in PRT code (coming soon on v11) then it will be possible as we can store all the relevant information to manage them. Until then it is a massive coding challenge. One way to get around it would be to run separate strategies all doing the same thing but only allowing a trade to open at a particular 4 hour bar. So you would have a 0400 strategy and an 0800 strategy and a 1200 strategy etc and each only has to manage its own position.
02/07/2020 at 3:56 PM #118952Thanx for the explanation.
I’ll try to do it for 1 candle per week separately. In this case I find it a bit easier to do it in excel if I download historical data a let a macro do it for all candles.
-
AuthorPosts
Find exclusive trading pro-tools on