/*[[ Name := RSI MA Author := seaweed Link := seaweed255@yahoo.com Separate Window := Yes First Color := Orange First Draw Type := Line First Symbol := 217 Use Second Data := Yes Second Color := Blue Second Draw Type := Line Second Symbol := 218 ]]*/ Inputs: RsiPeriod(14),BarsCount(500),MAPeriod(8),MAPeriod1(13); Variable : shift(0), value(0), MA(0),MA1(0), bars_(0), prev(0),prev1(0); Variable: RS(0),smconst(0),smconst1(0); SetLoopCount(0); if BarsCount > 0 then { if BarsCount > Bars then {bars_ = Bars;} else {bars_ = BarsCount;} } else {bars_ = Bars;}; For shift = bars_-1 Downto 0 Begin value = iRSI(RsiPeriod, shift); smconst = 2 / (1 + MAPeriod); smconst1 = 2 / (1 + MAPeriod1); if (shift < bars_ - (RsiPeriod + MAPeriod)) and (MAPeriod > 1) then begin prev = GetIndexValue(shift + 1); MA1 = smconst * (value - prev) + prev; SetIndexValue(shift , MA1); prev = GetIndexValue2(shift + 1); MA = smconst1 * (value - prev) + prev; SetIndexValue2(shift , MA); end; End;