How can the code tell if a strategy is in single-symbol mode or portfolio-backtest mode? Apparently, the IF statement below is "true" for both modes, so that test isn't working for me.
CODE:Alternatively, if there's a way to identify which stock symbol is showing on the Chart, that would also be helpful. Certainly the WL application must know what it's having the GUI display. Right?
public override void Cleanup(BarHistory bars) { if (ExecutionMode == StrategyExecutionMode.Strategy) //Backtester.PlotEquity(bars); WriteToDebugLog("hello world"); }
Rename
The backtesting engine is completely decoupled from the chart so there’s no way of knowing. Also, you can change the charted symbol whenever you do things like double click a position, so I question the value of identifying the charted symbol at the point in time a backtest is run.
You could look at the BacktestData property and if it only contains one item then that tells you something.
You could look at the BacktestData property and if it only contains one item then that tells you something.
QUOTE:
... look at the BacktestData property and if it only contains one item ...
That works! See the code below.
CODE:What I'm trying to do is only ScottPlot the equity curve of the single stock in the Chart and not every stock in the dataset. If you have any other suggestions, please make them.
public override void Cleanup(BarHistory bars) { if (BacktestData.Count == 1 && ExecutionMode == StrategyExecutionMode.Strategy) //avoid multiple symbol runs; single-symbol mode only //Backtester.PlotEquity(bars); WriteToDebugLog(BacktestData.Count); }
This is the best approach I can think of.
Your Response
Post
Edit Post
Login is required