RightEdge Forums
Main     Home          Members     Calendar     Who's On

Welcome Guest
        



New Indicator Error Expand / Collapse
Message
Posted 12/31/2009 21:54:43 Post #10397
 

Forum MemberForum MemberForum MemberForum MemberForum MemberForum MemberForum MemberForum Member
I am trying to build a new indicator and keep getting an error. The below is a test that should just return 20.

The error says "Need exactly 3 input series, 1 was passed in."

Not sure where or how to input 3 series. I have input set to 1.

Any ideas?

Imports System

Imports System.Collections.Generic

Imports System.Text

Imports RightEdge.Indicators

Imports RightEdge.Common

' Indicators that implement SeriesCalculatorBaseSimple will support chaining since they can view the calculated

' values of other series inputs.

' See the readme.txt included in this project for more information.

' Use the Indicator Attribute to provide information such as the

' name and description of your indicator. If you do not include

' this attribute, your indicator will not show up in the indicator

' list.

' The Id attribute needs to be set to a unique code that will identify

' your indicator. A GUID is a good candidate.

' Indicators must be marked Serializable in order to be used in

' trading systems.

' Use the SeriesInputAttribute to specify how many inputs your

' indicator uses.

<Indicator(System.Drawing.KnownColor.Black, _

Author:="Name", _

CompanyName:="Company", _

Description:="Test", _

GroupName:="~Jimmy", _

HelpText:="Help", _

Id:="{5F6EFD6C-492C-4312-9259-5F10Q8SB44F8}", _

DefaultDrawingPane:="Test", _

Name:="Test")> _

<Serializable()> _

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

Public Class Test : Inherits SeriesCalculatorBaseWithValues

<ConstructorArgument("Volatility Period", ConstructorArgumentType.Integer, "10", 1)> _

Public Sub New(ByVal myVOLATILITY_PERIOD As Integer)

MyBase.New(3)

If myVOLATILITY_PERIOD <= 0 Then

Throw New ArgumentException("ATR Lookback period must be greater than zero.")

End If

End Sub

Protected Overloads Overrides Function CalcNewValue(ByVal index As Integer) As Double

Return 20

End Function

Protected Overrides Sub Reset()

End Sub

Public Overloads Overrides Sub SetInputs(ByVal ParamArray newInputs As ISeries())

MyBase.SetInputs(newInputs(0))

End Sub

Posted 1/2/2010 01:46:51 Post #10399
 

Forum MemberForum MemberForum MemberForum MemberForum MemberForum MemberForum MemberForum Member
No worries fixed it.

But have another question. If I am creating an indicator that uses ATR and SMA's what should I use? IndicatorBase, SeriesCalculatorBaseWithValues or SeriesCalculatorBase?

The indicator will only use a close series but ATR needs all the inputs to work and the SMA only needs the close series.

All other inputs are integers or doubles.

Thanks.
Posted 1/4/2010 07:53:02 Post #10405
 

Lead DeveloperLead DeveloperLead DeveloperLead DeveloperLead DeveloperLead DeveloperLead DeveloperLead Developer
See this help topic about creating indicators for a rundown on what to derive from depending on your needs.

jimbob (1/2/2010)
No worries fixed it.

But have another question. If I am creating an indicator that uses ATR and SMA's what should I use? IndicatorBase, SeriesCalculatorBaseWithValues or SeriesCalculatorBase?

The indicator will only use a close series but ATR needs all the inputs to work and the SMA only needs the close series.

All other inputs are integers or doubles.

Thanks.
Posted 1/7/2010 02:22:14 Post #10430
 

Forum MemberForum MemberForum MemberForum MemberForum MemberForum MemberForum MemberForum Member
OK seam to be on the track now.

How can I create an ISeries from a Rlist?

I use

Private pBars As RList(Of BarData)

To keep track of the bar data but I need an ISeries to feed into the SMA indicator how can I do that?

Thanks.
Posted 1/7/2010 07:41:30 Post #10436
 

Lead DeveloperLead DeveloperLead DeveloperLead DeveloperLead DeveloperLead DeveloperLead DeveloperLead Developer
An ISeries is a double backed interface for use with indicators.  An RList is a generic collection, so one way to provide ISeries functionality from an RList would be to derive from ISeries and use your RList as the double based backing.  Try something like this:

public class MySeries : ISeries
{
   
RList<BarData> data;

   
public MySeries(RList<BarData> barSeries)
   
{
       
data = barSeries;
    }

    protected RList<BarData> barSeries
   
{
        
get
        
{
           
return data;
        }
    }

#region ISeries Members

public double LookBack(int nBars)
{
   
// Note, change this to accept which element of the bar you want to use, it's hard coded to close
   
return BarUtils.GetValueForBarElement(barSeries.LookBack(nBars), BarElement.Close);
}

 

public double Current
{
    
get
    
{
       
return LookBack(0);
     }
}


public
int Count
{
   
get
   
{
       
return barSeries.Count;
    }
}

 

public virtual bool OldValuesChange
{
   
get
   
{   return false;   }
}

 

public int OldestValueChanged
{
    get { return 0; }
}

 

public SeriesChartSettings ChartSettings
{
   
get { throw new NotSupportedException(); }
   
set { throw new NotSupportedException(); }
}

#endregion

}

Posted 1/7/2010 12:00:40 Post #10441
 

DeveloperDeveloperDeveloperDeveloperDeveloperDeveloperDeveloperDeveloper
While you can create an implementation of ISeries that reads from an RList, in practice you probably don't want to do this. Indicator values for a new bar are all calculated before NewBar is called. So you won't have a chance to update the current value for the RList/ISeries before it is used as an input for the SMA or whatever other indicator you are using.

If you just need an ISeries of the Close or other bar element, these already exist for you to use. The Open, Low, High, Close, and Volume properties of the symbol script class are all of type ISeries.

Thanks,
Daniel
Posted 1/8/2010 22:05:49 Post #10447
 

Forum MemberForum MemberForum MemberForum MemberForum MemberForum MemberForum MemberForum Member
Great work - It is working now.

Thanks.
« 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 6:01pm

2005-2007 © RightEdge Systems