I seem to be running into an issue when trying to exit long positions with an automated strategy. Previously everything was working as expected when working with 5 minute candles, but as soon as I switched over to tick candles, the trade exits appear to be significantly delayed and at odd prices (no where near charted prices).
I enter my positions using EnterLong(<quantity>) and exit using ExitLong(), and enforce that I only enter trades when I am flat, and exit when long (should only be one trade in progress at a time).
After running my strategy in a backtest, as mentioned, the exits appear to be significantly delayed, the prices no where near the charted prices, and have overlapping trades. To debug this, I inserted print statements to print the timestamp of when entering and exiting positions. The printed timestamps are inline with what I expect (no overlapping trades), but are also quite different from the timestamps shown in the Historical Strategy Performance view.
Attached are screenshots of: 1) Chart with misaligned exits, 2) Historical Strategy Performance view listing trades and their overlapping times, and 3) debugging print statements showing different times than Historical Performance view.
Would appreciate any help that may shed light on what may be happening here! Thanks!
Comment