/*[[ Name := Wiseman 1 Author := David Thomas, Basileus@Moneytec Notes := Bill Williams Wiseman 1 Divergent bars. ver. 5. Notes := the changes of Basileus@Moneytec have been corrected and simplified. Notes := AdditionalFilter if set to zero will not include the additional filters. Separate Window := Yes First Color := Blue First Draw Type := Histogram First Symbol := 217 Use Second Data := No Second Color := Red Second Draw Type := Line Second Symbol := 218 Minimum Chart Limits := -1.000000 Maximum Chart Limits := 1.000000 ]]*/ Input : AdditionalFilter(1); Variables : shift(0), prevbars(0), first(True), loopbegin(0), lips(0), teeth(0), jaws(0), median(0), result(0); SetLoopCount(0); // check conditions are ok. if Bars < 3 Or Bars = prevbars then exit; // check for additional bars loading or total reloading If Bars < prevbars or Bars-prevbars>1 Then first = True; prevbars = Bars; If first Then Begin // loopbegin prevent counting of counted bars exclude current loopbegin = Bars-30; first = False; End; loopbegin++; // loop from first bar to current bar (with shift=0) For shift=loopbegin Downto 0 Begin result = 0; median = (H[shift]+L[shift])/2; lips = iAlligator(13, 8, 8, 5, 5, 3, MODE_SMMA, PRICE_MEDIAN, MODE_GATORLIPS, shift); teeth = iAlligator(13, 8, 8, 5, 5, 3, MODE_SMMA, PRICE_MEDIAN, MODE_GATORTEETH, shift); jaws = iAlligator(13, 8, 8, 5, 5, 3, MODE_SMMA, PRICE_MEDIAN, MODE_GATORJAW, shift); // test for bullish divergent bar: if ((C[shift] >= median) // close is in upper half of bar and (H[shift] < Min(Min(lips,teeth),jaws)) // bar is completely below alligator and (L[shift] < L[shift+1]) and (L[shift] < L[shift+2]) // low is moving down and (AdditionalFilter == 0 // either no additional filtering or check the additional filtering or (L[shift] < L[shift+3]) and (L[shift] < L[shift+4]) // ... and (iAO(shift) <= iAO(shift+1))) // the AO is red--moving down. ) then result = 1; // test for bearish divergent bar: if ((C[shift] <= median) // close is in lower half of bar and (L[shift] > Max(Max(lips,teeth),jaws)) // bar is completely above alligator and (H[shift] > H[shift+1]) and (H[shift] > H[shift+2]) // high is moving up and (AdditionalFilter == 0 // either no additional filtering or check the additional filtering or (H[shift] > H[shift+3]) and (H[shift] > H[shift+4]) // ... and (iAO(shift) >= iAO(shift+1))) // the AO is green--moving up. ) then result = -1; SetIndexValue(shift, result); loopbegin--; End;