This is the code I am using. All the indicator is doing is getting the Secondary Chart Series DoubbleStochasctics and Printing out the Bar Time and Indicator Value. Then it passes the dataseries to a method that prints the Time and Indicator Values for the three previous bars. What am I doing wrong? Is this not a correct use for IDataSeries? Is there another way of accomplishing the same thing?
#region Variables
// Wizard generated variables
private int period = 10;
private PeriodType secondary_ChartType = PeriodType.Minute;
private int secondary_ChartInterval = 5;
// User defined variables (add any user defined variables below)
private DataSeries SecondaryDoubleStochastics;
#endregion
/// <summary>
/// This method is used to configure the indicator and is called once before any bar data is loaded.
/// </summary>
protected override void Initialize()
{
Overlay = true;
Add(Secondary_ChartType, Secondary_ChartInterval); // Bars Array 1
SecondaryDoubleStochastics = new DataSeries(this);
}
private void PrintSecondarySeries(IDataSeries CurrentSeries)
{
Print(" Print From Method");
// Loop back to get the 3 most recent Time and Values
for (int index = 0; index < 3; index++)
Print(String.Format(" Time: {0} SecondaryDoubleStochastics: {1}", Time[index], SecondaryDoubleStochastics[index] ));
}
protected override void OnBarUpdate()
{
// Sync Secondary DataSeries
if(SecondaryDoubleStochastics == null)
SecondaryDoubleStochastics = new DataSeries(SMA(BarsArray[1], 1));
// Secondary Series OnBarUpdate
if(BarsInProgress == 1)
{
// Set SecondaryDoubleStochastics
SecondaryDoubleStochastics.Set(DoubleStochastics(Period)[0]);
// Print the CurrentBar Time and Value
Print(String.Format("\r\nOnBarUpdate New Bar {0} SecondaryDoubleStochastics[0]: {1}", Time[0], SecondaryDoubleStochastics[0] ));
// Call the Method and pass the DataSeries
if(CurrentBar > 3)
PrintSecondarySeries(SecondaryDoubleStochastics);
}
}
I am getting incorrect results as can be seem in the image.
I have attached the indicator.
Thanks for your help.
Comment