Profile Picture

Indicators Inside Indicators

Posted By blousetrader 7 Years Ago
Message
Posted Thursday March 25 2010
How can I use the default indicators when Im building my own custom indicators?
Posted Friday March 26 2010
Derive from them or include them as a member of your custom indicator class. They are just classes themselves. So be sure to include a reference to the indicator dll.

blousetrader (3/25/2010)
How can I use the default indicators when Im building my own custom indicators?
Posted Friday March 26 2010
As Bill mentions, you need to add a reference to Indicators.dll in your RightEdge project. Then you can declare a field in your indicator class for the indicator you want to use. In your indicator's constructor, create the instance of the indicator you want to use. Then you need to forward the new bar information to the indicator you are using. There are two types of indicators, those that implement IIndicator and those that implement ISeriesCalculator. If the indicator you are using has SetBars and AppendBar methods, then it is an IIndicator. If possible, the indicator you are writing should be of the same type as the indicator you are wrapping. For IIndicators, just call the wrapped indicator's SetBars method in your SetBars method, and call the AppendBar method in your AppendBar method. For ISeriesCalculators, you should call SetInputs on the wrapped indicator from your indicator's constructor, call NewBar() from your NewBar method, and call NewSeries() from your NewSeries method.

Thanks,
Daniel
Posted Sunday March 28 2010
Thanks - thats a lot clearer now
Posted Saturday April 24 2010
Hi,

I'm also struggling with this right now. Is there an example out there somewhere? How do you pass the inputs to the indicator inside an Indicator?

Thanks.
Posted Monday April 26 2010
Well, indicator parameters are just constructor arguments. So when you instantiate the indicator inside of your indicator, pass the parameters there.

zykem (4/24/2010)
Hi,

I'm also struggling with this right now. Is there an example out there somewhere? How do you pass the inputs to the indicator inside an Indicator?

Thanks.
Posted Monday April 26 2010
Hi Bill,

Is it possible to post an example? I'm still not clear on how to do it.

Thanks in advance
Nick
Posted Monday April 26 2010
Bill,

here's how I created my newIndicator and I'm getting an error in the NewSeries() method when calling my existing indicator NewSeries() method:

myInd ind;

newIndicator constructor
{
myInd = new myInd(param1);
myInd.SetInputs(inputs);
}

public override void NewBar()
{
base.NewBar();
myInd.NewBar();
}

public override void NewSeries(int count)
{
base.NewSeries(count);
myInd.NewSeries(count);
}

And the error I'm getting is in the NewSeries() method:

The Indicator plugin NCT.Indicators.myInd threw an exception of type System.NullReferenceException

Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at RightEdge.Common.ISeriesCalculator.NewSeries(Int32 count)
at RightEdge.ChartFormIndicatorManager.AddSeries(IndicatorInfo info, ISeries series)
at RightEdge.x12ca728e0d6c36e0.AddIndicator(IIndicatorPlugin plugin, IndicatorInfo info, Boolean promptReplace)
at RightEdge.x12ca728e0d6c36e0.AddIndicatorPlugin(IIndicatorPlugin plugin)
at RightEdge.x12ca728e0d6c36e0.x24d5bc0f5050fbe7(Object xe0292b9ed559da7d, DragEventArgs xfbf34718e704c6bc)

Inner Exception:
An exception of type System.NullReferenceException was thrown.
Object reference not set to an instance of an object.
at RightEdge.Common.SeriesCalculatorBaseWithValues.NewSeries(Int32 count)
at NCT.Indicators.newIndicator.NewSeries(Int32 count)
at RightEdge.Shared.SeriesCalculatorWrapper.NewSeries(Int32 count)
Posted Tuesday April 27 2010
You need to override the SetInputs method and set your inner series inputs from there, instead of in the constructor:

public override void SetInputs(params ISeries[] newInputs)
{
   myInd.SetInputs(newInputs);
   base.SetInputs(newInputs);
}

Thanks,
Daniel
Posted Tuesday April 27 2010
Thanks Daniel!

It works perfectly now.

Nick


Similar Topics


Reading This Topic


2005-2017 © RightEdge Systems