Not sure how the final logic should be, but probably you can figure it out
by using a loop as shown below:

for(i = 2; i < BarCount; i++)
{
  if(V3[i-1] > 0 AND V3[i-1] > V3[i-2])
    Color[i] = colorGreen; 
  else
    Color[i] = colorRed; 
}


Kind regards,
Thomas Zmuck
www.PatternExplorer.com



From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf
Of dj9866
Sent: Wednesday, October 31, 2007 11:04 PM
To: [email protected]
Subject: [amibroker] What am I overlooking in generating color bar???

I am trying to generated a green/red colorbar across the bottom of the
indicator plot. I have it working properly in a number of other
indicator plots, but not this one. The value of the color array is
displayed in the interpertation window and changes between green and
red as the vertical cursor is moved across the screen. However, the
colorbar is a solid color all the way across the screen. As the screen
is shifted left or right the colorbar will change to all green or all red.

Any assistance is appreciated.

_SECTION_BEGIN("ModADX");
range = Param("Periods", 14, 2, 200, 1 );
Plot( ADX(range), _DEFAULT_NAME(), ParamColor( "ADX color", colorBlue
), ParamStyle("ADX style", styleThick ) );
Plot( MA(PDI(range),5), "+DI", ParamColor( "+DI color", colorGreen ),
ParamStyle("+DI style") );
Plot( MA(MDI(range),5), "-DI", ParamColor( "-DI color", colorRed ),
ParamStyle("-DI style") );

V1=MA(PDI(),5);
V2=MA(MDI(),5);
V3=V1-V2; //Value>0=PDI>MDI...value<0 then MDI>PDI...
if (V3[BarCount-1]>0)
Color = IIf( V3[BarCount-1]>V3[BarCount-2], colorGreen,colorRed); 
else
Color = IIf( V3[BarCount-1]<V3[BarCount-2], colorRed,colorGreen); 

Plot( 4, "ColorBar", Color, styleArea | styleOwnScale,-0.1,100);
printf("V3*********\n");
WriteVal(V3);
printf("Color**********\n");
WriteVal(Color);
_SECTION_END();
 

Reply via email to