- ago
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:
   public override void Cleanup(BarHistory bars)    {       if (ExecutionMode == StrategyExecutionMode.Strategy)          //Backtester.PlotEquity(bars);          WriteToDebugLog("hello world");    }
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?
0
347
Solved
3 Replies

Reply

Bookmark

Sort
Glitch8
 ( 9.42% )
- ago
#1
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.
0
Best Answer
- ago
#2
QUOTE:
... look at the BacktestData property and if it only contains one item ...

That works! See the code below.
CODE:
   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);    }
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.
0
Glitch8
 ( 9.42% )
- ago
#3
This is the best approach I can think of.
1

Reply

Bookmark

Sort