string to timeframe

Created at 09 Mar 2020, 14:41
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!
TJ

Tj11

Joined 24.10.2019

string to timeframe
09 Mar 2020, 14:41


Hi Panagiotis,

Could you please advise how to convert string into timeframe ?

 

Thank you.


@Tj11
Replies

PanagiotisCharalampous
09 Mar 2020, 14:46

Hi Tj11,

You can write a function with a switch statement that does the conversion. See an example below

        private TimeFrame GetTimeFrameFromString(string timeframeString)
        {
            switch (timeframeString)
            {
                case "Hour":
                    return TimeFrame.Hour;
                    // .
                    // .
                    // .
                    // .
                    // .
                    // .
                    // .
                    // .
            }
            return TimeFrame.Hour;
        }

 

Best Regards,

Panagiotis 

Join us on Telegram

 


@PanagiotisCharalampous

Tj11
09 Mar 2020, 15:07

RE:

PanagiotisCharalampous said:

Hi Tj11,

You can write a function with a switch statement that does the conversion. See an example below

        private TimeFrame GetTimeFrameFromString(string timeframeString)
        {
            switch (timeframeString)
            {
                case "Hour":
                    return TimeFrame.Hour;
                    // .
                    // .
                    // .
                    // .
                    // .
                    // .
                    // .
                    // .
            }
            return TimeFrame.Hour;
        }

 

Best Regards,

Panagiotis 

Join us on Telegram

 

 

Thanks a lot, Panagiotis !!!


@Tj11