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

Re: [amibroker] Code Help using if statement



PureBytes Links

Trading Reference Links

Try

Confidence = BarsSince(Crossing); 
instead of the first part of your loop.
Did not test it, but should work.

----- Original Message ----- 
From: "ricko8294_98" <ricko@xxxxxxxxxx>
To: <amibroker@xxxxxxxxxxxxxxx>
Sent: Sunday, January 07, 2007 9:29 PM
Subject: [amibroker] Code Help using if statement


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

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