Here is the code:
protected override void OnBarUpdate()
{
if(CurrentBar < smaPeriod) return;
if(CurrentBar < maEnvPeriod) return;
if(CurrentBar < ichimokuPeriod) return;
AroonUp = Aroon(14).Up[0];
AroonDown = Aroon(14).Down[0];
// Bullish Trend
if (Close[0] > SMA(smaPeriod)[0]
&& Close[0] > ParabolicSAR(.02,.2,.02)[0]
&& Close[0] > Open[0]
&& AroonUp == 100
&& Close[0] > MAEnvelopes(maEnvPerc,3,maEnvPeriod).Upper[0]
&& Close[0] > Ichimoku(9,26,52)[0]
&& !barpainted)
{
BarColorSeries[0] = Color.Blue;
CandleOutlineColor = Color.Black;
barpainted = true;
}
if (Close[0] < Ichimoku(9,26,52).KijunSen[0])
{
barpainted = false;
}
// Bearish Trend
if (Close[0] < SMA(smaPeriod)[0]
&& Close[0] < ParabolicSAR(.02,.2,.02)[0]
&& Close[0] < Open[0]
&& AroonDown == 100
&& Close[0] < MAEnvelopes(maEnvPerc,3,maEnvPeriod).Upper[0]
&& Close[0] < Ichimoku(9,26,52).KijunSen[0]
&& !barpainted)
{
BarColorSeries[0] = Color.HotPink;
CandleOutlineColor = Color.Black;
barpainted = true;
}
if (Close[0] > Ichimoku(9,26,52).KijunSen[0])
{
barpainted = false;
}
}
This works great as long as I do not have the Bearish section there. As soon as I tell the code to do the same thing for the bearish, it then causes every instance of the bullish criteria to be active.
I need to know how I can get the same indicator to paint both bullish and bearish bars, without cancelling each other out. Is this possible?
Thank you for your help.

Comment