- ago
Hello, anyone have an idea what the Wealth Lab 8 equivalent for the "PlotSyntheticSymbol" function on Wealth Lab 6 is?
0
483
Solved
7 Replies

Closed

Bookmark

Sort
Glitch8
 ( 12.35% )
- ago
#1
Use PlotBarHistory or PlotBarHistoryStyle. The first parameter is a BarHistory instance that you can get by calling GetHistory.
0
Best Answer
- ago
#2
A couple of helpful hints for similar potential questions:

1. Look up the V6 QuickRef (final build 6.9.24.1 from the legacy product's homepage at https://wl6.wealth-lab.com), the equivalents for WL7/8 are embedded there.
2. Search this forum for "equivalent".
0
- ago
#3
I'm stuck guys. This is the WL6 code I'm trying to convert to WL8

CODE:
using System; using System.Collections.Generic; using System.Text; using System.Drawing; using WealthLab; using WealthLab.Indicators; namespace WealthLab.Strategies {    public class MyStrategy1 : WealthScript    {       protected override void Execute()       {          {             HideVolume();             DataSeries maFast = SMA.Series(Close, 10) >> 1;             DataSeries maMid = SMA.Series(Close, 20) >> 1;             DataSeries maSlow = SMA.Series(Close, 40) >> 1;             DataSeries maParam = maSlow;             PlotSeries(PricePane, maParam, Color.FromArgb(255, 0, 0, 0), LineStyle.Solid, 2);             DataSeries MSAH = (High - maParam) / maParam * 100;             DataSeries MSAO = (Open - maParam) / maParam * 100;             DataSeries MSAC = (Close - maParam) / maParam * 100;             DataSeries MSAL = (Low - maParam) / maParam * 100;             ChartPane MSA_Chart = CreatePane(100, false, true);             PlotSyntheticSymbol(MSA_Chart, "long-term momentum", MSAO, MSAH, MSAL, MSAC, null, Color.Green, Color.Red);          }       }    } }


Trolling the discussion page, I've gotten to the code below, but getting an error with converting Timeseries to Double

CODE:
using WealthLab.Backtest; using System; using WealthLab.Core; using WealthLab.Data; using WealthLab.Indicators; using System.Collections.Generic; namespace WealthScript3 { 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) {          TimeSeries maParam = SMA.Series(bars.Close, 40)>>1;          TimeSeries MSAH = (bars.High - maParam) / maParam * 100;          TimeSeries MSAO = (bars.Open - maParam) / maParam * 100;          TimeSeries MSAC = (bars.Close - maParam) / maParam * 100;          TimeSeries MSAL = (bars.Low - maParam) / maParam *100;          PlotTimeSeries(maParam, "40 wk SMA", "Price", WLColor.Blue, PlotStyle.Line);          BarHistory prntBars = GetHistory(bars, "");          BarHistory msaBars = new BarHistory(prntBars);          for (int i = 0; i < prntBars.Count; i++)          {             msaBars.Add(prntBars.DateTimes[i],                      (prntBars.Open - maParam) / maParam * 100,                      (prntBars.High - maParam) / maParam * 100,                      (prntBars.Low - maParam) / maParam *100,                      (prntBars.Close - maParam) / maParam * 100, 0);          }          PlotBarHistoryStyle(msaBars, "price", "bars",WLColor.Black, false);          PlotTimeSeriesBands(MSAL, MSAH, "LT Momentum", "LT Momentum", WLColor.Blue,2,50);                  } //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 } }
0
- ago
#4
1.
CODE:
//BarHistory prntBars = GetHistory(bars); BarHistory prntBars = GetHistory(bars,bars.Symbol);

2.
CODE:
//(prntBars.Open - maParam) / maParam * 100, ... (prntBars.Open[i] - maParam[i]) / maParam[i] * 100, ...


However, since you've defined all these series above you can simply refer to them like this:
CODE:
msaBars.Add(prntBars.DateTimes[i], MSAO[i], MSAH[i], MSAL[i], MSAC[i], 0);
0
- ago
#5
Also, you're getting the history of nothing. That will not work. Instead here is the full code with Eugene's changes and also getting the history of QQQ. If you're not interested in the history of QQQ then get rid of prntBars and the call to GetHistory and replace prntBars with bars.

With prntBars...

CODE:
using WealthLab.Backtest; using System; using WealthLab.Core; using WealthLab.Data; using WealthLab.Indicators; using System.Collections.Generic; namespace WealthScript3 {    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)       {          TimeSeries maParam = SMA.Series(bars.Close, 40) >> 1;          TimeSeries MSAH = (bars.High - maParam) / maParam * 100;          TimeSeries MSAO = (bars.Open - maParam) / maParam * 100;          TimeSeries MSAC = (bars.Close - maParam) / maParam * 100;          TimeSeries MSAL = (bars.Low - maParam) / maParam * 100;          PlotTimeSeries(maParam, "40 wk SMA", "Price", WLColor.Blue, PlotStyle.Line);          BarHistory prntBars = GetHistory(bars, "QQQ");          BarHistory msaBars = new BarHistory(prntBars);          for (int i = 0; i < prntBars.Count; i++)          {             msaBars.Add(bars.DateTimes[i], MSAO[i], MSAH[i], MSAL[i], MSAC[i], 0);          }          PlotBarHistoryStyle(msaBars, "price", "bars", WLColor.Black, false);          PlotTimeSeriesBands(MSAL, MSAH, "LT Momentum", "LT Momentum", WLColor.Blue, 2,50);       }       //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    } }


Without prntBars...

CODE:
using WealthLab.Backtest; using System; using WealthLab.Core; using WealthLab.Data; using WealthLab.Indicators; using System.Collections.Generic; namespace WealthScript3 {    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)       {          TimeSeries maParam = SMA.Series(bars.Close, 40) >> 1;          TimeSeries MSAH = (bars.High - maParam) / maParam * 100;          TimeSeries MSAO = (bars.Open - maParam) / maParam * 100;          TimeSeries MSAC = (bars.Close - maParam) / maParam * 100;          TimeSeries MSAL = (bars.Low - maParam) / maParam * 100;          PlotTimeSeries(maParam, "40 wk SMA", "Price", WLColor.Blue, PlotStyle.Line);          BarHistory msaBars = new BarHistory(bars);          for (int i = 0; i < bars.Count; i++)          {             msaBars.Add(bars.DateTimes[i], MSAO[i], MSAH[i], MSAL[i], MSAC[i], 0);          }          // this just repeats your bar graph...          //PlotBarHistoryStyle(msaBars, "price", "bars", WLColor.Black, false);                    PlotTimeSeriesBands(MSAL, MSAH, "LT Momentum", "LT Momentum", WLColor.Blue, 2,50);       }       //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    } }
0
- ago
#6
Thanks a lot guys.
0
- ago
#7
This topic seem to have deviated from "PlotSyntheticSymbol equivalent" to development of a custom indicator. Continuation:

https://www.wealth-lab.com/Discussion/Turn-this-code-into-custom-momentum-indicator-9344
0

Closed

Bookmark

Sort