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

[amibroker] Re: AD Line problem?



PureBytes Links

Trading Reference Links

While you may be able to calculate the AD with the data in AB it 
seems to me that you must have have every stock on the NYSE and 
NASDAQ in your database. There is an easier and probably more 
reliable way but it requires that you get data from an external 
source. http://unicorn.us.com/advdec/ has historical data going back 
to 2002. You have to create a symbol, I use ~NYSE and ~NASD where Adv 
Issues is the open and Dec issues is the close. The higher of these 
goes in High and the lower in Low. The AdvVolume goes in Volume and 
the DecVolume in OpenInterest. Then you calculate the AD line using 
the Open and Close.  The formula for a simple A/D line is below. If 
you want the data I can put it in the Files section. Import it into 
AB. Then you will have to update it manually daily. The data goes 
back to 1965 for nyse and 1978 for nasd.  

Barry

// Advance / Decline Ratio 
// By Barry Scarborough
whichIndex = ParamToggle("Select market", "NASD|NYSE", 0);
if (whichIndex == 0)
{
	index = "~NASD";
   aI 	= Foreign("~NASD", "O"); 
   dI 	= Foreign("~NASD", "C"); 
}
else 
{
	index = "~NYSE";
   aI 	= Foreign("~NYSE", "O"); 
   dI 	= Foreign("~NYSE", "C"); 
}

ad = aI / dI; 

Plot(ad , index + " A/D Issues Ratio Daily",  colorRed) ;	
Plot(1,"",colorBlue);
Plot(aI, "\nUp", colorGreen, styleNoLine | styleOwnScale);
Plot(dI, "\nDown", colorGreen, styleNoLine | styleOwnScale);
Plot(ai-di, "\nDelta", colorBlue, styleNoLine | styleOwnScale);

--- In amibroker@xxxxxxxxxxxxxxx, "areehoi" <areehoi@xxx> wrote:
>
> Have any of you been successful in using the "ADLine" indicator?  
This
> is a built in indicator that comes with Amibroker.  To us it one 
needs
> to go to the "Composites recalculation tool" that can be found under
> >Symbol -> Categories Menu.  Follow the instructions (implicitly) 
and
> one is supposed to get the A/D line.  I've never had any luck using
> this.  If anyone has had success let me know how accomplished.
> As an alternate I latched onto the follow program (AFL) that is
> supposed to calculate both the Advances/Declines and Hi/Lows. It 
seems
> to work for the N100 but when expanded to the NYSE and Nasdaq 
markets
> I've had problems. My programming skill are primarily "copy and 
paste"
> so I would be most appreciative if someone knowledgeable would look 
at
> it and see what need to be changed for it to work properly.  Thanks
> 
> Dick H. 
> 
> // Develops 4 composites that can be plotted or manipulated as you 
wish
> // How to Run
> // 1) Build a composite of NYSE AND NASDQ stocks
> // 2) Select an issue with a long history in the current ticker 
window
> // 3) Set APPLY TO to use filter Market NYSE or NASDQ
> // 4) Set RANGE to one bar... 1 n last quotations
> // 5) Press SCAN
> 
>  //===================52 Week New
> NewLows==================================
> _SECTION_BEGIN("NewHINewLO");
> Title="NewhighNewlow";
> 
> 
> NYSE = "~" + MarketID(1);
> NASDQ = "~" + MarketID(3);
> Newhigh=IIf(H>Ref(H,-1),Ref(H,250),0);
> Newlow=IIf(L<Ref(L,-1),Ref(L,250),0);
> 
> AddToComposite(IIf(C > HHV(Ref(C, -1), 250), 
1,0), "~NYSENewHi", "X");
> AddToComposite( 1, "~NYSENewHi", "I" );//add one to open interest
> field,use this field as a counter
> AddToComposite(IIf(C < LLV(Ref(C, -1), 250), 
1,0), "~NYSENewLo", "X");
> AddToComposite( 1, "~NYSENewLo", "I" );
> AddToComposite(IIf(C > HHV(Ref(C, -1), 250), 
1,0), "~NASDQNewHi", "X");
> AddToComposite( 1, "~NASDQNewHi", "I" );
> AddToComposite(IIf(C < LLV(Ref(C, -1), 250), 
1,0), "~NASDQNewLo", "X");
> AddToComposite( 1, "~NASDQNewLo", "I" );
> 
> 
> NewHigh=Foreign("~NYSENHi","X");
> NewLow = Foreign("~NYSENLo","X");
> NewHigh=Foreign("~NASDQNHi","X");
> NewLow = Foreign("~NASDQNLo","X");
> 
> tgl = ParamToggle("Select MKT", "NYSE|NASDQ", 0);
> 
> if (!tgl)
> 
> {
> 
>     MKT = "NYSE|NYSE";
> 
> }
> 
> else
> 
> {
> 
>     MKT = "NASDQ|NASDQ";
> 
> } 
> 
> //Opt_H_L=Optimize("Opt_H_L",43,20,50,1);
> //Opt_A_D=Optimize("Opt_A_D",12,10,30,1);
> 
> Opt_H_L=30;
> Opt_A_D=5;
> 
> DIFF_H_L = NewHigh-NewLow;
> MADiff_H_L=MA(Diff_H_L,Opt_H_L);
> Plot(NewHigh,"NewHigh",colorGreen,styleLine);
> Plot(NewLow,"NewLow",colorRed,styleLine);
> Plot(MADiff_H_L,"MADiff_H_L",colorDarkYellow,styleLine);
> 
> MA_H_L=Ref(MADiff_H_L,0);
> MA_H_L1=Ref(MADiff_H_L,-1);
> MA_H_L3=Ref(MADiff_H_L,-3);
> MA_H_L4=Ref(MADiff_H_L,-5);
> Rising_H_L=MA_H_L>MA_H_L1 AND MA_H_L>MA_H_L3 AND MA_H_L>MA_H_L4 ;
> 
> //===================Advance/Decline Issues
> AddToComposite(IIf(C - Ref(C, -1) > 0, 1,0), "~NYSEAdv", "X" );
> AddToComposite(IIf(Ref(C, -1) - C > 0, 1,0), "~NYSEDec", "X" );
> AddToComposite(IIf(C - Ref(C, -1) > 0, 1,0), "~NASDQAdv", "X" );
> AddToComposite(IIf(Ref(C, -1) - C > 0, 1,0), "~NASDQDec", "X" );
> 
> Adv = Foreign("~NYSEAdv","X");
> Dec = Foreign("~NYSEDec","X");
> Adv = Foreign("~NASDQAdv","X");
> Dec = Foreign("~NASDQDec","X");
> 
> DIFF_A_D = Adv-Dec;
> MADiff_A_D = MA(Diff_A_D,Opt_A_D);
> Plot(Adv,"Adv",colorBlack,styleThick);
> Plot(Dec,"Dec",colorBrown,styleThick);
> Plot(MADiff_A_D,"MADiff_A_D",colorPlum,styleLine);
> MA_A_D = Ref(MADiff_A_D,0);
> MA_A_D1 = Ref(MADiff_A_D,-1);
> MA_A_D3 = Ref(MADiff_A_D,-3);
> MA_A_D4 = Ref(MADiff_A_D,-5);
> Rising_A_D = MA_A_D > MA_A_D1 AND MA_A_D > MA_A_D3 AND MA_A_D > 
MA_A_D4;
> Buy=Cover=Rising_A_D==True AND Rising_H_L==True; 
> Sell=Short= Rising_A_D==False AND Rising_H_L==False; 
> 
> Buy=ExRem(Buy,Sell);
> Sell=ExRem(Sell,Buy);
> //PlotShapes( shapeUpArrow * Buy + shapeDownArrow * Sell, IIf (Buy,
> colorGreen, colorRed));
> Bu=Ref(Buy,-1);
> Se=Ref(Sell,-1);
> 
> Filter = C;
> 
> AddColumn(C,"Close",1.2);
> AddColumn(NewHigH,"NewHigh",1.2);
> AddColumn(NewLow,"NewLow",1.2);
> AddColumn(Adv,"Adv",1.2);
> AddColumn(Dec,"Dec",1.2);
> //AddColumn(Rising_A_D,"A_D",1.2);
> //AddColumn(Rising_H_L,"H_L",1.2);
>  
> _SECTION_END();
>




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 NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/

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