/*[[ Name := Wiseman 1 Author := David Thomas Notes := Bill Williams Wiseman 1 Divergent bars. ver. 4. Separate Window := No First Color := LimeGreen First Draw Type := Histogram First Symbol := 217 Use Second Data := Yes Second Color := Red Second Draw Type := Histogram Second Symbol := 218 ]]*/ Input : AdditionalFilter(1); Variables : shift(0), prevbars(0), first(True), loopbegin(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; // loop from first bar to current bar (with shift=0) For shift=loopbegin Downto 0 Begin result = iCustom("Wiseman 1 trinary", AdditionalFilter, MODE_FIRST, shift); if result < 0 then { // red bar. SetIndexValue(shift, Low[shift]); SetIndexValue2(shift, High[shift]); } if result > 0 then { // green bar. SetIndexValue(shift, High[shift]); SetIndexValue2(shift, Low[shift]); } loopbegin--; End;