/*[[ Name := indTest2 Author := Copyright © 2004, podval Link := podval_2002@rambler.ru Separate Window := No First Color := Blue First Draw Type := Histogram Use Second Data := Yes Second Color := Red Second Draw Type := Histogram ]]*/ Inputs: AllBars(500), per1(13), per2(13); var: BarsCount(0), m1(0), m2(0), val1(0), val2(0), shift(0), bears1(0), bulls1(0); BarsCount = Bars - Max(per1, per2) - 1; SetLoopCount(0); // loop from first bar to current bar (with shift=0) for shift = BarsCount - 1 downto 1 begin m1 = iMA(per1, MODE_EMA, shift); m2 = iMA(per1, MODE_EMA, shift+1); // m1 = iCustom("SATL", 500, MODE_FIRST, shift); // m2 = iCustom("SATL", 500, MODE_FIRST, shift+1); bears1 = iBearsPower(per2, PRICE_CLOSE, shift); bulls1 = iBullsPower(per2, PRICE_CLOSE, shift); val1=0; val2=0; if m1 < m2 then { if (bears1 < 0) and (abs(bears1) > abs(bulls1)) then { val2 = High[shift]; val1 = Low[shift]; }; }; if m1 > m2 then { if (bulls1 > 0) and (abs(bulls1) > abs(bears1)) then { val1 = High[shift]; val2 = Low[shift]; }; }; SetIndexValue(shift, val1); SetIndexValue2(shift, val2); end;