I need to set some "pausing", blocking a strategy to generate any other for x minutes since last closing order (in case it was a loss), to improve my strategies performance.
So I need to store -> time_from_last_loss = toTime (when this event occurs) to check it against toTime (onBarUpdate()) to block or allow new trades.
But I am in trouble.
For instance, Does anyone know how can I store time_from_last_loss in case of a stop loss order?
Or maybe, there is some functionality on NT libraries.
Site Administrator Swing Trader Data Scientist & DevOps
Manta, Ecuador
Experience: Advanced
Platform: My own custom solution
Trading: Emini Futures
Posts: 49,753 since Jun 2009
Thanks: 32,299 given,
97,501
received
Look in the help guide for OnExecution()
You can easily access the DateTime for the last execution, and then determine if the execution was a winner or loser. If loser you can update a variable that stores the DateTime lastloser info.
As for new trades, you can just use the lastloser.AddSeconds() function (or similar) to test and see if sufficient time has passed before entering a new trade.
BTW, if you are using time based charts, there is also a built-in BarsSinceExit() function in NinjaTrader. But if using non-time based charts then it will only give you a bar number. You could also then pull the Time of that bar number.