Value() public static method

public static Value ( ISeries input, int index, int length, BarData barData = BarData.Close ) : double
input ISeries
index int
length int
barData BarData
return double
Example #1
0
 public static double Value(ISeries input, int index, int length, BarData barData = BarData.Close)
 {
     if (index >= length - 1)
     {
         var sma = SMA.Value(input, index, length, barData);
         return((input[index, barData] - sma) / sma * 100.0);
     }
     return(double.NaN);
 }
Example #2
0
 public static double Value(ISeries input, int index, int length1, int length2)
 {
     if (index >= length1 - 1 && index >= length2 - 1)
     {
         var ts = new TimeSeries();
         for (var i = index - Math.Max(length1, length2) + 1; i <= index; i++)
         {
             ts.Add(input.GetDateTime(i), input[i, BarData.Volume]);
         }
         return(SMA.Value(ts, length1 - 1, length1) - SMA.Value(ts, length2 - 1, length2));
     }
     return(double.NaN);
 }
Example #3
0
 public static double Value(ISeries input, int index, int length, BarData barData = BarData.Close)
 {
     if (index >= length - 1)
     {
         var sma = SMA.Value(input, index, length, barData);
         return(Enumerable.Range(index - length + 1, length)
                .Sum(i => (sma - input[i, barData]) * (sma - input[i, barData])) / length);
     }
     else
     {
         return(double.NaN);
     }
 }
Example #4
0
 public static double Value(ISeries input, int index, int length, double shift, BarData barData = BarData.Close)
 {
     return(index < length - 1 ? double.NaN : SMA.Value(input, index, length, barData) * (1 + shift / 100.0));
 }
Example #5
0
 public static double Value(ISeries input, int index, int length, double k, BarData barData = BarData.Close)
 {
     return(index >= length - 1
         ? SMA.Value(input, index, length, barData) + k * SMD.Value(input, index, length, barData)
         : double.NaN);
 }
Example #6
0
 public static double Value(ISeries input, int index, int length)
 {
     return(index < length
         ? double.NaN
         : SMA.Value(input, index, length, BarData.Typical) - Enumerable.Range(index - length + 1, length).Reverse().Sum(i => TR.Value(input, i)) / length);
 }
Example #7
0
 public static double Value(ISeries input, int index, int length1, int length2, BarData barData = BarData.Close)
 {
     return(index < length1 - 1 || index < length2 - 1
         ? double.NaN
         : SMA.Value(input, index, length1, barData) - SMA.Value(input, index, length2, barData));
 }