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

[amibroker] Code Help using if statement



PureBytes Links

Trading Reference Links

Hello
I am having trouble with the following.
I want to use the cross of the MACD as a signal, but in order to 
avoid whip-saws, I want to be "confident" that the MACD is still 
above the Signal.

This is part of my code which calculates the "confidence" level: Once 
there has been a "crossing" (which I will test separately), I want 
the "confidence" number to increase each day the MACD stays above the 
Signal (Condition) but to revert to zero if the MACD crosses back.  
In the following code, the Confidence number does not increment.

What am I doing wrong?

Thanks

Rick

****** code *******

Crossing = Cross(MACD(12,26),Signal(12,26,9));
Condition = MACD(12,r2) > Signal(12,26,9);
It_Crossed = Sum(Crossing,5);  // ie crossed within the past 5 days
Confidence = 0;

for( i = 1; i < BarCount; i++ )
{
  if(Condition[i])
    {
      Confidence[i]++ ;
    }
  
  if (It_Crossed[i] == 0);
    {
   Confidence[i] = 0;
    }
}



Content-Description: "AVG certification"
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.5.432 / Virus Database: 268.16.7/618 - Release Date: 1/6/2007 7:47 PM