- ago
When I backtest a strategy for a portfolio and want to view the results for the individual symbols, all drawing objects (like indicators, annotations, etc.) are only displayed for the first symbol. They then disappear completely for the other symbols.

This is not a problem (everything is fine with backtests for individual values), but it is a bit inconvenient. I always load all available data.

Thanks!
0
406
4 Replies

Reply

Bookmark

Sort
- ago
#1
Interesting. What is the action sequence to reproduce this?
0
- ago
#2
It occurs with compiled strategies. For example I have copied the sample strategy "Peak Trough Anylysis" and only added a parameter for the reversal amount.

CODE:
public class PeakTrougAnalysis : UserStrategyBase { public override string Author => "Unknown"; public override string StrategyName => "PeakTrougAnalysis Analysis"; public override string Description => "PeakTrougAnalysis Analysis"; public override bool IsPrivate => false; public PeakTrougAnalysis() : base() { AddParameter("PeakTroughPct", ParameterType.Double, 3, 0, 100, 0.5); } // create indicators and other objects here, this is executed prior to the main trading loop public override void Initialize(BarHistory bars) { var peakTroughPct = Parameters[0].AsDouble; CalculatePeakTrougs(bars, peakTroughPct); } // execute the strategy rules here, this is executed once for each bar in the backtest history public override void Execute(BarHistory bars, int idx) { } private void CalculatePeakTrougs(BarHistory bars, double peakTroughPct) { // perform peak/trough analysis PeakTroughCalculator ptc = new(bars, peakTroughPct); for (int n = 1; n < ptc.PeakTroughs.Count; n++) { int x1 = ptc.PeakTroughs[n - 1].PeakTroughIndex; double y1 = ptc.PeakTroughs[n - 1].Value; int x2 = ptc.PeakTroughs[n].PeakTroughIndex; double y2 = ptc.PeakTroughs[n].Value; DrawLine(x1, y1, x2, y2, WLColor.Red, 2, LineStyle.Solid); } // render peak/trough detection delay foreach (PeakTrough pt in ptc.PeakTroughs) { int x1 = pt.PeakTroughIndex; int x2 = pt.DetectedAtIndex; double y = pt.Value; DrawLine(x1, y, x2, y, WLColor.DarkGray, 2, LineStyle.Solid); } } }
0
Glitch8
 ( 10.83% )
- ago
#3
I'm not seeing this, here's a video of what I'm seeing. Are you sure the other symbols were in the portfolio?

https://drive.google.com/file/d/1tyGoLLTNLTlLdOXme5sM3QHIAjB2aeID/view?usp=sharing

I tried this also with a compiled strategy and I still see my indicators and drawing objects.
0
- ago
#4
It seems that it only works for symbols for which positions have been opened. What speaks against this is that the WL included sample strategy (c# coded - without parameter) is also only used for visualization and does not generate positions, but here the peak-trough curve is displayed for all symbols in the backtest.

As I have already mentioned. It's not dramatic. Just strange behavior.
0

Reply

Bookmark

Sort