Login Page - Create Account

Support Board


Date/Time: Fri, 03 May 2024 09:02:56 +0000



[Programming Help] - Backtesting gives different results if study is set to receive mouse/keyboard events

View Count: 508

[2020-05-18 16:06:11]
User497913 - Posts: 6
Dear SC support,

I use bar based backtesting for quick testing of concepts. I understand how orders fill in backtesting. The premise is that the backtesting should give the same result every time it is allowed to complete the run.

My observation is that this is true when the study is set to not receive keyboard or mouse events. However, if either of these events are enabled (by using: sc.ReceiveKeyboardKeyEvents = 1; sc.ReceivePointerEvents = ACS_RECEIVE_POINTER_EVENTS_ALWAYS;), and if the mouse of moved, or a key is pressed (including the escape key that interrupts the backtesting), results can be different.

I have included a chartbook and a simple trading system study with this post. The trading system buys at the first bar of every hour and holds the position for 120 bars (I used 9 tick range bars, symbol is ESH20).

To replicate the issue:
1. Run the bar based backtest to completion to get the golden truth. (FWIW I use 920 bars instead of the default 250, and the backtest takes less than 10 seconds)
2. Then run it again but press ESC to interrupt it, then run it again to completion. Every run will be set to clear trade records.
Repeat step 2 enough times and we will see a different result. On my platform, it usually takes less than 4 times.

Please let me know if I have mistaken something or if you have problems replicating it. Thanks.
attachmentSimpleBacktest.Cht - Attached On 2020-05-18 15:54:10 UTC - Size: 31.79 KB - 197 views
attachmentSimpleBacktest.cpp - Attached On 2020-05-18 15:56:16 UTC - Size: 2.18 KB - 191 views
[2020-05-27 15:18:41]
User497913 - Posts: 6
Bump. May I get an update? Thanks.

To post a message in this thread, you need to log in with your Sierra Chart account:

Login

Login Page - Create Account