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

[amibroker] Sector Industry Indicator Code



PureBytes Links

Trading Reference Links

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();





------------------------------------

**** IMPORTANT PLEASE READ ****
This group is for the discussion between users only.
This is *NOT* technical support channel.

TO GET TECHNICAL SUPPORT send an e-mail directly to 
SUPPORT {at} amibroker.com

TO SUBMIT SUGGESTIONS please use FEEDBACK CENTER at
http://www.amibroker.com/feedback/
(submissions sent via other channels won't be considered)

For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/

Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/amibroker/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/amibroker/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:amibroker-digest@xxxxxxxxxxxxxxx 
    mailto:amibroker-fullfeatured@xxxxxxxxxxxxxxx

<*> To unsubscribe from this group, send an email to:
    amibroker-unsubscribe@xxxxxxxxxxxxxxx

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/