Love NT8. Absolute noob at coding, but I've spent the last 3-4 months doing almost nothing else...just learning how to code by making this strategy in NT8. Its been awesome.
I have a few questions.
I am running a strategy where most of the logic is happening in OnMarketData().
I am currently trying to optimize my results by running market replay (without tick replay checked). I am playing back the same range of historical data each time and am getting different results on each replay, when I only really expected them to vary slightly.
I am running around a month worth of data on each replay. (is this too much to try and run at once?)
I was wondering if I needed to incorporate the 1 tick data series, like which has been recommended for increasing accuracy for strategy analyzer? I assumed that if I am using OnMarketData() and I am running the strategy in market replay that I wouldn't need to do that. Happy to be corrected though.
Secondly, the chart that the strategy is running on crashes when high volatility enters the live market. But the rest of Ninjatrader performs just fine. For instance, I had three charts open: NQ DEC23 was running my strategy, ES DEC23 was running my strategy, and MNQ DEC23 was not running my strategy. NQ and ES charts both froze (100% unresponsive with no recovery, needed to force quit NT8 to close those instruments) and there were no print statements in my Output window (indicating there was no significant execution or logic taking place, as I have print statements for most of my methods), while the MNQ chart was fine and I was able to still trade on it, which leads me to believe that running two strategies that are both using OnMarketData() is murdering something here either in my computer or in Ninjatrader. I have successfully managed to run the strategy during volatility on just the one instrument in the past. Obviously this is a great opportunity to optimize and improve my code, but I had a general question about this behavior. Could this behavior be attributed to a computer's capabilities? Could we expect only the chart to freeze if a computer is struggling to process the data that a strategy is trying to process?
A point to note here, although the strategy is set to OnBarClose and the bars imported are 15m bars, I ended up having the majority of the code running in OnMarketData.I thought this would give me more accurate backtest results, but i think its just giving me a headache.

Here is an example of a portion of the code running in OnMarketData:
protected override void OnMarketData(MarketDataEventArgs e)
{
List<KeyValuePair<DateTime, double>> nqSwingLowsToProcess = new List<KeyValuePair<DateTime, double>>(historicSwingLowsNQ);
foreach (var nqEntry in nqSwingLowsToProcess)
{
if (nqEntry.Value == DivergenceLow)
{
LogOnce("Skipping nqEntry with matching DivergenceLow: " + nqEntry);
continue; // Skip to next iteration
}
if (IsPotentialSwingLow(currentBidNQ, nqEntry.Value, previousBidNQ, detectedNQSwingLow))
{
if (nqEntry.Value > DivergenceLow && DivergenceLowSetForBar)
{
return;
}
else if ((nqEntry.Value < DivergenceLow && DivergenceLowSetForBar) ||
!DivergenceLowSetForBar)
{
{
hasCrossedOverLows = true;
LogOnce("hasCrossedOverLows is " + hasCrossedOverLows + " for NQ Low: " + nqEntry);
AssignNQSwingLow(nqEntry);
DateTime matchingES = FindMatchingESLow(nqEntry.Key);
if (matchingESLowFound)
{
LogOnce("matchingESLowFound is " + matchingESLowFound + " for ES Low: " + matchingES);
AssignESSwingLow(matchingES);
LogOnce("Attempting to tun CheckDivergenceLowLogic at " + CurrentBar);
CheckDivergenceLowLogic(e.Time);
if (DivergenceLowSetForBar)
{
LogOnce("(DivergenceLowSetForBar is " + (DivergenceLowSetForBar + " at " + CurrentBar));
break; // Exit Loop
}
}
else
{
LogOnce("Attempting to run ResetForNoMatchingNQLow at " + CurrentBar);
matchingESLowFound = false;
ResetForNoMatchingESLow(nqEntry.Key);
TimeStampsToRemoveLows();
break;
}
}
}
}
}
//etc. etc. etc.
}
Would having a more powerful computer (Let's say, a new Ryzen 9 with 64gb ram) allow for Ninjatrader to process under these high volatility conditions while I go about optimizing? I realize this is a somewhat generalized question. I'm just unsure how to understand only specific charts crashing, and not the entire software. And I'd love to be able to collect live data from my strategy during trading sessions before going through whatever I am going to go through in order to optimize this strat.

Comment