/*[[ Name := Mr.Roboto-SilverTrend Author := FAB4X Link := http://www.metexinvest.com/ Notes := M5 for all majors Lots := 1.00 Stop Loss := 45 Take Profit := 150 Trailing Stop := 15 ]]*/ Var: bull(0),bear(0); Define: slippage(2),MM(0),Risk(7.5); Var: sl(0),tp(0),cnt(0),b(0),s(0),Opentrades(0),lotsi(0),ITB(0),ITS(0); var: vSlippage(0); var: vTime(0); Var: Mode(0); var: FXSymbol(""); var: ARD(0),ARU(0); If Period <> 5 then Alert("Mr.Roboto System only works on 5M timeframe.") Exit; ///////////////////////////////////////////////// // Trade Management and Creation ///////////////////////////////////////////////// ARD=icustom("SilverTrend",1,240,9,mode_first,1); ARU=icustom("SilverTrend",1,240,9,mode_second,1); bull = iBullsPower(5,PRICE_CLOSE,1); bear = iBearsPower(5,PRICE_CLOSE,1); comment("bull+bear= ",bull + bear,"\n Arrow UP ",ARU,"\n Arrow DWN ",ARD); ///////////////////////////////////////////////// // Calculation/Settings ///////////////////////////////////////////////// OpenTrades = 0; for cnt = 1 to TotalTrades { FXSymbol = OrderValue(cnt, VAL_SYMBOL); Mode = OrderValue(cnt, VAL_TYPE); if FXSymbol == Symbol then { if (Mode == OP_SELL or Mode == OP_BUY) then { OpenTrades++; } } } ////////////////////////////////////////////////// ///////////// Manage multiple trades ///////////// ////////////////////////////////////////////////// Opentrades=0; For cnt=1 to TotalTrades Begin If OrderValue(cnt,Val_Symbol)=Symbol then { Opentrades=Opentrades+1; }; End; ////////////////////////////////////////////////// ///////////// Money Manager ///////////// ////////////////////////////////////////////////// if mm<>0 then Lotsi=Ceil(Balance*risk/10000)/10 else Lotsi=Lots; if OpenTrades != 0 then { for cnt = 1 to TotalTrades { if OrderValue(cnt, VAL_SYMBOL) == Symbol then { if (OrderValue(cnt, VAL_TYPE) == OP_BUY) then { // if vSig151 or vSig153 then // { // Exit; // } if ARD=icustom("SilverTrend",1,240,9,mode_first,1)>1 then { CloseOrder (OrderValue(cnt, VAL_TICKET),OrderValue(cnt, VAL_LOTS),OrderValue(cnt, VAL_CLOSEPRICE),Slippage,blue); Exit; } } if (OrderValue(cnt, VAL_TYPE) == OP_SELL) then { // if vSig152 or vSig153 then // { // Exit; // } if ARU=icustom("SilverTrend",1,240,9,mode_second,1)>1 then { CloseOrder (OrderValue(cnt, VAL_TICKET),OrderValue(cnt, VAL_LOTS),OrderValue(cnt, VAL_CLOSEPRICE),Slippage,red); Exit; } } } } } if Opentrades = 0 then { if vTime != Time[0] then { if bull + bear > 0 and ARU=icustom("SilverTrend",1,240,9,mode_second,2)>1 then { sl = Ask - StopLoss * Point; tp = Bid + TakeProfit * Point; SetOrder(OP_BUY,Lotsi,Ask,slippage,sl,tp,Blue); vTime = Time[0]; Exit; } } if vTime != Time[0] then { if bull + bear < 0 and ARD=icustom("SilverTrend",1,240,9,mode_first,2)>1 then { sl = Bid + StopLoss * Point; tp = Ask - TakeProfit * Point; SetOrder(OP_SELL,Lotsi,Bid,slippage,sl,tp,Red); vTime = Time[0]; Exit; } } } b = 1 * Point + iATR(5,1) * 1.5; s = 1 * Point + iATR(5,1) * 1.5; for cnt = 1 to TotalTrades { if OrderValue(cnt,VAL_TYPE) == 0 and OrderValue(cnt,VAL_SYMBOL) == Symbol then { if OrderValue(cnt,VAL_OPENPRICE) > OrderValue(cnt,VAL_STOPLOSS) and Bid - OrderValue(cnt,VAL_OPENPRICE) > StopLoss * Point then { ModifyOrder(OrderValue(cnt,VAL_TICKET),OrderValue(cnt,VAL_OPENPRICE),OrderValue(cnt,VAL_OPENPRICE),OrderValue(cnt,VAL_TAKEPROFIT),SlateBlue); Exit; } if Bid - OrderValue(cnt,VAL_OPENPRICE) > b then { if OrderValue(cnt,VAL_STOPLOSS) < Bid - b then { ModifyOrder(OrderValue(cnt,VAL_TICKET),OrderValue(cnt,VAL_OPENPRICE),Bid - b,OrderValue(cnt,VAL_TAKEPROFIT),SlateBlue); Exit; } } } if OrderValue(cnt,VAL_TYPE) == 1 and OrderValue(cnt,VAL_SYMBOL) == Symbol then { if OrderValue(cnt,VAL_OPENPRICE) < OrderValue(cnt,VAL_STOPLOSS) and OrderValue(cnt,VAL_OPENPRICE) - Ask > StopLoss * Point then { ModifyOrder(OrderValue(cnt,VAL_TICKET),OrderValue(cnt,VAL_OPENPRICE),OrderValue(cnt,VAL_OPENPRICE),OrderValue(cnt,VAL_TAKEPROFIT),Red); Exit; } if OrderValue(cnt,VAL_OPENPRICE) - Ask > s then { if OrderValue(cnt,VAL_STOPLOSS) > Ask + s then { ModifyOrder(OrderValue(cnt,VAL_TICKET),OrderValue(cnt,VAL_OPENPRICE),Ask + s,OrderValue(cnt,VAL_TAKEPROFIT),Red); Exit; } } } }