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

[amibroker] Still confused



PureBytes Links

Trading Reference Links

Title: Simple code problem

Hi,

 

I’m still confused on how to use the variables.  The code below seems to work but slows AmiBroker down.  It seems that the “if” statement doesn’t like to see the variables mo, mh, mc without the square brackets.  All I’m trying to do here is plot the difference between the average high and average open/close in a colour depending of the result as a histogram.

 

Question: is it possible to define a variable that is not an array?

 

Periods = Param("Periods", 5, 2, 200, 1, 1 );

 

     Color = Null;

     TheDiff = Null;

 

     for( i = 0; i < BarCount; i++ ) {

 

           mo = MA( Open, Periods);

           mh = MA( High, Periods); 

           mc = MA( Close, Periods);

 

          if(mo[i] < mc[i]){

                TheDiff[i] = mh[i] - mc[i];

                Color[i] = colorBlue;

           }else if(mo[i] > mc[i]){

                TheDiff[i] = mh[i] - mo[i];

                Color[i] = colorRed;

           }else{

                TheDiff[i] = 0;

                Color[i] = colorGreen;

           }

 

     }

 

Plot( TheDiff, "SC Plus", Color, styleHistogram);

 

 




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





SPONSORED LINKS
Investment management software Real estate investment software Investment property software
Software support Real estate investment analysis software Investment software


YAHOO! GROUPS LINKS