amibroker

Home ▸ Knowledge Base

How to detect the divergences

There are many different ways to check for divergences. One of the simplest is to use Rate of change indicator and EXPLORATION feature of Automatic Analysis window:

– Analysis -> Formula Editor
– enter:
 
// 5 day rate of change of close
PriceUp = ROC( C, 5 ) > 0 ;
// 5 day rate of change of MACD histogram
MacdUP = ROC( MACD() - Signal(), 5 ) > 0;
BullishDiv = NOT PriceUP AND MACDUp;
BearishDiv = PriceUP AND NOT MACDUp;
Filter = BullishDiv OR BearishDiv;
AddColumn( BullishDiv, "Bullish Divergence", 1.0,
       
colorDefault, IIf(BullishDiv, colorGreen, colorDefault ) ); 
AddColumn
( BearishDiv , "Bearish Divergence", 1.0,
       
colorDefault, IIf(BearishDiv , colorRed, colorDefault) )

– Tools -> Send to Auto-analysis
– Apply to: All Symbols, N last quotations = 1
– press EXPLORE

Tools -> Send to Auto-analysis- Apply to: All Symbols, N last quotations = 1- press EXPLORE

A different approach can use linear regression instead:
 
// 10 day linear regression slope of close
PriceUp = LinRegSlope( C, 10 ) > 0 ;
// 10 day linear regression slope of MACD histogram
MacdUP = LinRegSlope( MACD() - Signal(), 10 ); 

 

Comments are closed.