Hi Wealthlab team,
I am in the process of trying to convert from WL 6 to WL 8 but I am really struggling.
I have done all of my work to-date WL6 (i.e. for 10 years) using the WL6 editor and would like to be able to convert my WL6 codes to WL8 so that I can continue to use Wealthlab.
I have read through these posts:
https://www.wealth-lab.com/Discussion/Quick-WL6-9-to-WL7-Translation-Guide-5548
https://www.wealth-lab.com/blog/anatomy-of-a-wl7-strategy
I cannot make any sense of either of the above documents.
And watched these videos
https://www.youtube.com/playlist?list=PLcYQ6caO-N5yiSXsCqbDoAHDIdxTgFOEQ
The above videos are only useful if you can get a code to work - but I have not been able to find any WL8 codes that work.
As a starting point it would be useful if Wealthlab could publish a WL8 code that works (i.e. text that can be copied into the WL editor) that includes notation (i.e. //comments in the code) explaining what each part of the code is trying to achieve.
For example, if you could convert the example WL6 code below to WL8 I would really appreciate it. I should then be able to convert my existing WL6 strategies once I understand how the basic components of the WL8 code works.
It would be terrific if you could outline with notation (i.e. //comments) the following:
• where the buy loop starts and ends
• where the sell loop starts and ends
• how to create position priorities
• how to define indicators
• how to plot chart components and indicators
<EXAMPLE WL6 code>
I am in the process of trying to convert from WL 6 to WL 8 but I am really struggling.
I have done all of my work to-date WL6 (i.e. for 10 years) using the WL6 editor and would like to be able to convert my WL6 codes to WL8 so that I can continue to use Wealthlab.
I have read through these posts:
https://www.wealth-lab.com/Discussion/Quick-WL6-9-to-WL7-Translation-Guide-5548
https://www.wealth-lab.com/blog/anatomy-of-a-wl7-strategy
I cannot make any sense of either of the above documents.
And watched these videos
https://www.youtube.com/playlist?list=PLcYQ6caO-N5yiSXsCqbDoAHDIdxTgFOEQ
The above videos are only useful if you can get a code to work - but I have not been able to find any WL8 codes that work.
As a starting point it would be useful if Wealthlab could publish a WL8 code that works (i.e. text that can be copied into the WL editor) that includes notation (i.e. //comments in the code) explaining what each part of the code is trying to achieve.
For example, if you could convert the example WL6 code below to WL8 I would really appreciate it. I should then be able to convert my existing WL6 strategies once I understand how the basic components of the WL8 code works.
It would be terrific if you could outline with notation (i.e. //comments) the following:
• where the buy loop starts and ends
• where the sell loop starts and ends
• how to create position priorities
• how to define indicators
• how to plot chart components and indicators
<EXAMPLE WL6 code>
CODE:
using System; using System.Collections.Generic; using System.Text; using System.Drawing; using WealthLab; using WealthLab.Indicators; namespace WealthLab.Strategies { public class EMA8Code : WealthScript { protected override void Execute() { // Fitting paramters int START = 3; //Price EMA definitions //Create an EMA8 DataSeries EMA8 = EMAModern.Series(Close, 8); //PLOTS //Price Pane PlotSeries(PricePane, EMA8, Color.Blue, LineStyle.Dashed, 1); for (int bar = START; bar < Bars.Count; bar++) { if (ActivePositions.Count > 0) { //Sell LOOP { if (Close[bar] < EMA8[bar]) { SellAtMarket(bar + 1, Position.AllPositions, "Sell"); } } //Sell LOOP } else { //Buy loop { if (ActivePositions.Count < 1) { {//Buy if close is above EMA8 if (Close[bar] > EMA8[bar]) {BuyAtMarket(bar + 1, "Buy"); } } } } //Buy loop } } } } }
Rename
If there is no way of WL8 to work, can Wealthlab please retain WL6 for existing users (i.e. I have spent 10 years using WL6 and it works well).
From my perspective, a program that actually works (i.e. WL6) is far more powerful than a program that I cannot get to work at all (i.e. WL8 has no functionality at all for me).
From my perspective, a program that actually works (i.e. WL6) is far more powerful than a program that I cannot get to work at all (i.e. WL8 has no functionality at all for me).
Your WL6 code is carrying multiple positions for a single stock symbol. I'm not sure how to code that, but it is somewhat more complicated. I would suggest getting the simple case to work first before trying to manage multiple positions for the same stock symbol. The solution below is for a single position per stock symbol, which I coded in 30 minutes. Of course you can manage/simulate multiple symbols at the same time.
CODE:
using WealthLab.Backtest; using WealthLab.Core; using WealthLab.Indicators; namespace WealthScript2 { public class EMA8Code : UserStrategyBase { IndicatorBase ema8; public override void Initialize(BarHistory bars) { ema8 = EMA.Series(bars.Close, 8); PlotIndicator(ema8,WLColor.Blue,PlotStyle.DashedLine); StartIndex = ema8.FirstValidIndex; // was StartIndex = 3; } public override void Execute(BarHistory bars, int idx) { if (HasOpenPosition(bars, PositionType.Long)) { //sell conditions below if (bars.Close[idx] < ema8[idx]) PlaceTrade(bars, TransactionType.Sell, OrderType.Market, default, "Sell"); } else { //buy conditions below if (bars.Close[idx] > ema8[idx]) PlaceTrade(bars, TransactionType.Buy, OrderType.Market, default, "Buy"); } } } }
Thank you,
Greatly appreciated.
That will give me something to get started on.
Kind regards,
Jim
Greatly appreciated.
That will give me something to get started on.
Kind regards,
Jim
There's no better visual illustration (if I say so myself, so I will) of an example of going from WL6 to WL8, although the image was created for WL7:
https://www.wealth-lab.com/Discussion/Quick-WL6-9-to-WL7-Translation-Guide-5548
Also, this blog:
https://www.wealth-lab.com/blog/anatomy-of-a-wl7-strategy
We sent you these links by email last week.
Also, for many examples, see the Sample Strategies folder. Or, create a block strategy and click the button to "Open as a C# Coded Strategy". The resulting code is a little verbose, but correct.
Another resource is this pdf to find equivalent statements in WealthScript 7, which usually is the same in WL8. Just cross check using the WL8 QuickRef:
https://www2.wealth-lab.com/WL5WIKI/GetFile.aspx?File=%2fKB%2fQuickRef.pdf
https://www.wealth-lab.com/Discussion/Quick-WL6-9-to-WL7-Translation-Guide-5548
Also, this blog:
https://www.wealth-lab.com/blog/anatomy-of-a-wl7-strategy
We sent you these links by email last week.
Also, for many examples, see the Sample Strategies folder. Or, create a block strategy and click the button to "Open as a C# Coded Strategy". The resulting code is a little verbose, but correct.
Another resource is this pdf to find equivalent statements in WealthScript 7, which usually is the same in WL8. Just cross check using the WL8 QuickRef:
https://www2.wealth-lab.com/WL5WIKI/GetFile.aspx?File=%2fKB%2fQuickRef.pdf
Hi Superticketer,
If I wanted to make an indicator in WL6 that is say 10% less than the EMA8 I would write
DataSeries EMA8 = EMAModern.Series(Close, 8);
Then I would define the indicator as follows:
DataSeries EMA8minus10 = EMA8 - EMA8 * 0.1;
In WL8 I can define the indicator as follows:
But when I try to create the ema8minus10 indicator as follows it does not work:
Is there something simple that I am missing?
If I wanted to make an indicator in WL6 that is say 10% less than the EMA8 I would write
DataSeries EMA8 = EMAModern.Series(Close, 8);
Then I would define the indicator as follows:
DataSeries EMA8minus10 = EMA8 - EMA8 * 0.1;
In WL8 I can define the indicator as follows:
CODE:
IndicatorBase ema8; IndicatorBase ema8minus10; ema8 = EMA.Series(bars.Close, 8);
But when I try to create the ema8minus10 indicator as follows it does not work:
CODE:
ema8minus10 = EMA8 - EMA8 * 0.1;
Is there something simple that I am missing?
Hi Cone,
I had read through all of the docs on WL7 that were emailed through but I could not make any sense of it - that is why I posted on this forum. I still cannot make sense of any of those documents.
The code structure that Superticker sent through seems to make sense, but I am still going to need to work through a number differences between WL6 and WL8 one at a time. I have a feeling that this is still going to take some time.
Kind regards,
Jim
I had read through all of the docs on WL7 that were emailed through but I could not make any sense of it - that is why I posted on this forum. I still cannot make sense of any of those documents.
The code structure that Superticker sent through seems to make sense, but I am still going to need to work through a number differences between WL6 and WL8 one at a time. I have a feeling that this is still going to take some time.
Kind regards,
Jim
QUOTE:IndicatorBase (Indicators) are derived from TimeSeries. So an Indicator is a TimeSeries, but the reverse is not [always] true - like when you make TimeSeries calculations like that.
Is there something simple that I am missing?
CODE:And then use PlotTimeSeries* functions to plot TimeSeries.
IS: IndicatorBase ema8minus10; SHOULD BE: IS: TimeSeries ema8minus10;
Thank you Cone - greatly appreciated
QUOTE:
If I wanted to make an indicator in WL6 that is say 10% less than the EMA8 ...
DataSeries EMA8minus10 = EMA8 - EMA8 * 0.1;
So a unary operator such as "-" or "*" operates on a TimeSeries, not an IndicatorBase. So you need to write it as follows:
CODE:
public class EMA8Code : UserStrategyBase { IndicatorBase ema8; TimeSeries ema8minus10; public override void Initialize(BarHistory bars) { ema8 = EMA.Series(bars.Close, 8); //ema8minus10 = ema8 - ema8*0.1; //ema8minus10 = (TimeSeries)ema8*0.9; // The C# complier implicitly performs the cast to TimeSeries ema8minus10 = ema8*0.9; PlotIndicator(ema8,WLColor.Blue); PlotTimeSeries(ema8minus10, ema8minus10.Description, "EMA pane", WLColor.Blue, PlotStyle.DashedLine); StartIndex = ema8.FirstValidIndex; }
An indicator will always return an Indicator type. But a calculation (with a unary operator) will always return a TimeSeries type, so you need to code accordingly.
As an object-oriented programmer (OOP), you want to code at the highest datatype level possible (use IndicatorBase over TimeSeries) because the class types take advantage of the higher level types to simplify your code (e.g. employ PlotIndicator over PlotTimeSeries). Read the chapter of your C# textbook about encapsulation and information hiding when designing class types.
You are not required to use the ema8minus10.Description description WL8 supplies. You can replace that with any string "my description" that's more descriptive to you. PlotIndicator will supply its own description, but you can substitute (reassign it) to something else as well. Happy OOPs coding to you.
Your Response
Post
Edit Post
Login is required