Profile Picture

Using An Indicator with RList

Posted By Hocki101 7 Years Ago
Message
Posted Sunday April 04 2010
Can someone please help me setup an indicator using an RList that I am maintaining in c#. I need my bars to start at different times depending on the product, so I am creating them myself.

I am having trouble setting up an indicator (such as SMA) in code to use the low/high/etc. of my bars. I think I have to get an ISeries or ISeriesCalculator out of my RList, but am not sure how.

Any help would be appreciated.

Thanks
Posted Monday April 05 2010
I don't understand what you're trying to do exactly. When you say "setup an indicator" what does that mean? Do you have a custom indicator that you've created and you're trying to pull values from it to feed to another indicator?

Hocki101 (4/4/2010)
Can someone please help me setup an indicator using an RList that I am maintaining in c#. I need my bars to start at different times depending on the product, so I am creating them myself.

I am having trouble setting up an indicator (such as SMA) in code to use the low/high/etc. of my bars. I think I have to get an ISeries or ISeriesCalculator out of my RList, but am not sure how.

Any help would be appreciated.

Thanks
Posted Monday April 05 2010
Thanks for the response.

What I am looking to do is use your canned indicators, such as SMA with an RList<BarData> that I am creating/tracking myself.  How do I turn the low of my RList, myBars, into an ISeries[] that I can put in the SMA, mySMA?

Thank you in advance

Posted Tuesday April 06 2010
If you get that working can you post the solution - I'm trying to do something similar myself. Cheers
Posted Tuesday April 06 2010
OK, a few things, one, you can use the Items property to gain access to the list.  Second, you don't really want to convert your indicator to an ISeries to feed to another indicator.  Since things happen a bar at a time, you'd be creating a performance problem.  Instead, consider this sample, which is the actual source to our ADXR indicator.  It uses the ADX indicator to perform part of the calculation.  Notice the call to adxIndicator.SetBars in the CalcSeriesValues and the call to adxIndicator.AppendBar in CalcNextValue.

internal class ADXR : IndicatorBase

{

private int periods = 14;

private ADX adxIndicator = null;

private RList<BarData> pBars = null;

 

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

public ADXR(int periods)

{

this.periods = periods;

adxIndicator = new ADX(periods);

pBars = new RList<BarData>();

}

       public override RList<double> CalcSeriesValues(RList<BarData> bars)

{

pBars = new RList<BarData>();

adxIndicator.SetBars(pBars);

return base.CalcSeriesValues(bars);

}

 

       public override double CalcNextValue(BarData bar)

{

pBars.Add(bar);

int pBarIndex = pBars.TotalCount - 1;

 

adxIndicator.AppendBar(bar);

 

if (pBarIndex < periods)

{

return double.NaN;

}

                    

if (double.IsNaN(adxIndicator.LookBack(periods - 1)))

{

return double.NaN;

}

else

              {

double adxrValue = 0.0;

 

adxrValue = (adxIndicator.Current + adxIndicator.LookBack(periods - 1)) / 2;

 

return adxrValue;

}

}

}   

Posted Monday April 12 2010
If you actually do want to create your own bars, you need to create a frequency plugin. See this post for details.

Thanks,
Daniel


Similar Topics


Reading This Topic


2005-2017 © RightEdge Systems