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

RE: [amibroker] divergences



PureBytes Links

Trading Reference Links

Ed,

 

IMO, the first issue is to define “divergence” specifically.   If you mean that the price value is going up, when the indicator value is going down (or vice versa), one way of defining this is that the “trend” of one is up and “trend” of the other is down.  

 

Assuming that is what you want, then there is two ways of defining “trend” that I know of:

 

·         Defining points in time to measure from (E.g. 10 days back versus now), or

·         Linear Regression comparison.

 

The points in time works, but I like the Linear Regression approach better.  Below is a portion of a scan that I use to scan for Short Term changes in CMF and OBV in one direction while the Short Term price is headed in the opposite direction.

 

Note that the CMF code was provided by other members of this forum.

 

I hope this helps.

 

Regards,

 

Dan.   

 

//This script uses both CMF AND OBV divergences.

 

//Parameters

ShortTermLR_NumPeriods  =  Param( "LR Periods - Short", 21, 2, 255, 1 );

LongTermLR_NumPeriods   =  Param( "LR Periods - Long", 65, 2, 255, 1 );

LookBackPeriod          =  Param( "Look Back Period", 0, 0,  30, 1); 

VolumeNumPeriods        =  Param( "Volume Periods", 10, 1, 100, 1 );

LTRateOfChangePeriods   =  Param( "Long Term ROC Periods", 122, 1, 355, 1);

 

 

//LT ROC

LongTermROC          =  ROC(Close,LTRateOfChangePeriods);

 

//CMF Code       

CMFP = Param(" Chaikin MFI Period", 21,3,89,1);

CMFI = Sum(((( C-L )-( H-C )) / ( H-L ))*V, CMFP ) / Sum(V,CMFP);

CMFI = Prec(CMFI, 2) ;

 

// Other Criteria

AvgVolumeValue             =  MA(V, VolumeNumPeriods);

 

CMFLRSlope           =  LinRegSlope(Ref(CMFI , LookBackPeriod ), ShortTermLR_NumPeriods );

OBVLRSlope           =  LinRegSlope(Ref(OBV(), LookBackPeriod ), ShortTermLR_NumPeriods );

PriceLRSlope         =  LinRegSlope(Ref(C    , LookBackPeriod ), ShortTermLR_NumPeriods );

PriceLongTermLRSlope =  LinRegSlope(Ref(C    , LookBackPeriod ), LongTermLR_NumPeriods  );

 

Buy =       PriceLRSlope            <  0 

      AND   PriceLongTermLRSlope    >  0 

      AND   CMFLRSlope              >  0 

      AND   CMFI                    >  0 

      AND   LongTermROC             >  0 

;                                     

Sell =      PriceLRSlope            >  0 

      AND   PriceLongTermLRSlope    <  0 

      AND   OBVLRSlope              <  0 

      AND   CMFLRSlope              <  0 

      AND   LongTermROC             <  0 

;


From: amibroker@xxxxxxxxxxxxxxx [mailto:amibroker@xxxxxxxxxxxxxxx] On Behalf Of Ed
Sent: Friday, September 02, 2005 9:25 AM
To: amibroker@xxxxxxxxxxxxxxx
Subject: [amibroker] divergences

 

Does anyone know how to write code that shows divergences between an
indicator (RSI, Stochastics, MACD) and price over a period of time?
I'm hoping to save myself a lot of time manually searching for
indicator/price divergences through code. Thanks, Ed





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 other support material please check also:
http://www.amibroker.com/support.html





YAHOO! GROUPS LINKS