What I found was related to the "SystemPerformance.AllTrades" and associated "Trades". When a strategy is added & started on a Chart, there are not problems, but if you add & start a strategy on the strategy tab of the central control, all the Trades (in the StrategyBase iteration) are lost and not updated. The strategy added to the chart works fine if you disable and enable on the strategy tab, this doesn't break the "Trades".
I have enclosed a sample strategy. It includes the following block of code:
[COLOR=#0000ff]protected[/COLOR] [COLOR=#0000ff]override[/COLOR] [COLOR=#0000ff]void[/COLOR] [COLOR=#080808]OnBarUpdate[/COLOR]() { [COLOR=#0000ff]int[/COLOR] [COLOR=#080808]modeselect[/COLOR]=([COLOR=#080808]CurrentBar[/COLOR]/[COLOR=#ff8c00]10[/COLOR])%[COLOR=#ff8c00]2[/COLOR]; [COLOR=#0000ff]if[/COLOR] (([COLOR=#080808]Position[/COLOR].[COLOR=#080808]MarketPosition[/COLOR]!=[COLOR=#080808]MarketPosition[/COLOR].[COLOR=#080808]Long[/COLOR]) && ([COLOR=#080808]modeselect[/COLOR]==[COLOR=#ff8c00]0[/COLOR])) [COLOR=#080808]EnterLong[/COLOR](); [COLOR=#0000ff]if[/COLOR] (([COLOR=#080808]Position[/COLOR].[COLOR=#080808]MarketPosition[/COLOR]!=[COLOR=#080808]MarketPosition[/COLOR].[COLOR=#080808]Short[/COLOR]) && ([COLOR=#080808]modeselect[/COLOR]==[COLOR=#ff8c00]1[/COLOR])) [COLOR=#080808]EnterLong[/COLOR](); [COLOR=#080808]NinjaTrader[/COLOR].[COLOR=#080808]Code[/COLOR].[COLOR=#080808]Output[/COLOR].[COLOR=#080808]Process[/COLOR]([COLOR=#080808]CurrentBar[/COLOR]+[COLOR=#b22222]" OnBarUpdate(): Trades="[/COLOR]+[COLOR=#080808]SystemPerformance[/COLOR].[COLOR=#080808]AllTrades[/COLOR].[COLOR=#080808]Count[/COLOR]+[COLOR=#b22222]" vs TradeCount="[/COLOR]+ +[COLOR=#080808]SystemPerformance[/COLOR].[COLOR=#080808]AllTrades[/COLOR].[COLOR=#080808]TradesCount[/COLOR]+[COLOR=#b22222]" Name="[/COLOR]+[COLOR=#080808]Name[/COLOR]+[COLOR=#b22222]" strategyID="[/COLOR]+[COLOR=#080808]Id[/COLOR],[COLOR=#080808]PrintTo[/COLOR].[COLOR=#080808]OutputTab1[/COLOR]); [COLOR=#0000ff]foreach[/COLOR] ([COLOR=#080808]StrategyBase[/COLOR] [COLOR=#080808]sb[/COLOR] [COLOR=#0000ff]in[/COLOR] [COLOR=#080808]StrategyBase[/COLOR].[COLOR=#080808]Strategies[/COLOR]) { [COLOR=#0000ff]if[/COLOR] ([COLOR=#080808]sb[/COLOR]!=[COLOR=#0000ff]null[/COLOR]) { [COLOR=#080808]NinjaTrader[/COLOR].[COLOR=#080808]Code[/COLOR].[COLOR=#080808]Output[/COLOR].[COLOR=#080808]Process[/COLOR]([COLOR=#080808]CurrentBar[/COLOR]+[COLOR=#b22222]" OnBarUpdate(StrategyBase Method): Trades="[/COLOR]+[COLOR=#080808]sb[/COLOR].[COLOR=#080808]SystemPerformance[/COLOR].[COLOR=#080808]AllTrades[/COLOR].[COLOR=#080808]Count[/COLOR]+[COLOR=#b22222]" vs TradeCount="[/COLOR]+ +[COLOR=#080808]sb[/COLOR].[COLOR=#080808]SystemPerformance[/COLOR].[COLOR=#080808]AllTrades[/COLOR].[COLOR=#080808]TradesCount[/COLOR]+[COLOR=#b22222]" sb.Name="[/COLOR]+[COLOR=#080808]sb[/COLOR].[COLOR=#080808]Name[/COLOR]+[COLOR=#b22222]" sb.strategyID="[/COLOR]+[COLOR=#080808]sb[/COLOR].[COLOR=#080808]Id[/COLOR],[COLOR=#080808]PrintTo[/COLOR].[COLOR=#080808]OutputTab2[/COLOR]); } } }
Tab1:
8501 OnBarUpdate(): Trades=2 vs TradeCount=2 Name=TestStrategyBaseAccess strategyID=47593721
8502 OnBarUpdate(): Trades=2 vs TradeCount=2 Name=TestStrategyBaseAccess strategyID=47593721
8503 OnBarUpdate(): Trades=2 vs TradeCount=2 Name=TestStrategyBaseAccess strategyID=47593721
8504 OnBarUpdate(): Trades=2 vs TradeCount=2 Name=TestStrategyBaseAccess strategyID=47593721
And Tab2:
8500 OnBarUpdate(StrategyBase Method): Trades=2 vs TradeCount=2 sb.Name=TestStrategyBaseAccess sb.strategyID=47593721
8501 OnBarUpdate(StrategyBase Method): Trades=0 vs TradeCount=4 sb.Name=TestStrategyBaseAccess sb.strategyID=47593720
8501 OnBarUpdate(StrategyBase Method): Trades=2 vs TradeCount=2 sb.Name=TestStrategyBaseAccess sb.strategyID=47593721
8502 OnBarUpdate(StrategyBase Method): Trades=0 vs TradeCount=4 sb.Name=TestStrategyBaseAccess sb.strategyID=47593720
8502 OnBarUpdate(StrategyBase Method): Trades=2 vs TradeCount=2 sb.Name=TestStrategyBaseAccess sb.strategyID=47593721
8503 OnBarUpdate(StrategyBase Method): Trades=0 vs TradeCount=4 sb.Name=TestStrategyBaseAccess sb.strategyID=47593720
8503 OnBarUpdate(StrategyBase Method): Trades=2 vs TradeCount=2 sb.Name=TestStrategyBaseAccess sb.strategyID=47593721
8504 OnBarUpdate(StrategyBase Method): Trades=0 vs TradeCount=4 sb.Name=TestStrategyBaseAccess sb.strategyID=47593720
8504 OnBarUpdate(StrategyBase Method): Trades=2 vs TradeCount=2 sb.Name=TestStrategyBaseAccess sb.strategyID=47593721
Comment