alexwang7777 發表於 10-6-11 17:56

Bill William's Alligator System II

/*
Bill William's Alligator System II

Reference Website:
==================

http://www.alpari-idc.com/en/market-analysis-guide/chaos-theory/alligator-and-gator.html
Modified from http://www.amibroker.com/library/detail.php?id=100, by Steve Wiser - slwiserr@erols.com
Modified by TohMz on June 9th, 2008
*/
SetChartOptions( 0, chartShowArrows|chartShowDates );

_SECTION_BEGIN("Price Chart");
_N(Title = StrFormat("{{NAME}}- {{INTERVAL}} {{DATE}} O= %g, H= %g, L= %g, C= %g (%.1f%%) V= " +WriteVal( V, 1.0 ) +"\n{{VALUES}}", O, H, L, C, SelectedValue(ROC( C, 1 )) ));
PriceStyle = GetPriceStyle();
PriceStyleOpt = ParamStyle("Price Style")|PriceStyle;

if (PriceStyle==styleCandle)
Plot( C, "", colorBlack, PriceStyleOpt);
else
Plot( C, "", IIf( Close >= Ref(C, -1), colorBlue, colorRed ), PriceStyleOpt);
_SECTION_END();

_SECTION_BEGIN("BW Alligator");
/*** The trend indicators ***/

P= ParamList("Price", "Close|(H+L)/2|(H+C+L)/3",1);

if (P=="Close")
A = C;

else
if (P=="(H+C+L)/3")
A = (H+C+L)/3;
else
A = (H+L)/2;

AlligatorJaw = Ref(Wilders(A,13),-8);
AlligatorTeeth = Ref(Wilders(A,8), -5);
AlligatorLips = Ref(Wilders(A,5), -3);

Plot(AlligatorJaw, "Jaw", ParamColor("Jaw's Color",colorBlue),
ParamStyle("Jaw's Style", styleThick));
Plot(AlligatorTeeth,"Teeth", ParamColor("Teeth's Color",colorRed),
ParamStyle("Teeth's Style", styleThick));
Plot(AlligatorLips, "Lips", ParamColor("Lips's Color",colorGreen),
ParamStyle("Lips's Style", styleThick));

_SECTION_END();


_SECTION_BEGIN("BW Fractal");

UpFractal= ValueWhen(
(Ref(H,-2) > Ref(H, -4)) AND
(Ref(H,-2) > Ref(H, -3)) AND
(Ref(H,-2) > Ref(H, -1)) AND
(Ref(H,-2) > H), Ref(H,-2));

DownFractal= ValueWhen(
(Ref(L,-2) <= Ref(L, -4)) AND
(Ref(L,-2) <= Ref(L, -3)) AND
(Ref(L,-2) <= Ref(L, -1)) AND
(Ref(L,-2) <= L), Ref(L,-2));



//== Added Crash crashandburn59 hotmail.com solution
Plot(Ref(UpFractal,2), "Up Fractal", ParamColor("Up Fractal Color",colorRed),ParamStyle("Up Fractal Style", styleDashed));
Plot(Ref(DownFractal,2), "Down Fractal",ParamColor("Down Fractal Color",colorBlue), ParamStyle("Down Fractal Style", styleDashed));

//Plot(Max(HHV(H,3),Ref(UpFractal,2)), "Up Fractal", ParamColor("Up Fractal Color",colorRed), ParamStyle("Up Fractal Style", styleDashed));
//Plot(Max(HHV(H,3),Ref(UpFractal,2)), "Down Fractal",ParamColor("Down Fractal Color",colorBlue), ParamStyle("Down Fractal Style", styleDashed));

_SECTION_END();



_SECTION_BEGIN("Exploration");

Inc = 0.1;

//== Set the Price Range for stock to scan
PriceFrom = Param("Price From:", 5, 0.1, 200, Inc);
PriceTo = Param("Price To:", 100, 0.1, 200, Inc);
MaxBreakOut = Param("Max Breakout (%)", 5, 1, 30);
MaxBreakOut = MaxBreakOut/100;

Buy = C>UpFractal AND C<=(1+MaxBreakOut)*UpFractal AND
AlligatorTeeth>AlligatorJaw;
Sell = C<DownFractal AND C>=(1-MaxBreakOut)*DownFractal AND
AlligatorTeeth<AlligatorJaw;

Filter = (Buy OR Sell) AND (C>=PriceFrom AND C<=PriceTo) AND V>0;

AddTextColumn(FullName(), "Security", 1.0, colorDefault, colorDefault, 200);
AddTextColumn( WriteIf(Buy,"Buy", WriteIf(Sell, "Sell", "")), "Trade", 1.0);
AddColumn( UpFractal, "Up Fratal");
AddColumn( DownFractal, "Down Fratal");
//AddColumn( MA(V,3)/EMA(V,17), "MAV(3/17)");
AddColumn( C, "Today's Close");


_SECTION_END();

aaqqww93 發表於 10-6-11 19:14

不錯喔謝啦

eclife 發表於 10-9-12 11:21

感謝分享
已經納入收集了

nether 發表於 10-10-7 15:52

本帖最後由 nether 於 10-10-7 04:11 PM 編輯

請問這code要怎麼玩啊?
我backtest這code時 得到下面 errror message:
Missing Short/cover variable assignment:
Check User's guide: Tutoirial: Backtesting your trading idea for the details

請問這是什麼問題? 那裏要設定呢?


謝謝

allen0925 發表於 10-10-7 16:01

因為這個公式沒有設定空補發生條件 而你backtest有選雙邊回測吧

nether 發表於 10-10-7 16:14

對 您說對了 現在ok 了
感謝感謝

sjy039 發表於 10-12-27 13:47

感謝大大的分享,收集起來

bbdcd 發表於 11-3-27 04:00

感覺
Alligator System II 可以衡量速度
愈是恐慌所造成的速度愈快,但速度愈快,回到原點的機會就愈高

nivlek 發表於 15-11-6 22:58

Thx!!{:4_90:}{:4_90:}{:4_90:}
頁: [1]
查看完整版本: Bill William's Alligator System II