STRING TO TIMEFRAME

Created at 17 Mar 2020, 21:39
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!
DO

dordkash@gmail.com

Joined 30.09.2017

STRING TO TIMEFRAME
17 Mar 2020, 21:39


Hi

I wrote this code
To be more detailed, I just copied what I had a problem with
It gives the BC

an error as to why the string is there and not the time frame
What solution do you offer
 


@dordkash@gmail.com
Replies

dordkash@gmail.com
17 Mar 2020, 21:41 ( Updated at: 21 Dec 2023, 09:21 )

RE:
        [Parameter("TIME FRAME 2")]
        public TimeFrame TF2 { get; set; }

        [Parameter("TIME FRAME 3")]
        public TimeFrame TF3 { get; set; }

        [Parameter("TIME FRAME 4")]
        public TimeFrame TF4 { get; set; }


        protected override void Initialize()
        {
            // Initialize and create nested indicators

            TimeFrame[] TFF = 
            {
                TF2,
                TF3,
                TF4
            };

            var STF2 = new StackPanel 
            {
                VerticalAlignment = VerticalAlignment.Top,
                HorizontalAlignment = HorizontalAlignment.Right

            };

            foreach (var TFFF in TFF)
            {
                var PDH1 = MarketData.GetBars(TFFF, SymbolName);
                //....
                //....
                //....
                var BTF2 = new Button 
                {
                    Text = SymbolName + TFFF.ToString(),
                    Margin = "TFFF",
                    FontSize = 11,
                    FontWeight = FontWeight.UltraBold,
                    FontFamily = SymbolName

                };
                BTF2.Click += BTF2CLK;
                STF2.AddChild(BTF2);
            }

        }

        private void BTF2CLK(ButtonClickEventArgs obj)
        {
            var symbolName = obj.Button.FontFamily;
            var BC = obj.Button.Margin;

            Chart.TryChangeTimeFrameAndSymbol(BC, symbolName);
        }

dordkash@gmail.com said:

Hi

I wrote this code
To be more detailed, I just copied what I had a problem with
It gives the BC

an error as to why the string is there and not the time frame
What solution do you offer
 

 


@dordkash@gmail.com

PanagiotisCharalampous
18 Mar 2020, 08:36

Hi there,

You can write a function to convert a a string to a timeframe. Check this thread.

Best Regards,

Panagiotis 

Join us on Telegram

 

 


@PanagiotisCharalampous

dordkash@gmail.com
18 Mar 2020, 12:10

RE:

PanagiotisCharalampous said:

Hi there,

You can write a function to convert a a string to a timeframe. Check this thread.

Best Regards,

Panagiotis 

Join us on Telegram

 

 

Yes I saw this
But there must be a specified time frame in this code
For example H4,DAYLI ....

But here my frame time is variable


@dordkash@gmail.com

PanagiotisCharalampous
18 Mar 2020, 12:18

Hi there,

I am not sure what do you mean. The example I provided also takes a string variable as input string. 

Best Regards,

Panagiotis 

Join us on Telegram


@PanagiotisCharalampous

dordkash@gmail.com
18 Mar 2020, 19:32

RE:

PanagiotisCharalampous said:

Hi there,

I am not sure what do you mean. The example I provided also takes a string variable as input string. 

Best Regards,

Panagiotis 

Join us on Telegram

Yes
But its output is a specified frame time
I want my output to be exactly the TimeFrame , not that TimeFram.Daily OR Hour4 OR ...


@dordkash@gmail.com