- ago
I'm currently trying to create my own indicator, but I just can't get it to work...can someone here write me the code? The indicator should be very optimizable like you can be stored and can be used here in a building block strategy.

Here is my code so far:

CODE:
using WealthLab.Backtest; using System; using WealthLab.Core; using WealthLab.Data; using WealthLab.Indicators; using System.Collections.Generic; namespace WealthScript1 {    public class MyStrategy : UserStrategyBase    {       public MyStrategy() : base()       {          AddParameter("Einstieg_kurz_SMA", ParameterType.Int32, 1, 1, 10, 1);          AddParameter("Einstieg_lang_SMA", ParameterType.Int32, 260, 30, 600, 10);                           }       public override void Initialize(BarHistory bars)       {          indicator1 = new SMA(bars.Close, Parameters[0].AsInt);          PlotIndicator(indicator1, new WLColor(0, 0, 0));          _startIndexList.Add(indicator1);          indicator2 = new SMA(bars.Close, Parameters[1].AsInt);          PlotIndicator(indicator2, new WLColor(0, 0, 255));                              My Indicator= indicator1/indicator2


-----------------------------------------------------------------------------

P.S. Why is it not possible to copy an error message in this Indicator Builder?
0
543
Solved
14 Replies

Closed

Bookmark

Sort
Cone8
 ( 4.92% )
- ago
#1
1. You're not using the Indicator Builder
2. If you're successful creating a New [Custom] Indicator, you need to run WealthLab in Administrator mode to work with it.
3. Assuming you're not really trying to create a formalized custom Indicator, there are 3 obvious coding errors with the last statement.
a. Variable names like "My Indicator" need to be declared with a 'type'
b. a variable name cannot contain spaces, and,
c. statements end with a ;

CODE:
TimeSeries MyIndicator = indicator1 / indicator2; PlotTimeSeriesLine(MyIndicator, "MyIndicator", "MyIndPane");


If you're going to give C# Code a try, please look at the countless examples available on the forum, in the Sample Strategies folder, or even using the button to convert blocks to a C# Coded Strategy.
0
- ago
#2
many Thanks

CODE:
using WealthLab.Backtest; using System; using WealthLab.Core; using WealthLab.Data; using WealthLab.Indicators; using System.Collections.Generic; namespace WealthScript1 {    public class MyStrategy : UserStrategyBase    {       private SMA indicator1;       private SMA indicator2;       private TimeSeries MyIndicator;       public MyStrategy() : base()       {          AddParameter("Einstieg_kurz_SMA", ParameterType.Int32, 1, 1, 10, 1);          AddParameter("Einstieg_lang_SMA", ParameterType.Int32, 260, 30, 600, 10);       }       public override void Initialize(BarHistory bars)       {          indicator1 = new SMA(bars.Close, Parameters[0].AsInt);          PlotIndicator(indicator1, new WLColor(0, 0, 0));          indicator2 = new SMA(bars.Close, Parameters[1].AsInt);          PlotIndicator(indicator2, new WLColor(0, 0, 255));          MyIndicator = indicator1 / indicator2;          PlotTimeSeriesLine(MyIndicator, "MyIndicator", "MyIndPane");       }    } }


only error message:

Error Error “My strategy does not implement the inherited abstract member “UserStrategyBase.Execute(BarHistory,int)”.
0
- ago
#3
Use the Indicator Builder: Tools menu > New custom (C#) indicator.
0
Glitch8
 ( 11.27% )
- ago
#4
You can’t use the Strategy editor to create a reusable custom indicator.

You can create a strategy specific “indicator” within a Strategy. That’s just a TimeSeries.

If you want to create a reusable custom indicator that will appear in your indicators list you’ll have to use the Indicator Builder tool like Eugene suggests. It’s only available when WL8 is run in Windows Administrator mode.

A custom indicator derives from a class called IndicatorBase, while a strategy derives from UserStratgeyBase.
0
- ago
#5
I was sort of reluctant to adding the RSL indicator given it can be constructed with MathIndOpInd in a blink of an eye. But your desire to optimize the SMA of it by all means apparently has won. Let's get the RSL included it in the next PowerPack build.

https://www.wealth-lab.com/Discussion/RSL-Levy-6984
1
- ago
#6
Phew, that's a lot for my head and I don't really understand anything...Is there a video on how to use the Indicator Builder at all?

I just want to build my own indicator that divides the SMA1 by the SMA 260 as an example. I then want to use this indicator in the transaction weight
0
Glitch8
 ( 11.27% )
- ago
#7
You don’t need to create a custom indicator to do this.

You can use the MathIndOpInd indicator which can divide one indicator for another in your transaction weight.

And, so you really mean SMA1?
0
- ago
#8
SMA 1 is nothing other than the close, the MathIndOpInd indicator is of no use if you want to optimize later

but Eugen already said that he wants to integrate the RSL Indicator into the Powerpack

But I would like to know how to work with the Indicator Builder...again the question if there is a video for this
0
Best Answer
Glitch8
 ( 11.27% )
- ago
#9
No we don’t have that covered yet in a video but if you can join the webinar tuesday we can cover it there 👍
0
- ago
#10
QUOTE:
You can use the MathIndOpInd indicator which can divide one indicator for another in your transaction weight.

Right, but topic starter intends to optimize the period parameter which cannot be accomplished with the transformer.
1
- ago
#11
@Eugen, Panne

thank you so much
0
- ago
#12
@ Eugen

May I ask how long it will take for this Optimizable Indicator (RSL) to be available in the PowerPack?
0
- ago
#13
Happy New Year.

PowerPack B33 should see the light together with Wealth-Lab's next B67.
1
- ago
#14
wow, thank you verry much
0

Closed

Bookmark

Sort