Passing NON PARAMETER values to an indicator constructor?

Created at 26 Oct 2016, 23:43
How’s your experience with the cTrader Platform?
Your feedback is crucial to cTrader's development. Please take a few seconds to share your opinion and help us improve your trading experience. Thanks!
kdcp999's avatar

kdcp999

Joined 09.10.2016

Passing NON PARAMETER values to an indicator constructor?
26 Oct 2016, 23:43


Trying to reference a custom indicator passing in values for intialisation - to no avail. The API documentation really isn't helpfull on this matter.

 

// What I want...
Indicators.GetIndicator<IchiIndicator>("USD/GBP", 9, 26,  52);
Indicators.GetIndicator<IchiIndicator>("USD/AUS", 9, 26,  52);
Indicators.GetIndicator<IchiIndicator>("USD/JPY", 9, 26,  52);

// This above is a problem - because I can only set up values that will be passed automatically
// declaring input parameters like so...

    [Parameter("Symbol")]
    public Symbol Pair { get; set; }

    [Parameter("FastLinePeriods")]
    public int FastLinePeriods { get; set; }

    [Parameter("SlowLinePeriods")]
    public int SlowLinePeriods { get; set; }

    [Parameter("SlowestLinePeriods")]
    public int SlowestLinePeriods { get; set; }

// I REALLY don;t want to have to set up these parameter input boxes just to pass the values
// to an indicator.
// I am baffled as to why I can't just create a constructor for my indicator with the desired //params in a constructor?!

// --------------------------------------------------------------------
   

Any ideas?

I also find the way you need to reference an indicator in a Robot reallly awkward. There is no explanation as to why I can't just instantiate an indicator object(seeing as it would extend the base indicator interface) and pass the constructor whatever the user desires. 

 


@kdcp999
Replies

kdcp999
27 Oct 2016, 00:51

Got it, I do blame the documentation though.


Instead of setting your own constructor - You just define the args you pass to the "GetIndicattor" method as public prooperties on the class so they somehow are matched and get instatiated becasue you have explicitly set them as "parameters" in the indicator class.  Go figure.

Support - Please  open source you documentation!  Have people set up pull requests for updates, I am sure consultants for cAlgo would contribute to up their visibility along side poeople like my self. The state of tthe docs is not at all worthy of praise.
MetaQuotes may be a PITA, but their docs are thourough, and well maintained.


@kdcp999

Jiri
27 Oct 2016, 13:54

In the code above you are trying to pass symbol as a string. Isn't that causing the problem?


@Jiri