Profile Picture

Example Indicator With Multiple Inputs

Posted By blousetrader 7 Years Ago
Message
Posted Thursday January 21 2010
Does anyone have an example of an indictor with multpile inputs. I'm trying to build one but getting the error 'Overload Resolution failed because no accessible 'New' accepts this number of arhuments'
Posted Sunday January 24 2010
Which base class are you using?  Here's the source to our Bollinger Band Lower indicator which takes multiple inputs.  This should help.

       public class BollingerBandLower : SeriesCalculatorBaseWithValues

       {

              private int periods = 14;

              private double deviation = 1.5;

              StdDevQueue stdDevQueue;

 

              [ConstructorArgument("Periods", ConstructorArgumentType.Integer, "14", 1)]

              [ConstructorArgument("Deviation", ConstructorArgumentType.Double, "1.5", 2)]

              public BollingerBandLower(int periods, double deviation)

                     : base(1)

              {

                     this.periods = periods;

                     this.deviation = deviation;

 

                     stdDevQueue = new StdDevQueue(periods);

              }

 

              public BollingerBandLower(int periods, double deviation, ISeries input)

                     : this(periods, deviation)

              {

                     SetInputs(input);

              }

 

              protected override double CalcNewValue(int index)

              {

                     double price = inputs[0].LookBack(index);

 

                     stdDevQueue.AddValue(price);

 

                     if (!stdDevQueue.Full)

                     {

                           return double.NaN;

                     }

 

                     return stdDevQueue.Average - (stdDevQueue.StdDev * deviation);

              }

 

              protected override void Reset()

              {

                     stdDevQueue.Reset();

              }

       }

blousetrader (1/21/2010)
Does anyone have an example of an indictor with multpile inputs. I'm trying to build one but getting the error 'Overload Resolution failed because no accessible 'New' accepts this number of arhuments'
Posted Monday January 25 2010
Sorry - I didn't explain that very well.  In the indicator I want I need to use the Close, High and Low series - its how I set this up I need - code below doesn't work

<Serializable()> _
    <SeriesInputAttribute("Input 1", 1, Value := BarElement.Close)>

  <SeriesInputAttribute("Input 2", 2, Value := BarElement.High)>

  <SeriesInputAttribute("Input 3", 3, Value := BarElement.Low)>

Posted Monday January 25 2010
OK, I see what you mean.  Here is an example of multiple inputs.

[SeriesInputAttribute("Input", 1, Value=BarElement.Close)]

[SeriesInputAttribute("Input", 2, Value=1, Repeatable = true)]

public class MultiplySeries : SeriesCalculatorBaseSimple

{

       public MultiplySeries()

              : base(VARIABLE_NUM_INPUTS)

       {

       }

 

       public override double LookBack(int nBars)

       {

              double ret = 1;

              for (int i = 0; i < inputs.Length; i++)

              {

                     ret *= inputs[i].LookBack(nBars);

              }

              return ret;

       }

}

Posted Sunday January 31 2010
thanks bilb, off and running now


Similar Topics


Reading This Topic


2005-2017 © RightEdge Systems