[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [amibroker] Example code doesn't work



PureBytes Links

Trading Reference Links

Seems the preference that I've seen on the forum is to use the AB array processing approach has rather than using

the looping technique.  That is unless you want to select and operate on a specific element of the array

like Close[i],

Plotcolor = IIf(Close>Open,colorGreen,colorRed);

Plot(C,"Close",Plotcolor,styleLine);

Joe

 

----- Original Message -----
From: metaboxfan
Sent: Monday, March 06, 2006 3:32 AM
Subject: [amibroker] Example code doesn't work

Hi

Sorry for asking. In the code below, which I got from Common Coding mistakes I

neither see red nor green colors in my plot but I do see a gray plot.

What is wrong with this simple code?

Thanks in advance

Olli

/*

From: Common Coding mistakes in AFL

Example: if-else statement needs boolean (or single numeric expression), not array

Re: [Amibroker] Creating a toggle switch Sent: 27.06.2005

*/

_SECTION_BEGIN("ShowEarnings_1");

Color[0] = colorGreen;    // if I don't add this line I'll get Error 29, Variable 'color' used without having been initialized

  

for (i=0; i > BarCount; i++)

{

if (Close[i] > Open[i] )

Color[i] = colorGreen;

else

Color[i] = colorRed;

}

Plot(Close,"Colored Price", Color, styleCandle);

_SECTION_END();



Please note that this group is for discussion between users only.

To get support from AmiBroker please send an e-mail directly to
SUPPORT {at} amibroker.com

For other support material please check also:
http://www.amibroker.com/support.html





YAHOO! GROUPS LINKS