public static double Value(ISeries input, int index, int length, BarData barData = BarData.Close) { if (index >= length - 1) { double num = 0.0; double num2 = SMA.Value(input, index, length, barData); for (int i = index; i > index - length; i--) { num += (num2 - input[i, barData]) * (num2 - input[i, barData]); } return(num / (double)length); } return(double.NaN); }
public static double Value(ISeries input, int index, int length) { if (index >= length) { double num = 0.0; for (int i = index - length + 1; i <= index; i++) { num += TR.Value(input, i); } num /= (double)length; return(SMA.Value(input, index, length, BarData.Typical) - num); } return(double.NaN); }
public static double Value(ISeries input, int index, int length1, int length2) { if (index >= length1 - 1 && index >= length2 - 1) { TimeSeries timeSeries = new TimeSeries(); for (int i = index - Math.Max(length1, length2) + 1; i <= index; i++) { timeSeries.Add(input.GetDateTime(i), input[i, BarData.Volume]); } double num = SMA.Value(timeSeries, length1 - 1, length1, BarData.Close); double num2 = SMA.Value(timeSeries, length2 - 1, length2, BarData.Close); return(num - num2); } return(double.NaN); }
protected override void OnStrategyStart() { Portfolio.Account.Deposit(AllocationPerInstrument, CurrencyId.USD, "Initial allocation"); bbu = new BBU(Bars, Length, K); bbl = new BBL(Bars, Length, K); sma = new SMA(Bars, Length); AddGroups(); }