So the DataSeries Class Set method has a format of DataSeries.Set(int, barsago, double value); So my simple indicator the has the price change for 3 bars into the future is:
protected override void OnBarUpdate()
{
//Trgt.Reset();
if(CurrentBar < lookBack) return;
if( Close[0] - Close[lookBack] >= 0.00 )
{
Trgt.Set(lookBack, High[HighestBar(High,lookBack)] - Close[lookBack] );
}
else Trgt.Set(lookBack, Low[LowestBar(Low,lookBack)] - Close[lookBack] );
}
Now when adding this indicator to a chart everything is plotted correctly. The last 3 bars, right edge are empty. As they should be.
The problem comes in when I try and use this indicator in another indicator in which I create the file that contain all of the data that I want to train on. The script: SampleStreamWriter was used as the basis to create the file. I do not get the correct value from the indicator. I am getting some price from somewhere. The name of the indicator is MyTarget. Here is some of the code where I write everything to the file.
Print("Time:" + Time[lookback].ToString() + " Target: " +MyTarget(Close,lookback).Trgt[3].ToString());
sw.WriteLine(Time[lookback].ToString()
+ "," + Close[lookback]
+ "," + High[lookback]
+ "," + Low[lookback]
+ "," + Close[lookback + 1]
+ "," + High[lookback + 1]
+ "," + Low[lookback + 1]
+ "," + Close[lookback + 2]
+ "," + High[lookback + 2]
+ "," + Low[lookback + 2]
+ "," + DinapoliStochastic(Close, 3, 3, 5).LineK[lookback]
+ "," + DinapoliStochastic(Close, 3, 3, 5).LineD[lookback]
+ "," + DinapoliStochastic(Close, 3, 3, 5).LineK[lookback + 1]
+ "," + DinapoliStochastic(Close, 3, 3, 5).LineD[lookback + 1]
+ "," + DinapoliStochastic(Close, 3, 3, 5).LineK[lookback + 2]
+ "," + DinapoliStochastic(Close, 3, 3, 5).LineD[lookback + 2]
+ "," + MyTarget(lookback)[3] );
I have been able to verify that all of the data being exported to the file is correct except for what MyTarget()[3] is returning. The data is being returned is not even close. As I said, it's some kind of price data.
Is there something about using barsago in the Set method that I have failed to understand?
Thanks
Comment