George, I believe that what you want
has already been done by Dimitris Tsokakis.
For thread see:
http://elitetrader.com/vb/showthread.php?
s=&threadid=45378&highlight=The+probable+Cross+between+MACD+and+its+Si
gnal

directaim

// The probable Cross between MACD and its Signal, by D. Tsokakis, 
Feb2005
//The code may be used as a good daily consultant for the probable 
continuation of a trend. 

SetBarsRequired(10000,0);
function EMAn ( Cnext , p)
{
return ( 2 * Cnext + ( P - 1 ) * EMA ( C , P ) ) / ( P + 1 ) ;
}
function MACDn ( Cnext , p1 , p2 )
{
return EMAn ( Cnext ,p1 ) - EMAn ( Cnext , p2 ) ;
}
p1=12;p2=26;p=9;
det = 500 ;
perc = 25/100 ;
Clast = SelectedValue ( C ) ;

MACDlast = SelectedValue ( MACD() ) ; 
SIGNALlast = SelectedValue ( Signal ( ) );

Cnextmin = ( 1 - perc ) * Clast ;Cnextmax = ( 1 + perc ) * Clast ;
step = ( Cnextmax - Cnextmin ) / det ;
nextROC1 = -100 * perc ;
nextROC2 = -100 * perc ;
for ( Cnext = Cnextmin ; Cnext <= Cnextmax ; Cnext = Cnext + step )
{
X = MACDn ( Cnext , 12 , 26 ) ;
Y = EMA ( X , 9 ) ;
MACDnext = SelectedValue ( X );
SIGNALnext = SelectedValue ( Y );
NextROC = 100 * ( -1 + Cnext / Clast ) ;
NextROC0 = 100 * ( -1 + Cnext / Clast ) ;
if ( macdnext < SignalLAST )
{
NextROC1 = NextROC ; 
}
if ( MACDnext < MACDlast )
{
nextROC2 = nextROC0;
}
}

--- In amibroker@yahoogroups.com, "slamming26_11" <[EMAIL PROTECTED]> 
wrote:
>
> r1 = Param( "Fast avg", 12, 2, 200, 1 );
> r2 = Param( "Slow avg", 26, 2, 200, 1 );
> r3 = Param( "Signal avg", 9, 2, 200, 1 );
> mm = MACD(r1, r2);
> ms = Signal(r1, r2, r3);
> UpCrossover = Cross( mm, ms );
> DownCrossover = Cross( ms, mm);
> IIf( mm > ms, DownCrossover, UpCrossover );
> ValueWhen( DownCrossover, Ref(C,1));
> ValueWhen( UpCrossover, Ref(C,1));
> MACDPredictor = ValueWhen( DownCrossover, Ref(C, 1)) OR
> ValueWhen( UpCrossover, Ref(C,1));
> Plot(MACDPredictor,"",4);
> 
> The above code is a my feeble attempt to show the very next future 
> closing price that would create a crossover of the mm and ms. 
Please 
> help as I am not experienced with AFL coding.
> 
> Thanks.
> 
> George
>


Reply via email to