Beispiel #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);
        }
Beispiel #2
0
 /// <summary/>
 public override double GetTimeframeRatio(Timeframe tf)
 {
     if (tf == Timeframes.DAY)
     {
         return(5);
     }
     return(Timeframes.DAY.GetTimeframeRatio(tf) * 5);
 }
Beispiel #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);
        }
Beispiel #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));
        }
Beispiel #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);
        }
Beispiel #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 ) );
 }
Beispiel #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;
        }
Beispiel #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 );
        }
Beispiel #9
0
 /// <summary>
 /// Returns how many times the second timeframe fits in the first one.
 /// </summary>
 public abstract double GetTimeframeRatio( Timeframe other );
Beispiel #10
0
 /// <summary/>
 public bool Equals( Timeframe tf )
 {
     return tf != null && tf.Id == Id;
 }
Beispiel #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;
        }
Beispiel #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)));
 }
Beispiel #13
0
 /// <summary/>
 public override double GetTimeframeRatio(Timeframe tf)
 {
     throw new Exception("Cannot set timeframe ratio for tick data");
 }
Beispiel #14
0
 /// <summary/>
 public bool Equals(Timeframe tf)
 {
     return(tf != null && tf.Id == Id);
 }
Beispiel #15
0
 /// <summary>
 /// Returns how many times the second timeframe fits in the first one.
 /// </summary>
 public abstract double GetTimeframeRatio(Timeframe other);
Beispiel #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 );
        }
Beispiel #17
0
 /// <summary/>
 public override double GetTimeframeRatio( Timeframe tf )
 {
     throw new Exception( "Cannot set timeframe ratio for tick data" );
 }
Beispiel #18
0
 /// <summary/>
 public override double GetTimeframeRatio( Timeframe tf )
 {
     if ( tf == Timeframes.DAY ) return 5;
     return Timeframes.DAY.GetTimeframeRatio( tf ) * 5;
 }