This is where the idea came from to use Relative Performance of only certain 
criteria.
The way I use this code is to run a Scan on all stocks creating sector and 
industry composites. Then plot as indicator, which plots a nice bull bear based 
on MACD of the ticker's sector and industry.

_SECTION_BEGIN("BullBearMACD_ALLSectors");
/*MACD BULL-BEAR*/
SIDnum = SectorID(0);
SIDname = SectorID(1);

ob=Signal()<MACD();
os=Signal()>=MACD();
values5 = os>0;
values6 = ob>0;
MACDBearName = "~s" + SIDnum + "-" + StrLeft(SIDname,10) + "-" + "MACDBear";
MACDBullName = "~s" + SIDnum + "-" + StrLeft(SIDname,10) + "-" + "MACDBull";
AddToComposite(Values5,MACDBearName,"V",2 + 16);
AddToComposite(Values6,MACDBullName,"V",2 + 16);

Buy=0;
Filter = 1;
AddColumn(Values5, "Bear");
AddColumn(Values6, "Bull");

/*graph of bull and bear for Indicator Builder*/ 
bear = Foreign("~s" + SIDnum + "-" + StrLeft(SIDname,10) + "-" + 
"MACDBear","V");
bull = Foreign("~s" + SIDnum + "-" + StrLeft(SIDname,10) + "-" + 
"MACDBull","V");

Bears =100*bear/(bull+bear);
Bulls =100*bull/(bull+bear);
Plot(Bears,"Bears",colorRed,styleDots | styleDashed);
Plot(Bulls,"Bulls",colorGreen,styleDots | styleDashed);

Title="MACDsector - " +"BEAR= "+WriteVal(Graph1,1.1)+"% ("
+WriteVal(Ref(Graph1,-1),format=1.1)+") , BULL= "+
WriteVal(Graph0,1.1)+"% ("+WriteVal(Ref(Graph0,-1),format=1.1)+")";
_SECTION_END();

_SECTION_BEGIN("BullBearMACD_ALLIndustrys");
/*MACD BULL-BEAR*/
IIDnum = IndustryID(0);
IIDname = IndustryID(1);

ob=Signal()<MACD();
os=Signal()>=MACD();
values5 = os>0;
values6 = ob>0;
MACDBearName = "~i" + IIDnum + "-" + StrLeft(IIDname,10) + "-" + "MACDBear";
MACDBullName = "~i" + IIDnum + "-" + StrLeft(IIDname,10) + "-" + "MACDBull";
AddToComposite(Values5,MACDBearName,"V",2 + 16);
AddToComposite(Values6,MACDBullName,"V",2 + 16);

Buy=0;
Filter = 1;
AddColumn(Values5, "Bear");
AddColumn(Values6, "Bull");

/*graph of bull and bear for Indicator Builder*/ 
bear = Foreign("~i" + IIDnum + "-" + StrLeft(IIDname,10) + "-" + 
"MACDBear","V");
bull = Foreign("~i" + IIDnum + "-" + StrLeft(IIDname,10) + "-" + 
"MACDBull","V");

Bears =100*bear/(bull+bear);
Bulls =100*bull/(bull+bear);
Plot(Bears,"Bears",colorRed,styleLine|styleThick);
Plot(Bulls,"Bulls",colorGreen,styleLine|styleThick);

Title="MACD_Sec_Ind - " +"BEAR = "+WriteVal(Graph3,1.1)+"% ("
+WriteVal(Ref(Graph3,-1),format=1.1)+") , BULL = "+
WriteVal(Graph2,1.1)+"% ("+WriteVal(Ref(Graph2,-1),format=1.1)+")";

_SECTION_END();



Reply via email to