RightEdge Forums
Main     Home          Members     Calendar     Who's On

Welcome Guest
        



Example Indicator With Multiple Inputs Expand / Collapse
Message
Posted 1/21/2010 15:51:22 Post #10548
 

Forum GuruForum GuruForum GuruForum GuruForum GuruForum GuruForum GuruForum Guru
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 1/24/2010 09:31:00 Post #10559
 

Lead DeveloperLead DeveloperLead DeveloperLead DeveloperLead DeveloperLead DeveloperLead DeveloperLead Developer
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 1/25/2010 07:31:06 Post #10570
 

Forum GuruForum GuruForum GuruForum GuruForum GuruForum GuruForum GuruForum Guru
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 1/25/2010 07:42:30 Post #10571
 

Lead DeveloperLead DeveloperLead DeveloperLead DeveloperLead DeveloperLead DeveloperLead DeveloperLead Developer
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 1/31/2010 07:29:12 Post #10659
 

Forum GuruForum GuruForum GuruForum GuruForum GuruForum GuruForum GuruForum Guru
thanks bilb, off and running now
« Prev Topic | Next Topic »


Reading This Topic Expand / Collapse
Active Users: 0 (0 guests, 0 members, 0 anonymous members)
No members currently viewing this topic.
Forum Moderators: billb, young, dplaisted

Permissions Expand / Collapse

All times are GMT -5:00, Time now is 7:25pm

2005-2007 © RightEdge Systems