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

[amibroker] Code help for % stocks at 30 week hi / lo



PureBytes Links

Trading Reference Links



Hello,
I'm trying to create an indicator that plots the % of stocks at their 30 week hi or 30 week lows.  I pulled the basic idea from the AFL library, but wanted to implement the new timeframe functions.
However, I'm missing something as I can't seem to get the calculations and corresponding plots to work correctly.  Also, is there an easier way of caclulating the % of hi /lo than ATC.  Seems to work fine, but I'm certain to forget updating some ATC symbols as I add more ATC functionality to my indicators.
Thanks.  Code below.
//ESTABLISH PARAMATERS
NUMWEEKS = Param("# WEEKS",30,1,500,1);
TimeFrameSet(inWeekly);
NEWHI = C > Ref(HHV(High,NUMWEEKS),-1);
NEWLO = C < Ref(LLV(Low,NUMWEEKS),-1);
CHECKOK = NEWHI - NEWLO;
AddToComposite(IIf(CHECKOK == 1,NEWHI,0),"~WEEKHI","X",atcFlagDefaults|atcFlagEnableInExplore);//Num WEEKLY HI
AddToComposite(IIf(CHECKOK == 1,NEWLO,0),"~WEEKLO","X",atcFlagDefaults|atcFlagEnableInExplore);//Num WEEKLY LO
AddToComposite(1,"~WEEKHILOCOUNTER","OI",atcFlagDefaults|atcFlagEnableInExplore); //RETURNS TOTAL # SYMBOLS SCANNED
TimeFrameRestore();
SetForeign("~WEEKHI");
WEEKHI = TimeFrameExpand(C,inWeekly,expandFirst);
SetForeign("~WEEKLO");
WEEKLO = TimeFrameExpand(C,inWeekly,expandFirst);
SetForeign("~WEEKHILOCOUNTER");
WEEKCOUNTER = TimeFrameExpand(OI,inWeekly,expandFirst);
RestorePriceArrays();
HIRATIO = WEEKHI / WEEKCOUNTER;
LORATIO = WEEKLO / WEEKCOUNTER;
COUNT = WEEKCOUNTER;
Filter = 1;
AddColumn(HIRATIO,"HI RATIO",8.2);
AddColumn(LORATIO,"LO RATIO",8.2);
AddColumn(COUNT,"COUNT",8.2);
Plot(HIRATIO,"% STOCKS MAKING " + WriteVal(NUMWEEKS,8.0) + " WEEKLY HI",colorBrightGreen,styleLine|styleThick);
Plot(LORATIO,"% STOCKS MAKING " + WriteVal(NUMWEEKS,8.0) + " WEEKLY LO",colorRed,styleLine|styleThick);
Plot(COUNT,"# STOCKS SAMPLED",colorAqua,styleLine|styleThick);
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software






Yahoo! Groups Sponsor


  ADVERTISEMENT 









Send BUG REPORTS to bugs@xxxxxxxxxxxxx
Send SUGGESTIONS to suggest@xxxxxxxxxxxxx
-----------------------------------------
Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx 
(Web page: http://groups.yahoo.com/group/amiquote/messages/)
--------------------------------------------
Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html



Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.