{RSI} rsi_r := (CLOSE - ref(CLOSE,-1)); rsi_rs := Wilders(if(rsi_r>0,rsi_r,0),14) / Wilders(if(rsi_r<0,Abs(rsi_r),0),14); RSIndex:= Mov((100-(100/(1+rsi_rs))),2,E); {ATR RSI} TH :=if(Ref(RSIndex,-1) > RSIndex,Ref(RSIndex,-1),RSIndex); TL :=if(Ref(RSIndex,-1) < RSIndex,Ref(RSIndex,-1),RSIndex); TR :=TH-TL; ATRRSI:=Wilders(TR,14); DeltaATRRSI:= Wilders(ATRRSI,14)*2.618; TrLevelRSIFast:=If( RSIndex=PREV, PREV, If( ((Ref(RSIndex,-1)PREV) AND (RSIndex>PREV), Max(PREV,RSIndex - DeltaATRRSI), If( RSIndex>PREV, RSIndex - DeltaATRRSI, RSIndex + DeltaATRRSI ) ) ) ); DeltaATRRSI_2:= Wilders(ATRRSI,14)*4.236; TrLevelRSISlow:=If( RSIndex=PREV, PREV, If( ((Ref(RSIndex,-1)PREV) AND (RSIndex>PREV), Max(PREV,RSIndex - DeltaATRRSI_2), If( RSIndex>PREV, RSIndex - DeltaATRRSI_2, RSIndex + DeltaATRRSI_2 ) ) ) ); {Edit this section to your preferences.} {Control Error} Barnum:= BarCount(); Err:= (tp1=0) or (tp2=0); {Add Indicators Here} Indicator1:= mov(C,tp1,mTp); Indicator2:= mov(C,tp2,mTp); {Do NOT change the NAMES of the Variables below. If you Changed The NAMES of Indicator1 or Indicator2, you will have to change them below.} {Define Final Trade Entry/Exit Criteria} LongEntrySetup:= Cross(Indicator1,Indicator2) and RSIndex>TrLevelRSIFast and RSIndex>TrLevelRSISlow and TrLevelRSIFast>TrLevelRSISlow; LongExitSetup:= Cross(Cross(TrLevelRSISlow,RsIndex),LongEntrySignal); ShortEntrySetup:= Cross(Indicator2,Indicator1) and RSIndexeventCount('CloseBuy')); OpenSell:= ShortEntrySignal and (eventCount('OpenSell')=eventCount('CloseSell')); CloseSell:= ShortExitSignal and (eventCount('OpenSell')>eventCount('CloseSell')); {***********************************************} {Calculate Simulated Individual Trade Profit In Pips} _TradeProfitInPips:= If(LongExitSignal=1,LongExitPrice - (LongEntryPrice + _Spread), If(ShortExitSignal=1,ShortEntryPrice - (ShortExitPrice + _Spread), 0)); TradeProfitInPips:= if(SymbolDigits()=4, _TradeProfitInPips * 10000, _TradeProfitInPips * 100); {Calculate Simulated Total Profit In Pips} TotalProfitInPips:= cum(TradeProfitInPips); {Calculate Number of Trades and W/L Percentage} LosingTrades:= cum(If(TradeProfitInPips < 0,1,0)); WinningTrades:= cum(If(TradeProfitInPips > 0,1,0)); BreakEvenTrades:= if((LongExitSignal=1 or ShortExitSignal=1) and TradeProfitInPips=0, PREV+1, PREV); TotalTrades:= cum(LongExitSignal) + cum(ShortExitSignal); {Calculate Current Open Trade P/L In Pips} _OpenTradeInPips:= If(LongTradeAlert=1, (C - _Spread - LongEntryPrice), If(ShortTradeAlert=1, (ShortEntryPrice - C - _Spread), null)); OpenTradeInPips:= if(SymbolDigits()=4, _OpenTradeInPips * 10000, _OpenTradeInPips * 100); MaxOpenProfit:= Highest(OpenTradeInPips); MaxOpenLoss:= Lowest(OpenTradeInPips); {***********************************************}