I want to stop trading activity 1 hour prior to market day trading closing time, and I came across this code in your NT8 DOC, but when I added it is shows me several erros
This is the code I found : https://ninjatrader.com/support/helpGuides/nt8/
private SessionIterator sessionIterator;
protected override void OnStateChange()
{
if (State == State.DataLoaded)
{
//stores the sessions once bars are ready, but before OnBarUpdate is called
sessionIterator = new SessionIterator(Bars);
}
}
protected override void OnBarUpdate()
{
// Only process strategy logic up until three hours prior to the end of the trading day at the exchange
if (DateTime.Now <= sessionIterator.GetTradingDa yEndLocal(Bars.SessionIterator.ActualTradingDayExc hange).AddHours(-3))
{
// Strategy logic here
}
}
Can you please tell me how to do it the right way ?
This is the code snippet I'm using now :
if (DateTime.Now <= sessionIterator.GetTradingDayEndLocal(Bars.Session Iterator.ActualTradingDayExchange).AddHours(-1))
{
TimeUp = true;
}

Comment