- ago
Good evening

I want to build myself a RSL indicator, can anyone help me with this code?

Close / SMA.Series( Bars . Close , Period)[bar];

Greetings Didi
0
426
Solved
5 Replies

Reply

Bookmark

Sort
Cone8
 ( 4.98% )
- ago
#1
Here's that pattern to create and use a simple ad-hoc indicator -

CODE:
using WealthLab.Backtest; using System; using WealthLab.Core; using WealthLab.Data; using WealthLab.Indicators; using System.Collections.Generic; namespace WealthScript16 { public class MyStrategy : UserStrategyBase { public override void Initialize(BarHistory bars) {          int period = 10;          _myIndicator = bars.Close / SMA.Series(bars.Close, period); } public override void Execute(BarHistory bars, int idx) { if (!HasOpenPosition(bars, PositionType.Long)) {             if (_myIndicator[idx] > 1.2)   // just showing you how to get a value at idx                PlaceTrade(bars, TransactionType.Buy, OrderType.Market); } else {           } }       private TimeSeries _myIndicator;               } }

If the goal is to create a formal Indicator that you can use in Blocks, then you need to work with the Indicator Builder in Administrator mode.
0
Best Answer
- ago
#2
I think that topic starter can also use the MathIndOpInd indicator, choosing "Close" as Indicator1 and SMA(Period) for Indicator2. It's found in the Transformers group of built-in indicators.

Just make sure to type in a different pane name (e.g. "RSL") rather than the default "Price".
2
Glitch8
 ( 10.62% )
- ago
#3
Yep, we created these "Transformer" indicators just for jobs like this, to save you the trouble of having to create a bespoke indicator.
1
- ago
#4
@Cone

Thank you for this code!

Unfortunately I am a total beginner in Wealth Lab. I took the code and wanted to build a new indicator, so I just pasted your formula into the empty code, but there come lots of error messages
0
Cone8
 ( 4.98% )
- ago
#5
Then you shouldn't use code because you're not a programmer.

Instead, create block strategies, and wherever an Indicator is required, you can use the Transformer group to create it as suggested above. Specifically, you need to use the MathOpInd indicator to form your indicator.

Example -



Here are all the Transformers. Click on each on and see the Description below it.


You can play with them and create combinations of indicators by dragging them into a chart, for example.
1

Reply

Bookmark

Sort