Пример #1
0
        /// <summary/>
        public override double GetTimeframeRatio(Timeframe tf)
        {
            if (tf is Timeframe1Min)
            {
                return(60 * 2);                       // 8 hours approximatively
            }
            if (tf is Timeframe5Min)
            {
                return(12 * 2);
            }
            if (tf is Timeframe10Min)
            {
                return(6 * 2);
            }
            if (tf is Timeframe30Min)
            {
                return(2 * 2);
            }
            if (tf is TimeframeHour)
            {
                return(1 * 2);
            }

            throw new ArgumentOutOfRangeException("tf wrong: " + tf);
        }
Пример #2
0
 /// <summary/>
 public override double GetTimeframeRatio(Timeframe tf)
 {
     if (tf == Timeframes.DAY)
     {
         return(5);
     }
     return(Timeframes.DAY.GetTimeframeRatio(tf) * 5);
 }
Пример #3
0
        /// <summary/>
        public override double GetTimeframeRatio(Timeframe tf)
        {
            if (tf == Timeframes.DAY)
            {
                return(30 * 5 / 7);
            }
            if (tf == Timeframes.WEEK)
            {
                return(30 / 7);
            }

            return(Timeframes.DAY.GetTimeframeRatio(tf) * 30 * 5 / 7);
        }
Пример #4
0
        /// <summary>
        /// Returns how many times the second timeframe fits in the first one.
        /// </summary>
        public static double GetTimeframeRatio(Timeframe first, Timeframe second)
        {
            if (first == second)
            {
                return(1);
            }

            if (first < second)
            {
                return(1 / GetTimeframeRatio(second, first));
            }

            return(first.GetTimeframeRatio(second));
        }
Пример #5
0
        /// <summary/>
        public override double GetTimeframeRatio(Timeframe tf)
        {
            if (tf is TimeframeMonth)
            {
                return(12);
            }
            if (tf is TimeframeWeek)
            {
                return(52);
            }
            if (tf is TimeframeDay)
            {
                return(250);
            }

            return(Timeframes.DAY.GetTimeframeRatio(tf) * 250);
        }
Пример #6
0
 /// <summary>
 /// This function does convert the given date from the $orig_timeframe in a
 /// date of the $dest_timeframe. Take care that the destination timeframe must be
 /// bigger than the original timeframe.
 /// </summary>
 public static DateTime ConvertDate( DateTime date, Timeframe orig, Timeframe dest )
 {
     // #WAR#  WARN  "the destination time frame must be bigger" if ( $orig <= $dest);
     return dest.ConvertToDateTime( orig.ConvertToString( date ) );
 }
Пример #7
0
        /// <summary/>
        public override double GetTimeframeRatio( Timeframe tf )
        {
            if ( tf == Timeframes.DAY ) return 30 * 5 / 7;
            if ( tf == Timeframes.WEEK ) return 30 / 7;

            return Timeframes.DAY.GetTimeframeRatio( tf ) * 30 * 5 / 7;
        }
Пример #8
0
        /// <summary/>
        public override double GetTimeframeRatio( Timeframe tf )
        {
            if ( tf is Timeframe1Min ) return 60; // 8 hours approximatively
            if ( tf is Timeframe5Min ) return 12;
            if ( tf is Timeframe10Min ) return 6;
            if ( tf is Timeframe30Min ) return 2;
            if ( tf is TimeframeHour ) return 1;

            throw new ArgumentOutOfRangeException( "tf wrong: " + tf );
        }
Пример #9
0
 /// <summary>
 /// Returns how many times the second timeframe fits in the first one.
 /// </summary>
 public abstract double GetTimeframeRatio( Timeframe other );
Пример #10
0
 /// <summary/>
 public bool Equals( Timeframe tf )
 {
     return tf != null && tf.Id == Id;
 }
Пример #11
0
        /// <summary/>
        public override double GetTimeframeRatio( Timeframe tf )
        {
            if ( tf is TimeframeMonth ) return 12;
            if ( tf is TimeframeWeek ) return 52;
            if ( tf is TimeframeDay ) return 250;

            return Timeframes.DAY.GetTimeframeRatio( tf ) * 250;
        }
Пример #12
0
 /// <summary>
 /// This function does convert the given date from the $orig_timeframe in a
 /// date of the $dest_timeframe. Take care that the destination timeframe must be
 /// bigger than the original timeframe.
 /// </summary>
 public static DateTime ConvertDate(DateTime date, Timeframe orig, Timeframe dest)
 {
     // #WAR#  WARN  "the destination time frame must be bigger" if ( $orig <= $dest);
     return(dest.ConvertToDateTime(orig.ConvertToString(date)));
 }
Пример #13
0
 /// <summary/>
 public override double GetTimeframeRatio(Timeframe tf)
 {
     throw new Exception("Cannot set timeframe ratio for tick data");
 }
Пример #14
0
 /// <summary/>
 public bool Equals(Timeframe tf)
 {
     return(tf != null && tf.Id == Id);
 }
Пример #15
0
 /// <summary>
 /// Returns how many times the second timeframe fits in the first one.
 /// </summary>
 public abstract double GetTimeframeRatio(Timeframe other);
Пример #16
0
        /// <summary>
        /// Returns how many times the second timeframe fits in the first one.
        /// </summary>
        public static double GetTimeframeRatio( Timeframe first, Timeframe second )
        {
            if ( first == second ) return 1;

            if ( first < second )
            {
                return ( 1 / GetTimeframeRatio( second, first ) );
            }

            return first.GetTimeframeRatio( second );
        }
Пример #17
0
 /// <summary/>
 public override double GetTimeframeRatio( Timeframe tf )
 {
     throw new Exception( "Cannot set timeframe ratio for tick data" );
 }
Пример #18
0
 /// <summary/>
 public override double GetTimeframeRatio( Timeframe tf )
 {
     if ( tf == Timeframes.DAY ) return 5;
     return Timeframes.DAY.GetTimeframeRatio( tf ) * 5;
 }