protected override void Initialize()
{
Add(new Plot(Color.FromKnownColor(KnownColor.DarkViolet), PlotStyle.Line, "SPREAD"));
Add(FirstInstrument, BarsPeriods[0].Id, BarsPeriods[0].Value);
Add(SecondInstrument, BarsPeriods[0].Id, BarsPeriods[0].Value);
Overlay = false;
}
if (Times[1][0].DayOfYear == 7 )
{
a = CurrentDayOHL(BarsArray[0]).CurrentOpen[0];
b = CurrentDayOHL(BarsArray[1]).CurrentOpen[0];
}
if( b > 0 && a >0)
{
c = (Closes[0][0]/a)-1;
d = (Closes[1][0]/b)-1;
e = (c - d);
}
i have a fairly simple indicator that calculates a spread between two instruments. The reason why I used day 7 as the starting point for calculating the percentage return for the instrument is because i could not find a way to use the first bar loaded on the chart. So now it's really annoying because the indicator will not work if I don't have enough data loaded. In other words, I have to load a year worth of data so the "7th day" is also loaded on the chart for this indicator to work. Is there a way to avoid the above "starting point" so that any time i load a chart, it uses the first value as the starting point. In other words, if i load 30 days worth of data.. i want to use the open of the first bar on the chart for both instruments. a code sample will be very very appreciated.
thank you in advance.

Comment