Zweig Breadth Thrust Indicator (Amibroker Code)

 

The strategy in plain English:

  1. Today’s reading must be at least 0.615.
  2. At any time during the last ten days, the reading must have been less than 0.4.
  3. If 1 and 2 are true, we buy the close and sell x days later.

Amibroker code:

oddis=Optimize(“days”,5,5,50,5);

AdvancingIssues=Foreign(“NY-adv-issues”,”Close”,fixup=1);
DecliningIssues=Foreign(“NY-decl-issues”,”Close”,fixup=1);
Breadth = AdvancingIssues / ( AdvancingIssues + DecliningIssues );
Zweig=MA(Breadth,10);

Buy = Zweig>0.615 AND Ref(LLV(zweig,10),-1)<0.4;
buyPrice = Close;
Sell = 0 ;
sellPrice = Close;

applyStop(stopTypeNBar,stopModeBars,oddis,1);