MultiCharts sqx engine - Inconsistent ExitAfter X Bars

The number of bars spent in trade is inconsistent when ExitAfter X Bars is the exit condition, varying by 1 bar. Seems like a 1-off type of error.

Attached you can find:
1. Snapshot with trading for full data. Highlighted 1 example with 14h in trade. Below it is another with 15h in trade.
2. Strategy SQX file to reproduce error. You should apply the strategy to the 1h timeframe.
3. Data to reproduce error (just 41 days, unlike the full data for which the snapshot was produced, but it's enough to replicate the bug).


Attachments
inconsistent_exit_after_x_bars.sqx
(86.78 KiB)
inconsistent_exit_after_x_bars.jpg
(967.98 KiB)
matic_bin_short.csv
(3.81 MiB)
  • Votes +3
  • Project StrategyQuant X
  • Type Bug
  • Status Fixed
  • Priority Normal

History

AS
#1

andreis

20.11.2022 20:20

Task created

JB
#2

0xjoeblack@proton.me

20.11.2022 20:23
Voted for this task.
E
#3

Emmanuel

21.11.2022 02:38
Voted for this task.
TT
#4

Tamas

25.11.2022 08:58

Subject changed from Inconsistent ExitAfter X Bars to MultiCharts sqx engine - Inconsistent ExitAfter X Bars

b
#5

binhsir

08.02.2023 14:24
Voted for this task.
g
#6

Lee Guan Chuan

10.02.2023 07:24

Status changed from New to Fixed

Hi andreis,


I have checked this issue. ExitAfterBars means the strategy will exit after n bars. However, there is a problem here.


For example, if the ExitAfterBars is 3 and this is the data we have

2022.12.12 1:00

2022.12.12 2:00

2022.12.12 4:00

2022.12.12 5:00


If the trade entered at 2022.12.12 1:00, it will exit at 2022.12.12 5:00. You can see the data for 2022.12.12 3:00 is missing. 

If we calculate the time taken, it will be 4 hours instead of 3 hours. 


Due to this function is ExitAfterBars, is not ExitAfterHours. I cannot update the function to detect the hours/bar hours instead of bars. This is because, in real life, it could be market closed down for few hours (missing few bars) which we couldn't detect it.


I hope I explained this well. Let me know if you have further question.


Thanks.


Votes: +3

Drop files to upload

or

choose files

Max size: 5MB

Not allowed: exe, msi, application, reg, php, js, htaccess, htpasswd, gitignore

...
Wait please