/*[[ Name := ea_Robot_Power_M5_v-transport1 Author := MT Link := http://www.metexinvest.com/ Notes := long if bulls+bears>0:::short if bulls+bears<0 , hack by transport_david Lots := 1.00 Stop Loss := 30 Take Profit := 150 Trailing Stop := 0 ]]*/ Define: Adj2B.E.Aftr_Pips(17); Define: TrailAt_TimesATR(1.7); Define: BullBearPeriod(5); Define: MM(-1); Define: RiskPct(7); Define: Up2_Lots(50); Define: slippage(4); Var: LotMM(0); Var: bull(0); Var: bear(0); Var: b(0); Var: s(0); Var: sl(0); Var: tp(0); Var: cnt(0); Var: Opentrades(0); bull = iBullsPower(BullBearPeriod,PRICE_CLOSE,1)*1000; bear = iBearsPower(BullBearPeriod,PRICE_CLOSE,1)*1000; Comment(" Prev bull + bear = ",(bull+bear)); b = (1 * Point) + (iATR(5,1) * TrailAt_TimesATR); s = (1 * Point) + (iATR(5,1) * TrailAt_TimesATR); If (CurTime-LastTradeTime)<10 then exit; if MM < 0 then { LotMM = floor(Balance*RiskPct/10000)/10; If LotMM > Up2_Lots then { LotMM = Up2_Lots; } } else { LotMM = lots; }; if MM > 0 then { LotMM = floor(Balance*RiskPct/10000)/10; If LotMM > 1 then { LotMM = floor(LotMM); } if LotMM < 1 then { LotMM = 1; } If LotMM > Up2_Lots then { LotMM = Up2_Lots; } }; Opentrades=0; For cnt=1 to TotalTrades Begin If OrderValue(cnt,Val_Symbol)=Symbol then { Opentrades=Opentrades+1; }; End; if Opentrades <= 0 then { if bull + bear > 0 then { sl = Ask - StopLoss * Point; tp = Bid + TakeProfit * Point; SetOrder(OP_BUY,LotMM,Ask,slippage,sl,tp,Blue); Exit; } if bull + bear < 0 then { sl = Bid + StopLoss * Point; tp = Ask - TakeProfit * Point; SetOrder(OP_SELL,LotMM,Bid,slippage,sl,tp,Red); Exit; } }; for cnt = 1 to TotalTrades { If Ord(cnt,VAL_TYPE)=OP_BUY and Ord(cnt,VAL_SYMBOL)=Symbol Then { If Ord(cnt,VAL_STOPLOSS)=Ord(cnt,VAL_OPENPRICE)-StopLoss*Point and Bid-Ord(cnt,VAL_OPENPRICE)>Adj2B.E.Aftr_Pips*Point then { ModifyOrder(Ord(cnt,VAL_TICKET), Ord(cnt,VAL_OPENPRICE), Bid-Adj2B.E.Aftr_Pips*Point, Ord(cnt,VAL_TAKEPROFIT), DeepSkyBlue); }else{ if Bid - OrderValue(cnt,VAL_OPENPRICE) > b and Bid-b > Ord(cnt,VAL_STOPLOSS) then { ModifyOrder(OrderValue(cnt,VAL_TICKET), OrderValue(cnt,VAL_OPENPRICE), Bid - b, OrderValue(cnt,VAL_TAKEPROFIT), SlateBlue); Exit; }; }; }; If Ord(cnt,VAL_TYPE)=OP_SELL and Ord(cnt,VAL_SYMBOL)=Symbol Then { If Ord(cnt,VAL_STOPLOSS)=Ord(cnt,VAL_OPENPRICE)+StopLoss*Point and Ord(cnt,VAL_OPENPRICE)-Ask>Adj2B.E.Aftr_Pips*Point then { ModifyOrder(Ord(cnt,VAL_TICKET), Ord(cnt,VAL_OPENPRICE), Ask+Adj2B.E.Aftr_Pips*Point, Ord(cnt,VAL_TAKEPROFIT), DeepSkyBlue); }else{ if OrderValue(cnt,VAL_OPENPRICE) - Ask > s and Ask+s < Ord(cnt,VAL_STOPLOSS) then { ModifyOrder(OrderValue(cnt,VAL_TICKET), OrderValue(cnt,VAL_OPENPRICE), Ask + s, OrderValue(cnt,VAL_TAKEPROFIT), Red); Exit; }; }; }; };