TimeFrame operators
TimeFrame operators
14 Jul 2015, 17:47
The TimeFrame class is very poor, the class is :
namespace cAlgo.API
{
// Summary:
// Contains supported timeframe values from Minute 1 to Monthly.
public class TimeFrame
{
public static TimeFrame Daily;
public static TimeFrame Day2;
public static TimeFrame Day3;
public static TimeFrame Hour;
public static TimeFrame Hour12;
public static TimeFrame Hour2;
public static TimeFrame Hour3;
public static TimeFrame Hour4;
public static TimeFrame Hour6;
public static TimeFrame Hour8;
public static TimeFrame Minute;
public static TimeFrame Minute10;
public static TimeFrame Minute15;
public static TimeFrame Minute2;
public static TimeFrame Minute20;
public static TimeFrame Minute3;
public static TimeFrame Minute30;
public static TimeFrame Minute4;
public static TimeFrame Minute45;
public static TimeFrame Minute5;
public static TimeFrame Minute6;
public static TimeFrame Minute7;
public static TimeFrame Minute8;
public static TimeFrame Minute9;
public static TimeFrame Monthly;
public static TimeFrame Weekly;public static bool operator <(TimeFrame x, TimeFrame y);
public static bool operator <=(TimeFrame x, TimeFrame y);
public static bool operator >(TimeFrame x, TimeFrame y);
public static bool operator >=(TimeFrame x, TimeFrame y);public override string ToString();
}
}
It will be more convenient if there is a method like
TimeSpan TimeFrame.ToTimeSpan()
{
TimeSpan timespan;
// instruction to transform each TimeFrame.Time in TimeSpan.
return timespan;
};
With TimeSpan the operators is very large and it will be more simple to operate on timeframe.
aysos75
14 Jul 2015, 18:52
The solution is simple, I use extensions method to TimeFrame :
And I can use in my indicator instructions like this :
@aysos75