I wish there was a private chat in which I could express my frustration at having to rewrite all my strategies to you.
I am sure you are glad to have me back!
Thank you.
Can you delete this message please.
I am sure you are glad to have me back!
Thank you.
Can you delete this message please.
Rename
As you probably have figured out, there's no need to rewrite your WL7 strategies for WL8 as it has a built-in translator.
WL 6.9 I don't have WL 7
Here's a helpful post (it was a sticky post for over a year) and it's still valid for WL8.
https://www.wealth-lab.com/Discussion/Quick-WL6-9-to-WL7-Translation-Guide-5548
If you do Walk Forward optimizations, look up NewWFOInterval - you'll need to add that method to your strategies too.
There's a building block crossover Sample Strategy, but here's a good one without all the verbosity that demonstrates various common techniques.
https://www.wealth-lab.com/Discussion/Quick-WL6-9-to-WL7-Translation-Guide-5548
If you do Walk Forward optimizations, look up NewWFOInterval - you'll need to add that method to your strategies too.
There's a building block crossover Sample Strategy, but here's a good one without all the verbosity that demonstrates various common techniques.
CODE:
using WealthLab.Backtest; using System; using WealthLab.Core; using WealthLab.Indicators; using System.Drawing; using System.Collections.Generic; namespace WealthScript3 { public class MACrossoverSample : UserStrategyBase { public MACrossoverSample() { AddParameter("Period 1", ParameterType.Int32, 10, 6, 20, 2); // Parameter index 0 AddParameter("Period 2", ParameterType.Int32, 21, 20, 30, 1); // Parameter index 1 } //create indicators and other objects here, this is executed prior to the main trading loop public override void Initialize(BarHistory bars) { _ma1 = SMA.Series(bars.Close, Parameters[0].AsInt); _ma2 = SMA.Series(bars.Close, Parameters[1].AsInt); PlotIndicatorLine(_ma1, WLColor.Gold); PlotIndicatorLine(_ma2, WLColor.Red ); TimeSeries osc = _ma1 - _ma2; StartIndex = 50; PlotTimeSeries(osc, "Oscillator", "OSC", WLColor.Green, PlotStyle.HistogramTwoColor); } //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 if (_ma1.CrossesOver(_ma2, idx)) { PlaceTrade(bars, TransactionType.Buy, OrderType.Market); //paint a light blue background on the signal bar SetBackgroundColorAllPanes(bars, idx, WLColor.FromArgb(40, WLColor.Blue)); } } else { //code your sell conditions here Position p = LastPosition; if (_ma1.CrossesUnder(_ma2, idx)) ClosePosition(p, OrderType.Market); } } public override void NewWFOInterval(BarHistory bars) { _ma1 = SMA.Series(bars.Close, Parameters[0].AsInt); _ma2 = SMA.Series(bars.Close, Parameters[1].AsInt); } SMA _ma1; SMA _ma2; RSI _rsi; } }
Thank you. I will take a look.
So much work to revise it is really disheartening.
So much work to revise it is really disheartening.
It's worth it for the added benefit of the new and modern framework. I'd say 90% of migrating code from 6.9 to WealthLab 8 is cut and paste and moving variable declarations from local to class internal/private. The other 10% is probably fixing parameters in new method signatures.
Once you have a handle on the framework (of course this takes getting used to), it usually just a matter of minutes to migrate a typical script.
Once you have a handle on the framework (of course this takes getting used to), it usually just a matter of minutes to migrate a typical script.
Your Response
Post
Edit Post
Login is required