Welcome Features News Download Registration Support FAQ Wish list Links
Advanced stock charting and analysis program

AFL Library

This is read-only version of AFL library entry. Ability to add user formulas and comment is only available from members-only area.

Details:

Formula name: William's Alligator System II
Author/Uploader: TohMz - TohMz [at] yahoo.com
Date/Time added: 2008-06-09 18:33:55
Origin: http://www.amibroker.com/library/detail.php?id=100, by Steve Wiser - slwiserr@erols.com
Keywords: Alligrator
Level: semi-advanced
Flags: system,exploration

DISCLAIMER: Most formulas present in AFL on-line library are submitted by the users and are provided here on an "as is" and "as available" basis. AmiBroker.com makes no representations or warranties of any kind to the contents or the operation of material presented here. We do not maintain nor provide technical support for 3rd party formulas. If you believe that formula has an error - contact the AUTHOR directly, not us. If you believe that you have copyright on that work (i.e. you have written this particular code yourself) please send us proper DMCA takedown notice. Please note that mathematical ideas/concepts can not be copyrighted, only actual AFL code if you wrote it yourself.

Description:

To get a real picture of this go to the web site
www.profitunity.com and download the demo software
Investors Dream and see how this code compares.

You really need to read the book to get a picture of
what is going on. This is a good read. You can
get the Williams books on his web site as will. You
only need the latest one.

Formula:

/*
   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 [at] 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");

/*
   Buy:  Scan stocks only breakout..maxbreakout (1~30%, default) and Trend is
bullish
   Sell: Scan stocks only breakout..maxbreakout (1~30%, default) and Trend is
bearish

*/
//== Price Increment Value - depend on different country
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(); 

Comments:

Crash
crashandburn59 [at] hotmail.com
2008-06-09 18:35:23
Fractals require looking 2 days into the future.

Replace:

Plot(UpFractal, "Up Fractal", ParamColor("Up Fractal Color",colorRed),
ParamStyle("Up Fractal Style", styleDashed));
Plot(DownFractal, "Down Fractal",ParamColor("Down Fractal Color",colorBlue),
ParamStyle("Down Fractal Style", styleDashed));

with

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


Regards,
Crash.
Crash
crashandburn59 [at] hotmail.com
2008-06-09 18:36:44
This is better visually for displaying the formation of Fractals:

Plot(Max(HHV(H,3),Ref(UpFractal,2)) , "Up Fractal" ,33, styleLine);
Plot(Min(LLV(L,3),Ref(DownFractal,2)), "Down Fractal",33, styleLine);
TohMz

2008-06-09 18:39:20
Hi Crash,

Thank for your genius solution for my long wanted to solve problem. I adopt it and re-script as above.
Ernest

2008-06-12 22:05:49
Hi,

I'm new to the Amibroker....... I have a request if someone doesn't mind helping me. I would appreciate very much. I've surf the internet for weeks but no success. I would like a scan or exploration which can find any futures or stock that has reached its 20,30,52 or any number of weeks hi or low by changing the weekly variable.

Thank You
Crash
crashandburn59 [at] hotmail.com
2008-06-13 00:38:18
LBP = Param("Look back Period in Weeks", 10,1,100,1); // Look Back Period in Weeks

NewHigh = High > Ref(HHV(H,LBP*5),-1);
NewLow = Low < Ref(LLV(L,LBP*5),-1);

xx = WriteIf (NewHigh, "High", WriteIf(NewLow, "Low",""));

Filter = NewHigh OR NewLow;

AddColumn( Close, "Close",8.3,1,2,50);
AddTextColumn( xx, "New High / Low", 1.2,1,2,100);
MR

2008-10-20 16:12:17
Please help, i can't fix the problem:
Error 29:
Variable 'a' used without having been initialized
???
Thank you in advance
TohMz

2008-10-30 09:15:52
Hi,
Did not see any error in my version

// Try to add this statement:

A=C;

// before the following:

P= ParamList(\"Price\", \"Close|(H+L)/2|(H+C+L)/3\",1);
Deepinder Singh
dsetia [at] yahoo.com
2008-11-21 16:12:15
How do I access the fractal one before the last one? Ref(UpFractal, -1) does not work as it also returns the last value. In fact referencing multiple bars in the past all return the same value which is the last fractal. For example if UpFractals are 1, 2, 3, 4 etc but are seperated by multiple days in between, how can I tell how many days apart and then how to access the UpFractal array to retrieve them?
Paul Bailey
pmbailey4 [at] cox.net
2008-11-28 18:24:56
Can anyone help? I get a syntax error at line 80, col. 6, Error 30
William

2008-12-04 06:33:53
Hi,

syntax error at line 80, col. 6, Error 30
likely is copy and paste issue that you cause the
error near below :

/*
Buy: Scan stocks only breakout..maxbreakout (1~30%, default) and Trend is
bullish
==> Sell: Scan stocks only breakout..maxbreakout (1~30%, default) and Trend is
bearish

*/

Recopy the script again or remove the above remarked statement and see
Simon King

2008-12-04 06:39:26
Hi Deepinder Singh,

-4 -3 -2 -1 0
=============
^ ^
| |___ Current Day
|_____ Previous 1 day
........................

Paul Bailey
pmbailey4 [at] cox.net
2008-12-04 21:06:16
Thanjs William for trying. The syntax error happens a couple of lines above the code you wrote in your e-mail. It is on this line: //Plot(Max(HHV(H,3),Ref(UpFractal,2)), \"Up Fractal\", ParamColor(\"Up Fractal Color\",colorRed), ParamStyle(\"Up Fractal Style\", styleDashed));
Starting at Color,\"

Hope you can help with this explanation.
William

2008-12-18 07:35:57
The following causes was due to there is no downloading script for you.
When the author upload the code, the display had
had change the display as below:


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

The // is means remark.
it suppose to remark the whole paragraph till ... ));

what you need to do is as below

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

or remove the above.
Don
donaldschuman [at] msn.com
2011-06-26 14:55:54
Does anyone have this indicator with all of the suggested changes/updates?

I\'m not good enough at programming to incorporate them and don\'t want to mess it up.

Thanks


About | Privacy | Terms of Use | Contact information
Copyright © 2001 AMIBROKER.COM