Inheritance: Indicator
Esempio n. 1
0
        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();
        }
Esempio n. 2
0
        protected override void OnStrategyStart()
        {
            Portfolio.Account.Deposit(AllocationPerInstrument, CurrencyId.USD, "Initial allocation");

            // Set up indicators.
            fastSMA = new SMA(Bars, FastSMALength);
            slowSMA = new SMA(Bars, SlowSMALength);

            AddGroups();
        }
Esempio n. 3
0
        protected override void OnStrategyStart()
        {
            // Add money for current trading instrument's portfolio.
            Portfolio.Account.Deposit(Clock.DateTime, MoneyForInstrument, CurrencyId.USD, "Initial allocation");

            // Set up indicators.
            sma1 = new SMA(Bars, Length1);
            sma2 = new SMA(Bars, Length2);

            AddGroups();
        }
Esempio n. 4
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);
 }
Esempio n. 5
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);
     }
 }
Esempio n. 6
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));
 }
Esempio n. 7
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);
 }
Esempio n. 8
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);
 }
Esempio n. 9
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));
 }