You could try this

Crossing = Cross(MACD(12,26),Signal(12,26,9));
Condition = MACD(12,26) > Signal(12,26,9);
It_Crossed = barssince(Crossing)<=5 and Condition;  // ie crossed within the
past 5 days and still above signal line



--
Cheers
Graham
AB-Write >< Professional AFL Writing Service
Yes, I write AFL code to your requirements
http://www.aflwriting.com


On 08/01/07, ricko8294_98 <[EMAIL PROTECTED]> wrote:

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;
    }
}




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 NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/

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

Yahoo! Groups Links




Reply via email to