This is probably my poor coding causing a problem, but your input is welcome. I've used some of your SamplePnL code and added a line to log the result as an alert level log, and it seems to go into a loop and I get a "Mail queue overflow" event in the log (alert-level log items get emailed to me). Not pretty!
Note this code seemed to work fine yesterday, but upon a daily reboot and reload it entered a loop that required a hard shutdown.
Here is the code snippet;
protected override void OnBarUpdate()
{
if(BarsInProgress != 0)
return;
////Start of Strategy daily loss limit code///
// At the start of a new session
if (Bars.FirstBarOfSession)
{
// Store the strategy's prior cumulated realized profit
priorTradesCumProfit = Performance.AllTrades.TradesPerformance.Currency.CumProfit;
}
/* Prevents further trading if the current session's realized profit exceeds variable StrategyProfitTarget
or if realized losses exceed variable StrategyStopLoss. */
if (Performance.AllTrades.TradesPerformance.Currency.CumProfit - priorTradesCumProfit >= StrategyProfitTarget
|| Performance.AllTrades.TradesPerformance.Currency.CumProfit - priorTradesCumProfit <= (StrategyStopLoss*-1))
{
// Returns out of the OnBarUpdate() method. This prevents any further evaluation of trade logic in the OnBarUpdate() method.
Log(Instrument.FullName + " Strategy halted. Session profit/loss limits exceeded. Check your open positions. ",NinjaTrader.Cbi.LogLevel.Alert); //Log the shutdown
return;
}
////// GO LONG GO LONG GO LONG/////
A seperate minor issue in the same strategy is generated by this code;
{
EnterLong("Long 1a");
EnterLong("Long 1b");
Log(Instrument.FullName + " LONG signal generated with ASK at: " + GetCurrentAsk(),NinjaTrader.Cbi.LogLevel.Information); //For basic TCA
}
Any input or advice is welcome. Thanks.

.
Comment