Posted 12/31/2009 21:54:43
|
|
|
|
| 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 SystemImports System.Collections.GenericImports System.TextImports RightEdge.IndicatorsImports 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 ThenThrow New ArgumentException("ATR Lookback period must be greater than zero.")End IfEnd SubProtected Overloads Overrides Function CalcNewValue(ByVal index As Integer) As DoubleReturn 20End FunctionProtected Overrides Sub Reset()End SubPublic Overloads Overrides Sub SetInputs(ByVal ParamArray newInputs As ISeries())MyBase.SetInputs(newInputs(0))End Sub
|
|
Posted 1/2/2010 01:46:51
|
|
|
|
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
|
|
|
|
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
|
|
|
|
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
|
|
|
|
| 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 Memberspublic 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
|
|
|
|
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
|
|
|
|
Great work - It is working now.
Thanks.
|
|
|
|