List Parameter

Created at 22 Sep 2021, 09:50
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!
VM

vmtxd07

Joined 13.05.2021

List Parameter
22 Sep 2021, 09:50


Hi all.

I'm seeing the code in Automate of ctrader. I don't know how to get value of the Source after choose etc, Open or Close or High ...

I know DataSeries Source will return Source of bar will using as the data input.

Thanks !

        [Parameter("Source")]
        public DataSeries Source { get; set; }

 


@vmtxd07
Replies

PanagiotisCharalampous
22 Sep 2021, 10:22

Hi vmtxd07,

It's not possible to know the type of the source. If you need to know the type, then you might want to consider another approach e.g. using custom enums.

Best Regards,

Panagiotis 

Join us on Telegram and Facebook


@PanagiotisCharalampous

firemyst
24 Sep 2021, 03:37 ( Updated at: 21 Dec 2023, 09:22 )

RE:

vmtxd07 said:

Hi all.

I'm seeing the code in Automate of ctrader. I don't know how to get value of the Source after choose etc, Open or Close or High ...

I know DataSeries Source will return Source of bar will using as the data input.

Thanks !

        [Parameter("Source")]
        public DataSeries Source { get; set; }

 

 

What "value" are you trying to get?

1) The actual decimal value of the SMA? If so, then create your indicator similar to as follows:

Indicators.MovingAverage(DataSource source, int periods, MovingAverageType maType)

and get its value every time you need it.

 

2) the value of the type of source selected? Then you can use @Panagiotis' suggestion by creating your own enum:

 public enum MASource_Options
        {
            High,
            Low,
            Open,
            Close
        }

and using that as the parameter type:

 

 [Parameter("Source", DefaultValue = MASource_Options.Close)]
        public MASource_Options SMASource { get; set; }

 


@firemyst