How to set a custom parameter

Created at 15 Jun 2017, 18:06
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!
TA

tacnet

Joined 30.05.2017

How to set a custom parameter
15 Jun 2017, 18:06


Hello ,

I would like to set a custom property. It works when I want to assign a single string like below:

        [Parameter(DefaultValue = "MyCustomValue")]
        public string MyParameter{ get; set; }

Actually I want to be able to select a value from a drop down list of my custom values out of self defined string array.

Like string[3]={MyValue1,MyValue2,MyValue3}

I could not find a way to to this. Apparently I need to create a new custom type.

Does anyone have an idea how to achieve this goal?

Taco


@tacnet
Replies

cyfer
15 Jun 2017, 23:46

You set a Custom Parameter exactly like you did 

You just test it in Initalize 

[Parameter(DefaultValue = "MyCustomValue")]
public string MyParameter{ get; set; }

and in Initalize you test it 

switch(MyParameter)
{
  case "MyCustomValue" : 
                 do something
                 break;
  case "MyCustomValue2"  : 
                 do something
                 break;
  case "MyCustomValue3"  : 
                 do something
                 break;
 default : 
                 do something
                 break ;
}

However , The list thing is not currently possible 

feel free to flame Spotware 

 


@cyfer

tacnet
17 Jun 2017, 14:03

Thank you cyfer for your respond. I was blaming my novice skills on c# but apparently cAlgo is the cultprit. Pity that  a user cannot modify such small aspect with a powerful tool as c#.

I have noticed that already in 2014 this feature has been requested but spotware has not reacted yet. If some other users would like to have this feature they can vote here:

http://vote.spotware.com/forums/229166-ideas-and-suggestions-for-ctrader-and-calgo/suggestions/5502949-custom-parameters


@tacnet

AlgoCreators
05 Mar 2022, 01:22

use enumerations types

like this

        

public enum CustomType
        {
           Low,
           Medium,
           High
        }
        [Parameter("P1", Group = "new type", DefaultValue = Low)]
        public CustomType P1 { get; set; }

read this like for more information:https://w3schools.com/cs/cs_enums.php


@AlgoCreators