TimeFrame object bug ?

Created at 04 Apr 2019, 01:38
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!
A.

a.fernandez.martinez

Joined 02.03.2019

TimeFrame object bug ?
04 Apr 2019, 01:38


Hello,

 

I tried to make a method that converts seconds to the closest timeframe (rounded down), here is the code (only goes to m3 at the moment) :

            // Seconds to Timeframe
            public static TimeFrame Timeframe(double seconds);
            {               
                if(seconds - 60 >= 0 && seconds - 120 < 0)
                    return TimeFrame.Minute;
                else if(seconds - 120 >= 0 && seconds - 180 < 0)
                    return TimeFrame.Minute2;
                else if(seconds - 180 >= 0 && seconds - 240 < 0)
                    return TimeFrame.Minute3;
            }

 

But I get compiling error...

I think I don't understand very well the timeframe object, I already tried to do it by creating an object like this :

            // Seconds to Timeframe
            public static TimeFrame Timeframe(double seconds);
            { 
                TimeFrame timeframe = new Timeframe();

                if(seconds - 60 >= 0 && seconds - 120 < 0)
                    return timeframe.Minute;
                else if(seconds - 120 >= 0 && seconds - 180 < 0)
                    return timeframe.Minute2;
                else if(seconds - 180 >= 0 && seconds - 240 < 0)
                    return timeframe.Minute3;
            }

But it still doesn't work.

 

I thought of returning a string like "Minute" or "Minute2" but I'm not sure if it would work with GetSeries, can you tell me if it works ?

 

How can I make such method ?

 

Thanks.


@a.fernandez.martinez
Replies

... Deleted by UFO ...

PanagiotisCharalampous
04 Apr 2019, 09:37

Hi a.fernandez.martinez,

A couple of questions

  1. What errors do you get?
  2. Why do you have ; before the function body?

Best Regards,

Panagiotis 


@PanagiotisCharalampous

a.fernandez.martinez
04 Apr 2019, 19:49

RE:

Panagiotis Charalampous said:

  1. Why do you have ; before the function body?

That was the cause of the error, sorry it was late I didn't pay attention...........

I'll check twice before posting next time, thanks !


@a.fernandez.martinez