/*[[ Name := ema Author := Copyright © 2005, MetaQuotes Software Corp. Link := http://www.metaquotes.net/ Notes := /*[[ Notes := Name := EMA Cross example Notes := Author := Copyright ) 2005 Notes := Link := Notes := Lots := 1.00 Notes := Stop Loss := 26 Notes := Take Profit := 237 Notes := Trailing Stop := 15 Notes := ]]*/ Notes := Notes := Notes := Define: EMA1Period(13); Notes := Define: EMA2Period(89); Notes := Notes := Var: EMA1now(0), EMA2now(0); Notes := Var: EMA1prev(0), EMA2prev(0); Notes := Notes := EMA1now=iMA(EMA1Period,MODE_EMA,0); Notes := EMA1prev=iMA(EMA1Period,MODE_EMA,1); Notes := Notes := EMA2now=iMA(EMA2Period,MODE_EMA,0); Notes := EMA2prev=iMA(EMA2Period,MODE_EMA,1); Notes := Notes := If EMA1prev>=EMA2Prev // First EMA is above 2nd Notes := EMA at previous bar Notes := and EMA1nowEMA2now // Now the first EMA is Notes := above 2nd EMA Notes := then Notes := { Notes := Alert("EMA(",EMA1Period,") crossed above Notes := EMA(",EMA2Period,")"); Notes := }; Notes := Notes := Exit; Separate Window := No First Color := Blue First Draw Type := Line First Symbol := 217 Use Second Data := No Second Color := Red Second Draw Type := Line Second Symbol := 218 ]]*/ Variable : shift(0); SetLoopCount(0); // loop from first bar to current bar (with shift=0) For shift=Bars-1 Downto 0 Begin SetIndexValue(shift, 0); End;