always execute stop/limit order at next bar

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #159301 quote
    Paul
    Participant
    Master

    Hi, I’am stuck on something. It’s not intended for live, but for backtest purpose.

    defparam cumulative orders=true.

    I’ve a buy signal and a long position will be sold at the market next bar open.

    But at the same time I need to buy at that bar where that long position was closed.

    How do I write the condition with stop/limit so the order will always be executed, regardless how the next candle (after the signal) looks or gaps.

    So far I’ve this and works in part. In pic an example where it doesn’t work.

    if longonmarket and condbuy and (reentry=1 or reentry=2) then
    sell positionsize contract at market
    newprice=close
    if newprice=newprice+0.01 then
    buy positionsize contract at newprice stop
    else
    buy positionsize contract at newprice limit
    endif
    set stop %loss sll
    set target %profit ptl
    endif
    Screenshot-2021-01-24-at-23.32.35.jpg Screenshot-2021-01-24-at-23.32.35.jpg
    #159305 quote
    robertogozzi
    Moderator
    Master

    You can’t, unless you use the MTF support with a default 1-minute TF and BUY 1 minute after the previous position is closed.

    This is because ProOrder needs one bar before knowing the updated OnMarket status.

    Paul thanked this post
    #159309 quote
    Paul
    Participant
    Master

    Thnx roberto. that’s a shame. I don’t want to use MTF because that defeats the purpose.

    But I’ve changed it a little. Removed the 0.01, the condition is always true.

    It works often now. I will update progress on the concept in the vectorial dax topic.

    Nicolas thanked this post
    Screenshot-2021-01-25-at-03.02.46.jpg Screenshot-2021-01-25-at-03.02.46.jpg Screenshot-2021-01-25-at-03.10.43.jpg Screenshot-2021-01-25-at-03.10.43.jpg
    #159436 quote
    Paul
    Participant
    Master

    Here’s the file i’ve been working on.

    step1 & step2 use with cumulative orders set to true, optimising one or both steps to find good values to be used in step3.

    step3 set cumulative orders to false for live trading

    this is about seeing the trades that the normal backtest might not see because it is already on the market. Now those trades/signals have more meaning when optimising and always have impact. Best is to have all 3 equity-curves look similar (regardless the extra spread/trades with step1/2)

    Maybe it will be useful and can be improved or maybe it’s not useful at all. I’am not sure yet.

    example; dow 5m 100k optimised with a dpo setup for long

    nonetheless thanked this post
    DJ-5m-DPO.itf
    #159532 quote
    Paul
    Participant
    Master

    @nonetheless

    After having founded good & robust entry settings, added Roberto’s ts  (disabled pt) and you have on (step3) a nice equity-curve on 200k. Maybe I shouldn’t have posted it here in this topic. But pretty good for an entry parameter with only 1 (best) value which is 100! Should be robust on vrt too I hope.

    Screenshot-2021-01-26-at-19.19.56.jpg Screenshot-2021-01-26-at-19.19.56.jpg Screenshot-2021-01-26-at-19.33.16.jpg Screenshot-2021-01-26-at-19.33.16.jpg
    #159596 quote
    nonetheless
    Participant
    Master

    This is a really cool idea – comes close to incorporating VRT at the optimization level by using more of the possible entries. I’ll have to make some time to play around with it, thanks for sharing!

    Paul thanked this post
Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.

always execute stop/limit order at next bar


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
Paul @micky75d Participant
Summary

This topic contains 5 replies,
has 3 voices, and was last updated by nonetheless
5 years ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 01/24/2021
Status: Active
Attachments: 6 files
Logo Logo
Loading...