- Katılım
- 23 Eki 2020
- Mesajlar
- 1,826
BATS ( Beta-Adjusted Stop Loss ) for Amibroker (AFL)
Beta is a measure of the volatility of a stock compared with an index or average. Beta Adjusted Trailing Stop (BATS) was introduced in an article for Technical Analysis of Stocks & Commodities magazine in January 1997 by Thomas Bulkowski.Ref: http://traders.com/documentation/feedbk_docs/1997/01/Abstracts0197/0197Bulkowski.html
By using Kaufman’s technique, Bulkowski computed the average daily high-low price range for the prior month, multiply by 2, and then subtract the result from the current low price. ( details here http://thepatternsite.com/stops.html )
Note: Higher-beta stocks have larger price declines compared with lower-beta stocks and require a larger stop-loss percentage to compensate for the increased volatility. A beta of 1.50 means that a stock tends to rise or fall 50% more than the ref Index.
Kod:
// Downloaded From https://www.WiseStockTrader.com
_SECTION_BEGIN("BATS");
// Ref: http://thepatternsite.com/stops.html & http://thepatternsite.com/stops.html
// compute the average daily high-low price range for the prior month, multiply by 2, and then subtract the result from the current low price.
dif=Ref(High,0)-Ref(Low,0);
dif1=Ref(High,-1)-Ref(Low,-1);
dif2=Ref(High,-2)-Ref(Low,-2);
dif3=Ref(High,-3)-Ref(Low,-3);
dif4=Ref(High,-4)-Ref(Low,-4);
dif5=Ref(High,-5)-Ref(Low,-5);
dif6=Ref(High,-6)-Ref(Low,-6);
dif7=Ref(High,-7)-Ref(Low,-7);
dif8=Ref(High,-8)-Ref(Low,-8);
dif9=Ref(High,-9)-Ref(Low,-9);
dif10=Ref(High,-10)-Ref(Low,-10);
dif11=Ref(High,-11)-Ref(Low,-11);
dif12=Ref(High,-12)-Ref(Low,-12);
dif13=Ref(High,-13)-Ref(Low,-13);
dif14=Ref(High,-14)-Ref(Low,-14);
dif15=Ref(High,-15)-Ref(Low,-15);
dif16=Ref(High,-16)-Ref(Low,-16);
dif17=Ref(High,-17)-Ref(Low,-17);
dif18=Ref(High,-18)-Ref(Low,-18);
dif19=Ref(High,-19)-Ref(Low,-19);
dif20=Ref(High,-20)-Ref(Low,-20);
dif21=Ref(High,-21)-Ref(Low,-21);
Sumdif=(dif+dif1+dif2+dif3+dif4+dif5+dif6+dif7+dif8+dif9+dif10+dif11+dif12+dif13+dif14+dif15+dif16+dif17+dif18+dif19+dif20+dif21)/22;
Sumdifml=(Sumdif*1);
Sumdifml2=(Sumdif*1.5);
Sumdifml3=(Sumdif*2);
Betastops=HHV(C,22) - Sumdifml;
Betastops2=HHV(C,22) - Sumdifml2;
Betastops3=HHV(C,22) - Sumdifml3;
bsd=IIf(C>Ref(Betastops3,-1),1,IIf(C<Ref(Betastops3,-1),-1,0));
bsn=ValueWhen(bsd!=0,bsd,1);
colbs = IIf(bsn==1,colorGreen,colorRed);
Plot(Betastops3, "BATS", colbs,ParamStyle("Style2",styleThick,maskAll));
_SECTION_END();
www.WiseStockTrader.com