Two stop orders at high and low.

Forums ProRealTime English forum ProOrder support Two stop orders at high and low.

Tagged: 

Viewing 6 posts - 1 through 6 (of 6 total)
  • #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:

    1. ByuStop order at High of ended candle
    2. 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

    1. all orders should be cancelled at 15:00 GMT (16:00 CET)
    2. all open trades should be closed at 20:00 GMT (21:00 CET)

    That’s all.

    Peter

    #118875

    Your 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.

     

    #118877

    This 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?

    #118913

    Hi 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:

    1. 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
    2. 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

    1. all orders should be cancelled at 15:00 GMT (16:00 CET)
    2. 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

    #118949

    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.

    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.

     

    #118952

    Thanx 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.

Viewing 6 posts - 1 through 6 (of 6 total)

Create your free account now and post your request to benefit from the help of the community
Register or Login