I am not sure if I am doing a mistake or missing something or if it is the desired behavior. When I run a strategy using StrategyRunner.RunBackTest(), I don't see any child window getting launched in WealthLab and the corresponding chart and other visualizers. This is my code:
CODE:
using WealthLab.Backtest; using System; using WealthLab.Core; using WealthLab.Indicators; using System.Drawing; using System.Collections.Generic; namespace WealthScript1 { public class MyStrategy : UserStrategyBase { //create indicators and other objects here, this is executed prior to the main trading loop public override void Initialize(BarHistory bars) { var symbol = "AAPL"; var strategy = "Test1"; Strategy s = StrategyFactory.FindStrategy(strategy); if (s == null) { WriteToDebugLog("strategy could not be found. Strategy = '" + strategy + "'"); //throw new ArgumentException("Strategy not found: RSI2"); return; } StrategyRunner sr = new StrategyRunner(); sr.Symbols.Add(symbol); sr.BacktestSettings.CommissionType = CommissionTypes.None; StrategyBase sb = s.CreateInstance(); Backtester bt = sr.RunBacktest(sb); WLHost.Instance.AddLogItem("Test2", "Executing my test script", Color.Red); WriteToDebugLog("Log: " + bt.ToString()); } //execute the strategy rules here, this is executed once for each bar in the backtest history public override void Execute(BarHistory bars, int idx) { if (!HasOpenPosition(bars, PositionType.Long)) { //code your buy conditions here } else { //code your sell conditions here } } //declare private variables below } }
Rename
It does not mean to instantiate any Strategy window with visualizers nor a chart. The point is to have code-based access to the strategy backtest object in the strategy code.
Got it!
Is there any other method/class to launch (or use existing one if already open) Strategy Window with the chart and visualizers? If not, can we add this as a feature request?
Is there any other method/class to launch (or use existing one if already open) Strategy Window with the chart and visualizers? If not, can we add this as a feature request?
What the purpose? Is it something you can't do by opening a Workspace?
You can use ScottPlot for doing your own plotting:
https://www.youtube.com/watch?v=js81fCy_rx4&t=662s
https://www.youtube.com/watch?v=js81fCy_rx4&t=662s
Yeah, ChartComponent will help, but it will be just easier to launch a chart with specific WealthLab script. My current use case is that when I click on a symbol, I want to see four charts (with their own WealthLab scripts) updated:
1. stock daily
2. stock weekly
3. stock's industry group daily
4. stock's industry group weekly
I can have a "driver" script which can run the scripts for all the above 4 charts if we have the StrategyRunner.RunBackTest() show the Window with the chart and visualizers.
1. stock daily
2. stock weekly
3. stock's industry group daily
4. stock's industry group weekly
I can have a "driver" script which can run the scripts for all the above 4 charts if we have the StrategyRunner.RunBackTest() show the Window with the chart and visualizers.
I'm sorry but this is out of scope for the StrategyRunner. It's not meant to interface with the WL7 GUI at all.
I get it that this was not in the original scope of StrategyRunner.
Can we take it as a feature request?
I think you already have all the individual pieces, it will just require plumbing them.
Can we take it as a feature request?
I think you already have all the individual pieces, it will just require plumbing them.
I don’t feel this is an appropriate task for the StrategyRunner. It operates at a lower logical level, and doesn’t even have any concept of the WL7 UI.
QUOTE:
Yeah, ChartComponent will help, but it will be just easier to launch a chart with specific WealthLab script.
As @Cone already suggested, and I believe it's to the point, you can simply open a Workspace. It hardly makes sense to build an awkward programmatic solution for what can already be reached by pressing a button.
@Glitch,
How about having a new method in IHost class - IHost.RunScript(scriptName, symbolName, timeFrame) ?
How about having a new method in IHost class - IHost.RunScript(scriptName, symbolName, timeFrame) ?
The IHost class is at an even lower level, it doesn't have any concept of the WL7 UI.
Your Response
Post
Edit Post
Login is required