Topic: Adding bars shift to TopBottom indicator
Hello i added shift by bars to topbottom price and it works fine when the base price is one bar or one day but when use the week it starts drawing lines in a wrong way !!!!!
// Reading the parameters
double shift = IndParam.NumParam[0].Value*Point;
var shift1 = (int)IndParam.NumParam[1].Value;
int firstBar = 1 + shift1;
// Calculation
var adTopPrice = new double[Bars];
var adBottomPrice = new double[Bars];
adTopPrice[0] = 0;
adBottomPrice[0] = 0;
double dTop = double.MinValue;
double dBottom = double.MaxValue;
for (int bar = 1; bar < Bars - shift1; bar++)
{
if (High[bar - 1] > dTop)
dTop = High[bar - 1];
if (Low[bar - 1] < dBottom)
dBottom = Low[bar - 1];
if (IsPeriodChanged(bar + shift1))
{
adTopPrice[bar + shift1] = dTop;
adBottomPrice[bar + shift1] = dBottom;
dTop = double.MinValue;
dBottom = double.MaxValue;
}
else
{
adTopPrice[bar + shift1] = adTopPrice[bar - 1];
adBottomPrice[bar + shift1] = adBottomPrice[bar - 1];
}
}
var adUpperBand = new double[Bars];
var adLowerBand = new double[Bars];
for (int bar = firstBar; bar < Bars; bar++)
{
adUpperBand[bar] = adTopPrice[bar];
adLowerBand[bar] = adBottomPrice[bar];
}