Pls help me for stop trading and wait for condition New comment quagpz0 2018.10.18 22:31 Hi! I have problem with my code! I want if orderlots >= lotb then it will stop trading and wait for new condition! However it didnt stop and countinute trade until profitable result //+------------------------------------------------------------------+ //| advance_rsibo.mq4 | //| TeoPham | //| https://fb.com/jviruss | //+------------------------------------------------------------------+ #property copyright "TeoPham" #property link "" #property version "1.00" #property strict //+------------------------------------------------------------------+ //| Expert initialization function | extern double lot = 0.01, mp = 2.0; double rsihigh = 75.0, rsilow = 25.0, ccihigh = 195.0, ccilow = -195.0; double lota = lot; double lotb = 0.02; /*datetime hethan = D'2018.10.19 0:00'; */ int init() { HideTestIndicators(TRUE); return (0); } int dieukien() { if (( iRSI(Symbol(),NULL,14,PRICE_OPEN,0) > rsihigh) && ( iCCI(Symbol(),NULL,14,PRICE_OPEN,0) > ccihigh)&& (Close[0] > iBands(NULL,0,14,2,0,PRICE_OPEN,MODE_UPPER,0))) return(1); if ((iRSI(Symbol(),NULL,14,PRICE_OPEN,0) < rsilow) && (iCCI(Symbol(),NULL,14,PRICE_OPEN,0) < ccilow) && (Close[0] < iBands(NULL,0,14,2,0,PRICE_OPEN,MODE_LOWER,0))) return(2); else return(3); } void OnTick() { Comment( "Xin chao " + AccountInfoString(ACCOUNT_NAME) + "\nRobot dang chay..."); //--- if(dieukien() == 1 && OrdersTotal() < 1) OrderSend(Symbol(),OP_SELL,lota,Open[0],NULL,NULL,NULL,NULL,NULL,NULL,Red); if(dieukien() == 2 && OrdersTotal() < 1) OrderSend(Symbol(),OP_BUY,lota,Open[0],NULL,NULL,NULL,NULL,NULL,NULL,Green); //------------------------------------------------------------------------------------ //Closeorder Function---------------------------- for(int iPos=OrdersTotal() - 1; iPos >=0; iPos--) if (OrderSelect(iPos,SELECT_BY_POS) && OrderSymbol() == Symbol()) { int duration = iBarShift(NULL,NULL, OrderOpenTime()); if (duration < 1) continue; if (!OrderClose(OrderTicket(),OrderLots(), OrderClosePrice(), NULL, MediumSeaGreen)) Alert("OrderClose Failed: ", GetLastError()); } //---------------------------------------------- int last_trade=HistoryTotal(); if(last_trade>0) { if(OrderSelect(last_trade-1,SELECT_BY_POS,MODE_HISTORY)==true) { if(OrderSymbol()==Symbol() && (OrderProfit() < 0) && (OrdersTotal() < 1)) { if(OrderType() == OP_BUY) { if(OrderLots() >= lotb) { Print("Reset lots"); OrderLots() == lot; dieukien() == 3; } OrderSend(Symbol(),OP_BUY,lota*mp,Open[0],NULL,NULL,NULL,NULL,NULL,NULL,Green); Print("Du dieu kieu BUY lenh 2"); } if(OrderType() == OP_SELL) { if(OrderLots() >= lotb) { Print("Reset lots"); OrderLots() == lot; dieukien() == 3; } OrderSend(Symbol(),OP_SELL,lota*mp,Open[0],NULL,NULL,NULL,NULL,NULL,NULL,Red); Print("Du dieu kieu ban SELL 2"); } if(OrderSymbol()==Symbol() && (OrderProfit() == 0)) { if(OrderType() == OP_BUY) OrderSend(Symbol(),OP_BUY,OrderLots(),Open[0],NULL,NULL,NULL,NULL,NULL,NULL,Green); if(OrderType() == OP_SELL) OrderSend(Symbol(),OP_SELL,OrderLots(),Open[0],NULL,NULL,NULL,NULL,NULL,NULL,Red); } if(OrderSymbol()==Symbol() && (OrderProfit() > 0)) { Print("Sleepp - di nguuuuu"); dieukien() == 3; } } if(OrderSymbol()==Symbol() && (OrderProfit() > 0)) { lota = lot; } } } if(OrderLots() >= lotb) { OrderLots() == lot; dieukien() == 3; } } //+------------------------------------------------------------------+ pls help me with is code line fix two ma cross condition. thanks NEED Help!! How to make limit order per condition >,< New comment
Hi! I have problem with my code! I want if orderlots >= lotb then it will stop trading and wait for new condition! However it didnt stop and countinute trade until profitable result