- ago
I don't know enough to know whether this is implementable but can parameters be changed so that we can write something like this

CODE:
public MyStrategy() // This has to have the name of the class above       {          // In this instance I am not using this for anything          AddParameter("Steepness_level", ParameterType.Int32, -15, -15, 40, 1); // Parameter index 0          AddParameter("High_per", ParameterType.Int32, 50, 25, 300, 25); // Parameter index 1          //AddParameter("ATR_mult_2", ParameterType.Int32, 2, 2, 8, 1);       }


CODE:
public override void Initialize(BarHistory bars){    highest_s = Highest.Series(bars.Close, Parameters[1].AsInt); }


to

CODE:
public override void Initialize(BarHistory bars){    highest_s = Highest.Series(bars.Close, Parameters.High_per.AsInt); }


Thank you for the consideration.
0
78
2 Replies

Reply

Bookmark

Sort
- ago
#1
You're looking for this, no need for feature requests (removed):

ParameterList.FindName

It's documented here: https://www.wealth-lab.com/Support/ApiReference/ParameterList

CODE:
var highest_s = Highest.Series(bars.Close, Parameters.FindName("High_per").AsInt);


P.S. Use the CODE button instead of QUOTE when wrapping code snippets (fixed).
1
- ago
#2
If you look at the Docs for the AddParameter method, it does return a Parameter object. But if you want that object to be visible throughout the strategy (which you probably do), then you need to declare that object in the MyStrategy {block} with any other strategy-wide declarations. In other words, standard C#/C++/Java scoping rules apply.

CODE:
public class MyStrategy : UserStrategyBase {    Parameter steepness_level, high_per;    IndicatorBase highest_s;    public MyStrategy()    {       steepness_level = AddParameter("Steepness_level", ParameterType.Int32, -15, -15, 40, 1); // Parameter index 0       high_per = AddParameter("High_per", ParameterType.Int32, 50, 25, 300, 25); // Parameter index 1    }    public override void Initialize(BarHistory bars)    {       highest_s = Highest.Series(bars.Close, high_per.AsInt);    }    public override void Execute(BarHistory bars, int idx) { } }
0

Reply

Bookmark

Sort