Cumulate orders and close with barindex-tradeindex
Forums › ProRealTime English forum › ProOrder support › Cumulate orders and close with barindex-tradeindex
- This topic has 5 replies, 3 voices, and was last updated 3 years ago by GraHal.
-
-
01/15/2021 at 6:06 AM #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:
123if barindex-tradeindex=2 thensell at marketendifNow, there are two different ways that I could run this strategy. Both with
1cumulateorders=trueI can either run a 1 position max,
1countoflongshares<1or a 2 position max,
1countoflongshares<2The 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.
01/15/2021 at 7:53 AM #157910TRADEINDEX(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)
1234i = CountOfLongSharesif barindex-tradeindex(i)=2 thensell 1 contracts at marketendif1 user thanked author for this post.
01/15/2021 at 12:52 PM #15794401/15/2021 at 11:30 PM #15800101/15/2021 at 11:43 PM #158010Tested, and it works as intended – thanks!
1 user thanked author for this post.
01/16/2021 at 10:27 AM #158030Roberto correct code above added as Log 269 to here …
1 user thanked author for this post.
-
AuthorPosts
Find exclusive trading pro-tools on