TimeFrame object bug ?
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.
Replies
PanagiotisCharalampous
04 Apr 2019, 09:37
Hi a.fernandez.martinez,
A couple of questions
- What errors do you get?
- Why do you have ; before the function body?
Best Regards,
Panagiotis
@PanagiotisCharalampous
a.fernandez.martinez
04 Apr 2019, 19:49
RE:
Panagiotis Charalampous said:
- 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
... Deleted by UFO ...