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