Problem with duplicate figures for symultaneous trades
Forums › ProRealTime English forum › ProRealTime platform support › Problem with duplicate figures for symultaneous trades
- This topic has 13 replies, 4 voices, and was last updated 1 week ago by BillTarrej.
-
-
12/04/2024 at 2:07 PM #241092
Hello everyone, I have a simple problem and I hope someone here may be able to help me. When I write out a list of simple entry and exit commands PRT’s ‘detailed report’ within its backtest does not like 2 trades being held simultaneously. The overall loss is correct in this example, its just when two trades are on at the same time, you can see it duplicates entry dates and it simply halves the overall realised figure between the simultaneous trades within the closed positions list.
For example the trades listed 2 dec are actually placed at different times, so the realised figures should be different, prt has simply totalled it up and halved it. Another example dated 25.11.24 shows two trades which list different losses as there entrys are different, however again prt backtest lumps them together as they were on at the same time. The other examples are a loss and a win, but im sure you get the idea. It also simply duplicates dates I note even if they were placed on different dates. I hope someone can help.
Heres the code;
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220// Stop loss in pointsSTOPLOSS = 1000// Initialize execution flags for each tradeIF barindex = 0 THENtradeExecuted1 = 0tradeExecuted2 = 0tradeExecuted3 = 0tradeExecuted4 = 0tradeExecuted5 = 0tradeExecuted6 = 0tradeExecuted7 = 0tradeExecuted8 = 0ENDIF// Trade 1: 02.12.24 - 10:00 exit at 03.12.24 - 15:00IF (date = 20241202 AND time >= 100000 AND time < 100100 AND tradeExecuted1 = 0) THENBUY 10 CONTRACT AT MARKETSET STOP LOSS STOPLOSStradeExecuted1 = 1ENDIFIF (ONMARKET AND date = 20241203 AND time >= 150000 AND tradeExecuted1 = 1) THENSELL AT MARKETENDIF// Trade 2: 02.12.24 - 15:00 exit at 03.12.24 - 15:00IF (date = 20241202 AND time >= 150000 AND time < 150100 AND tradeExecuted2 = 0) THENBUY 10 CONTRACT AT MARKETSET STOP LOSS STOPLOSStradeExecuted2 = 1ENDIFIF (ONMARKET AND date = 20241203 AND time >= 150000 AND tradeExecuted2 = 1) THENSELL AT MARKETENDIF// Trade 3: 25.11.24 - 08:30 exit at 26.11.24 - 09:00IF (date = 20241125 AND time >= 083000 AND time < 083100 AND tradeExecuted3 = 0) THENBUY 10 CONTRACT AT MARKETSET STOP LOSS STOPLOSStradeExecuted3 = 1ENDIFIF (ONMARKET AND date = 20241126 AND time >= 090000 AND tradeExecuted3 = 1) THENSELL AT MARKETENDIF// Trade 4: 25.11.24 - 09:30 exit at 26.11.24 - 09:00IF (date = 20241125 AND time >= 093000 AND time < 093100 AND tradeExecuted4 = 0) THENBUY 10 CONTRACT AT MARKETSET STOP LOSS STOPLOSStradeExecuted4 = 1ENDIFIF (ONMARKET AND date = 20241126 AND time >= 090000 AND tradeExecuted4 = 1) THENSELL AT MARKETENDIF// Trade 5: 21.11.24 - 07:00 exit at 21.11.24 - 15:50IF (date = 20241121 AND time >= 070000 AND time < 070100 AND tradeExecuted5 = 0) THENBUY 10 CONTRACT AT MARKETSET STOP LOSS STOPLOSStradeExecuted5 = 1ENDIFIF (ONMARKET AND date = 20241121 AND time >= 155000 AND tradeExecuted5 = 1) THENSELL AT MARKETENDIF// Trade 6: 21.11.24 - 08:10 exit at 21.11.24 - 09:20IF (date = 20241121 AND time >= 081000 AND time < 081100 AND tradeExecuted6 = 0) THENBUY 10 CONTRACT AT MARKETSET STOP LOSS STOPLOSStradeExecuted6 = 1ENDIFIF (ONMARKET AND date = 20241121 AND time >= 092000 AND tradeExecuted6 = 1) THENSELL AT MARKETENDIF// Trade 7: 19.11.24 - 09:40 exit at 19.11.24 - 14:00IF (date = 20241119 AND time >= 094000 AND time < 094100 AND tradeExecuted7 = 0) THENBUY 10 CONTRACT AT MARKETSET STOP LOSS STOPLOSStradeExecuted7 = 1ENDIFIF (ONMARKET AND date = 20241119 AND time >= 140000 AND tradeExecuted7 = 1) THENSELL AT MARKETENDIF// Trade 8: 19.11.24 - 11:30 exit at 20.11.24 - 07:30IF (date = 20241119 AND time >= 113000 AND time < 113100 AND tradeExecuted8 = 0) THENBUY 10 CONTRACT AT MARKETSET STOP LOSS STOPLOSStradeExecuted8 = 1ENDIFIF (ONMARKET AND date = 20241120 AND time >= 073000 AND tradeExecuted8 = 1) THENSELL AT MARKETENDIF12/04/2024 at 5:19 PM #241106Hi there Bill,
This will be the same issue as this thread talks about (or runs into after a couple of posts) : https://www.prorealcode.com/topic/no-or-incorrect-display-of-drawdown-in-v12/
People still report this once in a while, and now you. So this is apparently still not solved.
After reading into that thread, it would be good if you send it as a Technical Report (via Help in the main menu), so that the developers have more data points.Best regards,
Peter2 users thanked author for this post.
12/05/2024 at 11:34 AM #241143Thankyou for replying so promtly Peter that is great and appreciated. Ive looked through it’s quite a long chain, I cant seem to find anything specific on this other than overall annoyance at tech issues with the backtest feature. Ill take it as this is a technical issue that is unresovled at PRT and theres nothing I can do to amend my code? If you can confirm that that would be great. I will take your advice and forward this issue to them. It seems strange that somethign so fundamentel is overlooked by them, is the backtest particularly new or something.
12/06/2024 at 3:56 AM #241168What I suggested myself in that thread, is that you can put an end date/time in the backtest so you’d force the Detailed Report not to do a final recalculation for the current moment (which would incur for the double trades, as I see it). That end date/time can just be from an hour or so ago. For me this works, I hope for you too.
12/06/2024 at 9:46 AM #241176BillTarrej if you close the Detailed Report and open it again … do the figures then show as correct?
12/06/2024 at 7:31 PM #241215Thanks for reply, no unfortunately same effect if I open close and run script again. Lists as duplicate trades, divides final figures of symaltaneuos trades.
12/06/2024 at 7:33 PM #241216Thankyou for the response, I gave this a try same effect. Its not happy with this either.
12/06/2024 at 8:22 PM #241217Check your Orders List also, see attached …
- Image1 Closed Positions List – yellow squiggle looks like duplicates for 19 Nov 24?
- Image2 Orders List – yellow squiggle shows 2 separate buys at different times for 19 Nov 24.
Does above help?
12/07/2024 at 7:10 AM #24122812/07/2024 at 11:09 AM #241233BillTarrej problem is that …
- The Orders List shows 2 entries at 2 different times.
- Closed Positions List shows the above 2 entries both at the same identical entry time (also both trades exit at the same time, so they look like duplicated trades in the Closed Position List)
You can see above in the screenshots I posted as I ran BillTarrej code on my Platform.
12/07/2024 at 11:23 AM #24123412/07/2024 at 12:04 PM #24123512/07/2024 at 12:26 PM #241237“The ‘problem’ is that Bill opens an order while the other order is still active, resulting in cumulative orders. You know how PRT handles this: the purchase prices are averaged, and when this cumulative position is closed, the profits are evenly distributed…
Technically, the report isn’t incorrect, but it differs due to the cumulative positions…
If you want to handle the orders separately, you need to use:
DefParam CumulateOrders = False”1 user thanked author for this post.
12/07/2024 at 8:20 PM #241250On first impressions, this was perfect and listed the trades individually so no cumultative total, however the issue is that it doesnt allow for all symaltaneous orders to go through. Your getting the first one and then it doesnt allow for the second, etc if the first is still open. Thanks a lot for your help so far
-
AuthorPosts
Find exclusive trading pro-tools on