Cumulate orders and close with barindex-tradeindex

Forums ProRealTime English forum ProOrder support Cumulate orders and close with barindex-tradeindex

Viewing 6 posts - 1 through 6 (of 6 total)
  • #157903

    Hi there,

    just something I’ve noticed, and I’m not sure why it’s happening.

    I have a strategy, and it should exit after 2 full bars on the market. I have this set up as:

    Now, there are two different ways that I could run this strategy. Both with

    I can either run a 1 position max,

    or a 2 position max,

    The thing I’ve noticed, is that if I run the countoflongshares<1, then it exits the position after 2 full bars. This is what is intended.

    If I run it as countoflongshares<2 and if I buy a second position while the first position is still on, then it doesn’t do 2 separate exits but a combined single exit, and it pushes the first exit out, so that the first trade is on the market for 3 full bars, and not 2.

    Please see the attached picture that shows this.

    What I want to know, is this normal/is this to be expected?

    What will the broker (IG) see and do?

    Will it execute as backtested, or will I have two separate exits, and not the single exit that I’m seeing?

    Thanks,

    Finning

     

    1 user thanked author for this post.
    #157910

    TRADEINDEX(1), or simply TRADEINDEX, always refers to the most recent entry, so 2 bars will be computed from THAT barindex.

    Refer to TRADEINDEX(2) for the previous entry and use the partial closure support to exit only the first position entered.

    (not tested)

     

    1 user thanked author for this post.
    #157944

    The correct code is:

     

     

    2 users thanked author for this post.
    #158001

    Hi Roberto,

    Thanks for that!

    will test, but it looks good and makes sense.

    Cheers,

    Finning

    #158010

    Tested, and it works as intended – thanks!

    1 user thanked author for this post.
    #158030

    Roberto correct code above added as Log 269 to here …

    Snippet Link Library

    1 user thanked author for this post.
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