How to use a bool as parameter

Created at 05 Mar 2013, 18:37
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!
condor's avatar

condor

Joined 28.02.2013

How to use a bool as parameter
05 Mar 2013, 18:37


I tried this :

        [Parameter("Use Trade Time ?", DefaultValue = false)]
        public bool UseTradeTime { get; set; }

I got a succesfull compilation but an error message too :

"Unable to load assembly : Unsupported parameter type 'boolean' "


@condor
Replies

TraderM
05 Mar 2013, 22:09

RE:
condor said:

I tried this :

        [Parameter("Use Trade Time ?", DefaultValue = false)]
        public bool UseTradeTime { get; set; }

I got a succesfull compilation but an error message too :

"Unable to load assembly : Unsupported parameter type 'boolean' "

Hi,

from what I have read I don't think you can use a boolean as a parameter.

To solve this I use an integer and set it to 1 or 0 (to represent true and false).

I would rather use a boolean as the user would be restricted as to what input they can enter, and the programming is neater. But as the user is me and I know not to enter a different value it works.

TraderM


@TraderM

condor
05 Mar 2013, 22:59

Exactly what i've done, but i made it simplier 0 for false and everything else for true, so i don't risk to have problems with users who choose 2.


@condor

hichem
06 Mar 2013, 10:47

RE:
condor said:

Exactly what i've done, but i made it simplier 0 for false and everything else for true, so i don't risk to have problems with users who choose 2.

Actually you can set a MaxValue= 1 and a MinValue = 0 in your paramater attribute


@hichem

cAlgo_Development
26 Jun 2013, 12:31

Boolean type parameters are supported in last release:

 

        [Parameter("Use Stop Loss", DefaultValue = true)]
        public bool UseStopLoss { get; set; }

@cAlgo_Development