Topic: Bollinger Band Upgrade
iam trying to use all the three lines of bollingerbands to be used in the 4 slots
but i faced the problem in the code part of SlotType == SlotTypes.Open || SlotType == SlotTypes.Close
it uses the upper and lower bands as interchange to each other
My problem: I cannot add the middle line to that part of code
Any help !!!
if (SlotType == SlotTypes.Open || SlotType == SlotTypes.Close)
{
if (nMA > 1)
{
for (int bar = firstBar; bar < Bars; bar++)
{
// Covers the cases when the price can pass through the band without a signal.
double open = Open[bar]; // Current open price
// Upper band
double valueUp = adUpBand[bar - prvs]; // Current value
double valueUp1 = adUpBand[bar - prvs - 1]; // Previous value
double tempValUp = valueUp;
if ((valueUp1 > High[bar - 1] && valueUp < open) || // The Open price jumps above the indicator
(valueUp1 < Low[bar - 1] && valueUp > open) || // The Open price jumps below the indicator
(Close[bar - 1] < valueUp && valueUp < open) || // The Open price is in a positive gap
(Close[bar - 1] > valueUp && valueUp > open)) // The Open price is in a negative gap
tempValUp = open; // The entry/exit level is moved to Open price
// Lower band
double valueDown = adDnBand[bar - prvs]; // Current value
double valueDown1 = adDnBand[bar - prvs - 1]; // Previous value
double tempValDown = valueDown;
if ((valueDown1 > High[bar - 1] && valueDown < open) ||
// The Open price jumps above the indicator
(valueDown1 < Low[bar - 1] && valueDown > open) ||
// The Open price jumps below the indicator
(Close[bar - 1] < valueDown && valueDown < open) || // The Open price is in a positive gap
(Close[bar - 1] > valueDown && valueDown > open)) // The Open price is in a negative gap
tempValDown = open; // The entry/exit level is moved to Open price
if (IndParam.ListParam[0].Text == "Enter long at Upper Band" ||
IndParam.ListParam[0].Text == "Exit long at Upper Band")
{
Component[3].Value[bar] = tempValUp;
Component[4].Value[bar] = tempValDown;
}
else
{
Component[3].Value[bar] = tempValDown;
Component[4].Value[bar] = tempValUp;
}
}
}
else
{
for (int bar = 2; bar < Bars; bar++)
{
if (IndParam.ListParam[0].Text == "Enter long at Upper Band" ||
IndParam.ListParam[0].Text == "Exit long at Upper Band")
{
Component[3].Value[bar] = adUpBand[bar - prvs];
Component[4].Value[bar] = adDnBand[bar - prvs];
}
else
{
Component[3].Value[bar] = adDnBand[bar - prvs];
Component[4].Value[bar] = adUpBand[bar - prvs];
}
}
}
}