I'm using replay mode to test strategies and need to exit a position between bars, e.g. exit if unrealized gain/loss >= $ or time >= 4:14pm.
I thought it would be easy, but I've tried these methods so far with no success:
- setting CalculateOnBarClose false
- putting my conditions and exit code in the OnMarketData event.
- I've also tried to at least satisfy the latter condition by setting the strategy 'Exit On Close' parameters, expecting them to exit at 4:14, but that never occurred either.
And OnMarketData behaved completely differently than I expected, e.g. when printing a Time[0], it's out of sync (falls way behind) the actual replay time?
So I'm not sure what to try next, but I need to find some way to do this.
I suspect (hope) I'm just missing something simple (I'd imagine this would be a common requirement).
Any advice would be greatly appreciated.
Comment