/*[[ Name := Robot_PowerM5_demo Author := MT Link := http://www.metexinvest.com/ Notes := long if bulls+bears>0:::short if bulls+bears<0 Lots := 1.00 Stop Loss := 45 Take Profit := 150 Trailing Stop := 15 ]]*/ Var: bull(0); Var: bear(0); Define: slippage(2); Var: sl(0); Var: tp(0); Var: cnt(0); Var: b(0); Var: s(0); bull = iBullsPower(5,PRICE_CLOSE,1); bear = iBearsPower(5,PRICE_CLOSE,1); Comment("\n","Day : ",Day," Hour : ",Hour," Min ",Minute," Seconds ", Seconds, "\n","Version 0.1", "\n", "\n","bull+bear= ",bull + bear); Define: StartHour(9),EndHour(19); if TimeHour(CurTime)=EndHour then { Comment("Outside Trading Hours, Exiting...", "\n","Day : ",Day," Hour : ",Hour," Min ",Minute," Seconds ", Seconds, "\n","Version 0.1", "\n", "\n","bull+bear= ",bull + bear); for cnt=1 to TotalTrades { If OrderValue(cnt,VAL_SYMBOL)=Symbol then { If OrderValue(cnt,VAL_TYPE)=OP_BUY then { CloseOrder(OrderValue(cnt,VAL_TICKET),OrderValue(cnt,VAL_LOTS),Bid,5,Violet); exit; }; If OrderValue(cnt,VAL_TYPE)=OP_SELL then { CloseOrder(OrderValue(cnt,VAL_TICKET),OrderValue(cnt,VAL_LOTS),Ask,5,Violet); exit; }; }; }; exit; }; /* if TimeYear(Time[0]) >= 2005 and TimeMonth(Time[0]) >= 7 then { Alert(" Your License Has Expired "); Comment(" Please Contact Customer Support ","\n"," The Expert will Manage Open Trades ","\n"," For 2 Days ","\n"," Then Cease To Operate "); Exit; } if TimeYear(Time[0]) >= 2005 and TimeMonth(Time[0]) >= 7 and TimeDay(Time[0]) >= 6 then Exit; */ if TotalTrades < 1 then { if bull + bear > 0 then { sl = Ask - StopLoss * Point; tp = Bid + TakeProfit * Point; SetOrder(OP_BUY,Lots,Ask,slippage,sl,tp,Blue); Exit; } if bull + bear < 0 then { sl = Bid + StopLoss * Point; tp = Ask - TakeProfit * Point; SetOrder(OP_SELL,Lots,Bid,slippage,sl,tp,Red); 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; } } } }