Laman

Monday, April 15, 2013

AFL ALLIGATOR FOR FREE-Brightspark Swing Volume Tool

1:  /*    Ord Volume by Peter Bjarheim  
2:        Rev - 11-12-07  
3:       Adjust "zig percent change" so that each swing last from 5 to 30 days   
4:       (the the percentage, the more sigificant the swing is).  
5:       Peak Volume Extreme Detection:  
6:             ->Sometimes several days around the true swing price extreme, a higher volume  
7:  extreme has been encountered.   
8:            Back testing suggests that these swing volumes while rare, do occur and are  
9:  significant.  
10:  ---->     Rules For Trading from http://www.ord-oracle.com/  
11:       This software is designed to pick out the swings in a stock and then measure  
12:  the force between the swings. The  
13:  force is the amount of volume between the swings that pushes the stock in an  
14:  up-mode or down-mode. Stocks trend  
15:  in the direction of the highest volume. Stocks correct or consolidate on  
16:  lighter volume. By measuring the volume  
17:  between the swings and comparing to previous swings, one can "See" the force of  
18:  a particular move developing in the  
19:  stock. In an uptrend the stock should have higher volume on the rally phase  
20:  than the correction phase. In a  
21:  downtrend the stock should have higher volume on the declining phase than the  
22:  up correction phase. With that in  
23:  mind, we have developed this software to do just that. Keep in mind that this  
24:  software measures volume force in a  
25:  stock and is not implied to be a stand-alone tool to pick every turn in a  
26:  stock. The Ord-volume software is designed  
27:  to help identify the probable direction by the volume flow the stock has. Other  
28:  factors of the stock may push it in a  
29:  different direction.  
30:  1. To pick the strongest stock (in up-trend), average daily volume should  
31:  shrink near 50% on correction phase  
32:  compared to the rally phase.  
33:  2. To pick the weakest stocks (in down-trend) average daily volume should  
34:  shrink near 50% on up phase compared to  
35:  the declining phase.  
36:  Definition of a "Swing". A "Swing" is a price high or low where the stock  
37:  changes direction.  
38:  Definition of "Ord-Volume". "Ord-volume" measures the average volume between  
39:  "Swings".  
40:  Definition of "Ord-Volume Low". "Ord-Volume Low" is a down-leg in a stock.  
41:  Definition of "Ord-Volume High". "Ord-Volume High" is an up-leg in a stock.  
42:  3. A buy signal is triggered when a stock closes above a previous important  
43:  "Ord-Volume low" where the current  
44:  "Ord-volume low" shrinks near 50% or greater against the "Important "Ord-volume  
45:  low"". An "Important  
46:  "Ord-volume Low" is when that low marks a bottom where the equity starts a  
47:  sideways consolidation.  
48:  4. A sell signal is triggered when a stock closes below a previous important  
49:  "Ord-Volume High" where the current  
50:  "Ord-Volume High" shrinks near 50% or greater against the "Important  
51:  "Ord-Volume High"". An "Important  
52:  "Ord-Volume High"" is when that high marks a top where the equity starts a  
53:  sideways consolidation.  
54:  5. Target price Projections:  
55:       5.1 An upside target for a buy signal will be the previous "Swing High". If  
56:  volume is equal or greater on the test of the  
57:        previous high then the next higher swing high will be the target and so on.  
58:       5.2 A downside target after a sell signal will be the previous "Swing Low". If  
59:  volume is equal or greater than the  
60:       previous "Swing Low" then the next lower swing will be the target and so on.  
61:  */  
62:  swingDays = 0;  
63:  swingVol = 0;  
64:  ordVol = 0;  
65:  upswingSignal = 0;  
66:  downswingSignal = 0;  
67:  accumulatedVolume = 0;  
68:  accumulatedDays = 0;   
69:  arrayHasSignal = 0;  
70:  zigPercentage = Param("ZigZag Percent", 10, 2, 50);  
71:  trendZig = Zig(C, zigPercentage);   
72:  action = Status("action");  
73:  midPointY = 0;  
74:  midPointValue = 0;  
75:  peakVolumeExtremeDetectionDays = Param("Peak Vol. Days", 6, 1, 20); //3 days  
76:  before and 3 days after a peak  
77:  daysBeforeAndAfterForPeakVolume = round(peakVolumeExtremeDetectionDays/2);  
78:  peakVolume = 0;  
79:  colorOrdVolume = ParamColor("Ord Vol. Info.", colorGrey50);  
80:  colorZig = ParamColor("ZigZag", colorGold);  
81:  colorPeakUp = ParamColor("Support Info.", colorGreen);  
82:  colorPeakDown = ParamColor("Resistance Info.", colorRed);  
83:  scalingFactor = 0.1;  
84:  function volumeInMillions(inVolume)  
85:  {  
86:       volInM = inVolume/1000000;  
87:       return NumToStr(volInM, 1.2, False) + " m";  
88:  }  
89:  function getPeakVolume(daysToCheck, nowDay)  
90:  {  
91:       returnPeakVolume = V[nowDay];  
92:       dayNumberBefore = (nowDay) - daysToCheck;  
93:       dayNumberAfter = (nowDay) + daysToCheck;  
94:       //find Max swing Volume  
95:       if( dayNumberBefore > 0 AND dayNumberAfter < BarCount )  
96:       {  
97:            returnPeakVolume = V[dayNumberBefore];  
98:            //_TRACE("Start returnPeakVolume = " + returnPeakVolume);  
99:            for( j = dayNumberBefore; j < dayNumberAfter; j++ )  
100:            {  
101:                 if(returnPeakVolume < V[j])  
102:                 {  
103:                      returnPeakVolume = V[j];  
104:                 }   
105:                 //_TRACE("returnPeakVolume = " + returnPeakVolume);  
106:            }  
107:       }  
108:       else if( dayNumberBefore > 0 AND dayNumberAfter >= BarCount )  
109:       {  
110:             returnPeakVolume = V[dayNumberBefore];  
111:            //_TRACE("Start returnPeakVolume = " + returnPeakVolume);       
112:            for( j = dayNumberBefore; j < BarCount; j++ )  
113:            {  
114:                 if(returnPeakVolume < V[j])  
115:                 {  
116:                      returnPeakVolume = V[j];  
117:                 }  
118:                 //_TRACE("returnPeakVolume = " + returnPeakVolume);                 
119:            }  
120:       }  
121:       else   
122:       {  
123:            peakVolume = V[i-1];  
124:       }  
125:       return returnPeakVolume;  
126:  }  
127:  for( i = 3; i < BarCount; i++)  
128:  {  
129:  //initialize parameters  
130:       arrayHasSignal[i] = 0;  
131:  //Then we check which way the price goes  
132:       swingVol = swingVol + V[i-1];//Don't add today since price may have changed  
133:  direction  
134:       swingDays = swingDays + 1;  
135:       if( (trendZig[i] < trendZig[i-1]) AND (trendZig[i-1] > trendZig[i-2]) AND i >  
136:  10 )//Changes from up swing to down swing  
137:       {  
138:            /*_TRACE("Changes from up swing to down swing, i = " + i);  
139:            _TRACE("trendZig[i-2] = " + trendZig[i-2]);  
140:             _TRACE("trendZig[i-1] = " + trendZig[i-1]);  
141:            _TRACE("trendZig[i] = " + trendZig[i]);*/  
142:            downswingSignal[i-1] = 0;  
143:            upswingSignal[i-1] = 1;  
144:            ordVol[i-1] = swingVol/swingDays;       
145:            accumulatedVolume[i-1] = swingVol;  
146:            accumulatedDays[i-1] = swingDays;   
147:            arrayHasSignal[i-1] = 1;  
148:            if(action == actionIndicator)  
149:            {  
150:                 midPointValue = i - round(swingDays/2) - 1;  
151:                 midPointY = trendZig[midPointValue];  
152:                 peakVolume = getPeakVolume(daysBeforeAndAfterForPeakVolume, i - 1);  
153:                 PlotText("(" + volumeInMillions(ordVol[i-1]) + ")", midPointValue,  
154:  midPointY, colorOrdVolume);  
155:                 PlotText(NumToStr(H[i-1], 1.1, False) + " (" + volumeInMillions(peakVolume)  
156:  + ")", i-4, trendZig[i-1] * 1.02, colorPeakUp);  
157:            }  
158:            swingVol = 0;  
159:            swingDays = 0;  
160:       }  
161:       if( (trendZig[i] > trendZig[i-1]) AND (trendZig[i-1] < trendZig[i-2]) AND i >  
162:  10 )//Changes from down swing to up swing  
163:       {  
164:             downswingSignal[i-1] = 1;  
165:            upswingSignal[i-1] = 0;  
166:            ordVol[i-1] = swingVol/swingDays;  
167:            accumulatedVolume[i-1] = swingVol;  
168:            accumulatedDays[i-1] = swingDays;   
169:            arrayHasSignal[i-1] = 1;  
170:            if(action == actionIndicator)  
171:            {  
172:                 midPointValue = i - round(swingDays/2) - 1;  
173:                 midPointY = trendZig[midPointValue];  
174:                 peakVolume = getPeakVolume(daysBeforeAndAfterForPeakVolume, i - 1);  
175:                 PlotText("(" + volumeInMillions(ordVol[i-1]) + ")", midPointValue,  
176:  midPointY, colorOrdVolume);  
177:                 PlotText(NumToStr(L[i-1], 1.1, False) + " (" + volumeInMillions(peakVolume)  
178:  + ")", i-4, trendZig[i-1] * 0.95, colorPeakDown);  
179:            }       
180:            swingVol = 0;  
181:            swingDays = 0;  
182:       }  
183:       if( i == BarCount - 1)//add last signal too  
184:       {  
185:            swingVol = swingVol + V[i];//Remember to add today also  
186:            swingDays = swingDays + 1;  
187:            if(trendZig[i] < trendZig[i-1])//is down swing  
188:            {  
189:                 downswingSignal[i] = 1;  
190:                  upswingSignal[i] = 0;  
191:                 ordVol[i] = swingVol/swingDays;       
192:                 accumulatedVolume[i] = swingVol;  
193:                 accumulatedDays[i] = swingDays;   
194:                 arrayHasSignal[i] = 1;  
195:            }  
196:            if(trendZig[i] > trendZig[i-1])//is up swing  
197:            {  
198:                 downswingSignal[i] = 0;  
199:                 upswingSignal[i] = 1;  
200:                 ordVol[i] = swingVol/swingDays;  
201:                 accumulatedVolume[i] = swingVol;  
202:                 accumulatedDays[i] = swingDays;   
203:                 arrayHasSignal[i] = 1;  
204:            }  
205:            if(action == actionIndicator)  
206:            {  
207:                 midPointValue = i - round(swingDays/2) - 1;  
208:                 midPointY = trendZig[midPointValue];   
209:                 PlotText("(" + volumeInMillions(ordVol[i]) + ")", midPointValue, midPointY,  
210:  colorOrdVolume);  
211:            }  
212:       }  
213:  }  
214:  if(action == actionExplore)  
215:  {  
216:       //Filter = 1;  
217:       Filter = arrayHasSignal;  
218:       //AddColumn(trendZig , "trendZig ", 1.2);  
219:       AddColumn(C, "Swing Up", 1.2, colorDefault, IIf(upswingSignal, colorPeakUp,  
220:  colorDefault));  
221:       AddColumn(C, "Swing Down", 1.2, colorDefault, IIf(downswingSignal,  
222:  colorPeakDown, colorDefault));  
223:       AddColumn(ordVol, "Ord Vol.", 1.0);  
224:       AddColumn(accumulatedDays, "Swing Days", 1.0);  
225:       AddColumn(accumulatedVolume, "Tot. Swing Vol.", 1.0);  
226:  }  
227:  else if(action == actionIndicator)  
228:  {  
229:       Plot(trendZig, "Ord Vol ZigZag", colorZig);  
230:       //Scale the axis so we can read the numbers  
231:       Plot(trendZig + (trendZig * scalingFactor), "", colorRed, styleNoDraw);  
232:       Plot(trendZig - (trendZig * scalingFactor), "", colorBlue, styleNoDraw);  
233:  }  
234:  ///////////////selesai//////////////////////////// 
 
sumber http://amibrokerindonesia.blogspot.com/2010/02/re-komunitas-amibroker-afl-alligator_02.html 

AFL Alligator Trading System

1:  //TODO:  
2:  //1. Remember F, AO, AC and Zone Add Ons signals and hits  
3:  //2. Integrate squat bars with exit signals somehow.  
4:  //3. five magic bullets - for taking profit  
5:  //Alligator lines  
6:  //---------------  
7:  //The Blue balance line is where the price would be on this time frame if there were no new incoming information,  
8:  //in other words, the market only moves when there is Chaos present.  
9:  AlligatorBlue=Ref(Wilders(Avg,13),-8);  
10:  Plot(AlligatorBlue, "Jaw", colorDarkBlue, styleLine | styleThick);  
11:  AlligatorRed=Ref(Wilders(Avg,8),-5);  
12:  Plot(AlligatorRed, "Teeth", colorRed, styleLine | styleThick);  
13:  AlligatorGreen=Ref(Wilders(Avg,5),-3);  
14:  Plot(AlligatorGreen, "Leeps", colorGreen, styleLine | styleThick);  
15:  //The PURPLE line is a 5 bar SIMPLE moving average of the barĂ¢€™s CLOSE offset 3 bars into the future  
16:  PurpleLine = MA(Ref(C,-3),5);  
17:  if( ParamToggle("Show Purple Line", "No|Yes", 0))  
18:  {  Plot(PurpleLine , "Purple", colorViolet, styleLine | styleThick);  
19:  }  
20:  //AO  
21:  //---------------  
22:  AO = MA( Avg,5) - MA( Avg , 34);  
23:  AOUpBar = AO > Ref(AO, -1);  
24:  AODownBar = AO < Ref(AO, -1);  
25:  //AC  
26:  //---------------  
27:  MAAvg34=MA( Avg , 34);  
28:  MAAvg5 = MA( Avg,5);  
29:  MADiff = MAAvg5 - MAAvg34;  
30:  AC = MA(MADiff - MA(MADiff, 5), 5);  
31:  ACUpBar = AC > Ref(AC, -1);  
32:  ACDownBar = AC < Ref(AC, -1);  
33:  //Squat Bar  
34:  //---------  
35:  //Squat bars are a battle of the bulls and the bears, with lots of buying and selling but little price movement.   
36:  //A squat bar will be one of the top three OR bottom three bars 85% of the time at the end of a trend.  
37:  //While all trends end with a squat, all squats are NOT the end of a trend.  
38:  MarketFacilitionIndex =(H-L)/V;  
39:  SquatBar = MarketFacilitionIndex < Ref(MarketFacilitionIndex, -1) AND Volume > Ref(Volume, -1);  
40:  ShowSquatBars = ParamToggle("Show Squat Bars", "No|Yes", 1);  
41:  //Price Bar  
42:  //---------  
43:  GreenBar = AOUpBar AND ACUpBar;  
44:  RedBar = AODownBar AND ACDownBar;  
45:  PriceBarColor = IIf(GreenBar, colorBrightGreen , IIf(RedBar, colorRed, colorGrey40));  
46:  PriceBarColor = IIf(ShowSquatBars AND SquatBar, colorBlue, PriceBarColor);  
47:  Plot( C, "Close", PriceBarColor , styleNoTitle | ParamStyle("Style") | GetPriceStyle() );  
48:  if( ParamToggle("Tooltip shows", "All Values|Only Prices" ) )  
49:  {  
50:   ToolTip=StrFormat("Open: %g\nHigh: %g\nLow:  %g\nClose: %g (%.1f%%)\nVolume: "+NumToStr( V, 1 ), O, H, L, C, SelectedValue( ROC( C, 1 )));  
51:  }  
52:  //Fractal up  
53:  //----------  
54:  fUp = (Ref(H,-2) > Ref(H, -4)) AND  
55:   (Ref(H,-2) > Ref(H, -3)) AND  
56:   (Ref(H,-2) > Ref(H, -1)) AND  
57:   (Ref(H,-2) > H);  
58:  var1=ValueWhen(fUp ,Ref(H,-2) ,1);  
59:  FractalUp=HighestSince(var1 > 0, var1, 1);  
60:  Plot(FractalUp, "F+",colorLime , styleLine | styleDots);  
61:  FUpBuyPrice = FractalUp + 0.01;  
62:  FUpHit = FUpBuyPrice <= H AND FUpBuyPrice >= L;  
63:  FUpSignalOn = Flip(Ref(FractalUp,-1) != FractalUp, FUpHit);  
64:  //Looks into the future. This is done only to display Fractal arrow at the right bar.  
65:  //The calculation of the fractal up is done without looking into the future.  
66:  PlotShapes(IIf(Ref(FractalUp,2) != Ref(FractalUp,1), shapeSmallUpTriangle, shapeNone), colorGreen,0,Ref(FractalUp,2), 10);  
67:  //Fractal Down  
68:  //------------  
69:  var2=  
70:    (Ref(L,-2) <= Ref(L, -1)) AND  
71:    (Ref(L,-2) <= Ref(L, 0)) AND  
72:    (Ref(L,-2) <= Ref(L, -3)) AND  
73:    (Ref(L,-2) <= Ref(L, -4));  
74:  FractalDown=ValueWhen(var2, Ref(L,-2), 1);  
75:  FDownSellPrice= FractalDown+ 0.01;  
76:  FDownHit = FDownSellPrice <= H AND FDownSellPrice >= L;  
77:  FDownSignalOn = Flip(Ref(FractalDown,-1) != FractalDown, FDownHit );  
78:  Plot(FractalDown, "F-", colorGrey40, styleLine | styleDots);  
79:  //Looks into the future. This is done only to display Fractal arrow at the right bar.  
80:  //The calculation of the fractal up is done without looking into the future.  
81:  PlotShapes(IIf(Ref(FractalDown,2) != Ref(FractalDown,1), shapeSmallDownTriangle, shapeNone), colorRed,0,Ref(FractalDown,2), 10);  
82:  //Exits  
83:  //-----  
84:  Bar5LongExit = Ref(GreenBar, -4) AND Ref(GreenBar, -3) AND Ref(GreenBar, -2) AND Ref(GreenBar, -1) AND GreenBar;  
85:  Bar5ShortExit = Ref(RedBar, -4) AND Ref(RedBar, -3) AND Ref(RedBar, -2) AND Ref(RedBar, -1) AND RedBar;  
86:  Bar5LongPrice = LowestSince(Bar5LongExit, L) - 0.01;  
87:  Bar5LongHit = L <= Ref(Bar5LongPrice, -1);  
88:  Bar5LongOn = Flip(Bar5LongExit, Bar5LongHit);  
89:  Bar5ShortPrice = LowestSince(Bar5ShortExit, H) + 0.01;  
90:  Bar5ShortHit = H >= Ref(Bar5ShortPrice, -1);  
91:  Bar5ShortOn = Flip(Bar5ShortExit, Bar5ShortHit);  
92:  GreenLineLongExit = Cross(AlligatorGreen, C);  
93:  RedLineLongExit = Cross(AlligatorRed, C);  
94:  GreenLineShortExit = Cross(AlligatorGreen, C);  
95:  RedLineShortExit = Cross(AlligatorRed, C);  
96:  //Zones (Add-Ons)  
97:  //---------------  
98:  //"Add-On" Buy (Sell):  
99:  //(1) The Momentum is still going up (down).  
100:  //(2) The Accelerator is moving up (down).  
101:  //(3) The Price is closing higher (lower).  
102:  //It is rare to continue to get over six to eight bars of the same color - No add ons after 5 consecutive bars.  
103:  AddOnBuy = Ref(GreenBar,-1) AND GreenBar AND C > Ref(C,-1) AND NOT Bar5LongExit;  
104:  AddOnSell = Ref(RedBar,-1) AND RedBar AND C < Ref(C,-1) AND NOT Bar5ShortExit;  
105:  //Balance Lines  
106:  //-------------  
107:  //1. If we are going toward the Balance Line, we place our Signal at base + two higher highs (lower lows).  
108:  //2. If we are going away from the Balance Line, we use base + one higher High (lower Low).  
109:  //3. If the current bar is red (green) and we are above the blue (Green) Balance Line AND looking for Buy (sell)signals  
110:  //  we double the number of lower low (higher high) bars needed.  
111:  //4. Base Bar is the Lowest High (Highest Low) in buy (sell). Signal Bar is the bar before the base bar.  
112:  //5. Buy (Sell) stop is defined as the High (Low) + 1 tick of the Signal Bar.  
113:  //6. As long as the Signal bar itself is above the Balance Line, we act as if the entire formation were above the Balance Line.  
114:  //7. The buy (sell) stop stays in place unless  
115:  //   (a) it is triggered  
116:  //   OR  
117:  //   (b) another bar with a lower High (Higher Low) is formed, creating a different base bar.  
118:  //8. You do not sell above the Alligator's mouth and you do not buy below the Alligator's mouth.  
119:  AboveAll = L > AlligatorRed AND L > AlligatorBLue AND L > AlligatorGreen;  
120:  BelowAll = H < AlligatorRed AND H < AlligatorBLue AND H < AlligatorGreen;  
121:  //Buys. Only above balance lines for now  
122:  LowerHigh = Ref(H, -1) > H;  
123:  //Double the number of LowerHighs Required on RedBar  
124:  BuySignalRef = IIf(RedBar, 2, 1);  
125:  //"BuySignalRef =" +WriteVal(BuySignalRef );  
126:  //1 or 2 lower highs above balance line  
127:  BLBuyCondition = Ref(AboveAll,-BuySignalRef) AND LowerHigh AND IIf(RedBar, Ref(LowerHigh,-1) , True);  
128:  //"BLBuyCondition =" +WriteVal(BLBuyCondition );  
129:  //Update price if new buy signal is on, otherwise use previous price:  
130:  BLBuyPrice = LowestSince(BLBuyCondition, Ref(H,-BuySignalRef)+0.01, 1);  
131:  //"Buy Hit="+WriteVal(H > Ref(BLBuyPrice,-1)) +" at"+WriteVal(Ref(BLBuyPrice,-1));  
132:  //Keep buy signal on until it is hit or marked is below all balance lines:  
133:  BLBuySignal = Flip(BLBuyCondition , ((NOT BLBuyCondition) AND H >= Ref(BLBuyPrice,-1)) OR BelowAll);  
134:  //"BLBuySignal "+WriteVal(BLBuySignal)+" BLBuyPrice="+WriteVal(BLBuyPrice);  
135:  BLBuyHit = Ref(BLBuySignal, -1) AND (NOT BLBuyCondition) AND H >= Ref(BLBuyPrice,-1);  
136:  //Note that if new buy signal is after a still valid older signal, we choose the lowest from both of them  
137:  BLBuyPrice = IIf(Ref(BLBuySignal,-1), Min(BLBuyPrice, Ref(BLBuyPrice,-1)), BLBuyPrice);  
138:  //Sells. Only below balance lines for now  
139:  HigherLow = Ref(L, -1) < L;  
140:  //Double the number of LowerHighs Required on GreenBar  
141:  SellSignalRef = IIf(GreenBar, 2, 1);  
142:  //"SellSignalRef =" +WriteVal(SellSignalRef );  
143:  //1 or 2 higher lows above balance line  
144:  BLSellCondition = Ref(BelowAll, -SellSignalRef) AND HigherLow AND IIf(GreenBar, Ref(HigherLow,-1) , True);  
145:  //"BLSellCondition =" +WriteVal(BLSellCondition);  
146:  //Update price if new sell signal is on, otherwise use previous price:  
147:  BLSellPrice = HighestSince(BLSellCondition , Ref(L,-SellSignalRef)-0.01, 1);  
148:  //"Sell Hit="+WriteVal((NOT BLSellCondition) AND L < Ref(BLSellPrice,-1)) +" at"+WriteVal(Ref(BLSellPrice,-1));  
149:  //Keep buy signal on until it is hit or market is above all balance lines  
150:  BLSellSignal = Flip(BLSellCondition, ((NOT BLSellCondition) AND L <= Ref(BLSellPrice,-1)) OR AboveAll);  
151:  //"BLSellSignal"+WriteVal(BLSellSignal)+" BLSellPrice="+WriteVal(BLSellPrice);  
152:  BLSellHit = Ref(BLSellSignal, -1) AND (NOT BLSellCondition) AND L <= Ref(BLSellPrice,-1);  
153:  //Note that if new sell signal is after a still valid older signal, we choose the highest from both of them  
154:  BLSellPrice = IIf(Ref(BLSellSignal,-1), Max(BLSellPrice, Ref(BLSellPrice,-1)), BLSellPrice);  
155:  //Bars Analysis  
156:  //-------------  
157:  Third = (H-L) / 3;  
158:  Line1 = H - Third;  
159:  Line2 = L + Third;  
160:  Half = L + ((H-L) / 2);  
161:  //After an extreme bar 85% of the time the market will change direction within the next 1-5 bars.  
162:  ExtremeBarUp = Open > Line1 AND Close > Line1;  
163:  ExtremeBarDown = Open < Line2 AND Close < Line2;  
164:  ExtremeBar = ExtremeBarUp OR ExtremeBarDown;  
165:  //Bullish AND Bearish Bars Inside the mouth do NOT create a Signal.  
166:  OutsideMouth = NOT ((H < AlligatorBlue AND L > AlligatorGreen) OR (L > AlligatorBlue AND H < AlligatorGreen));  
167:  //Bullish Divergence Bars  
168:  BullDivBar = OutsideMouth AND L < Ref(L,-1) AND C > Half;  
169:  //Bearish Divergence Bars  
170:  BearDivBar = OutsideMouth AND H > Ref(H, -1) AND C < Half;  
171:  PlotShapes(IIf(ExtremeBar, shapeSmallCircle ,shapeNone), colorBlue, 0, H, 12);  
172:  PlotShapes(IIf(BullDivBar, shapeSmallCircle ,shapeNone), colorGreen, 0, L, -12);  
173:  PlotShapes(IIf(BearDivBar, shapeSmallCircle ,shapeNone), colorRed, 0, H, 12);  
174:  //Commentary:  
175:  WriteIf(ExtremeBarUp OR ExtremeBarDown, "Possible Change of direction within the next 1-5 bars. (Extreme Bar)\n","")+  
176:  "Buy Signals:\n"+  
177:  WriteIf(FUpSignalOn , "Place Buy Stop if Price rises to" +WriteVal(FUpBuyPrice)+ " or higher. (F+)\n","")+  
178:  WriteIf(BullDivBar, "Place Buy Stop if Price rises to" +WriteVal(H+0.01)+ " or higher. (Bullish Divergent Bar)\n","")+  
179:  WriteIf(AddOnBuy, "Place Buy Stop if Price rises to" +WriteVal(H+0.01)+ " or higher. (Zones Add On Buy)\n","")+  
180:  WriteIf(BLBuySignal,"Place Buy Stop if Price rises to" +WriteVal(BLBuyPrice)+ " or higher. (BL+)\n","")+  
181:  "Sell Signals:\n"+  
182:  WriteIf(FDownSignalOn , "Place Sell Stop if Price falls to" +WriteVal(FDownSellPrice)+ " or lower. (F-)\n","")+  
183:  WriteIf(BearDivBar, "Place Sell Stop if Price falls to" +WriteVal(L-0.01)+ " or lower. (Bearish Divergent Bar)\n","")+  
184:  WriteIf(AddOnSell, "Place Sell Stop if Price falls to" +WriteVal(L-0.01)+ " or lower. (Zones Add On Sell)\n","")+  
185:  WriteIf(BLSellSignal,"Place Sell Stop if Price falls to" +WriteVal(BLSellPrice)+ " or lower. (BL-)\n","")+  
186:  "Hits:\n"+  
187:  WriteIf(BLBuyHit,"Buy Stop Hit at" +WriteVal(Ref(BLBuyPrice,-1))+ ". (BL+)\n","")+  
188:  WriteIf(BLSellHit,"Sell Stop Hit at" +WriteVal(Ref(BLSellPrice,-1))+ ". (BL-)\n","")+  
189:  WriteIf(Ref (FUpSignalOn, -1) AND FUpHit,"Buy Stop Hit at" +WriteVal(Ref(FUpBuyPrice,-1))+ ". (F+)\n","")+  
190:  WriteIf(Ref (FDownSignalOn, -1) AND FDownHit,"Sell Stop Hit at" +WriteVal(Ref(FDownSellPrice,-1))+ ". (F-)\n","")+  
191:  WriteIf(Ref(Bar5LongOn , -1) AND Bar5LongHit, "Close all positions Hit at" +WriteVal(Ref(Bar5LongPrice,-1))+ ". (Long Five Consecutive Bars Exit)\n","")+  
192:  WriteIf(Ref(Bar5ShortOn , -1) AND Bar5ShortHit, "Close all positions Hit at" +WriteVal(Ref(Bar5ShortPrice,-1))+ ". (Short Five Consecutive Bars Exit)\n","")+  
193:  "Exits:\n"+  
194:  WriteIf(Bar5LongOn , "Long Five Consecutive Bars Exit Strategy: Close all Long positions if Price falls to" +WriteVal(Bar5LongPrice)+ " or lower.\n","")+  
195:  WriteIf(Bar5ShortOn, "Short Five Consecutive Bars Exit Strategy: Close all Short positions if Price rises to" +WriteVal(Bar5ShortPrice)+ " or higher.\n","")+  
196:  WriteIf(GreenLineLongExit, "Green Line Long Exit Strategy: All Long positions should have been closed when Close Price fell below "+WriteVal(AlligatorGreen)+".\n","")+  
197:  WriteIf(RedLineLongExit, "Red Line Long Exit Strategy: All Long positions should have been closed when Close Price fell below "+WriteVal(AlligatorRed)+".\n","")+  
198:  WriteIf(GreenLineShortExit, "Green Line Short Exit Strategy: All Short positions should have been closed when Close Price rose above "+WriteVal(AlligatorGreen)+".\n","")+  
199:  WriteIf(RedLineShortExit, "Red Line Short Exit Strategy: All Short positions should have been closed when Close Price rose aboce "+WriteVal(AlligatorRed)+".\n",""); 
 
 
 
diambil dari http://www.wisestocktrader.com