//+------------------------------------------------------------------+ //| Kir Janja010.mq4 | //| ljubas | //+------------------------------------------------------------------+ ... ... ... //-------------------------------------------------------------------- int init() { ... ... ... return(0); } //-------------------------------------------------------------------- int start() { ... ... ... // BUYING CONDITIONS if( IsTradeTime() && CountOrders(Magic,OP_BUY) > 0 && LastBuyPrice >= NormalizeDouble(Ask,Decimal) && CountOrders(Magic,OP_BUY) < MaxOrders ) OpenbyBuying(False); // Buy More To Save Wrong Buy if( IsTradeTime() && iStochastic(NULL,PERIOD_H1,5,3,3,MODE_SMA,0,MODE_MAIN, 1) < 60 && ... ... ... CountOrders(Magic,OP_BUY) < 1 ) OpenbyBuying(False); // Buy first one //-------------------------------------------------------------------- //-------------------------------------------------------------------- //-------------------------------------------------------------------- // SELLING CONDITIONS if( IsTradeTime() && CountOrders(Magic,OP_SELL) > 0 && LastSellPrice <= NormalizeDouble(Bid,Decimal) && CountOrders(Magic,OP_SELL) < MaxOrders ) OpenbySelling(False); // Sell More To Save Wrong Sell if( IsTradeTime() && iStochastic(NULL,PERIOD_H1,5,3,3,MODE_SMA,0,MODE_MAIN, 1) > 40 && ... ... ... CountOrders(Magic,OP_SELL) < 1 ) OpenbySelling(False); // Sell first one //-------------------------------------------------------------------- return(0); // Exit start() } ... ... ... //-------------------------------------------------------------------- //-------------------------------------------------------------------- //-------------------------------------------------------------------- void OpenbyBuying(bool Safe) { double Iznos = NormalizeDouble(LotsOptimized() * MultiplierBuy/15,2); if (Iznos < 0.1) Iznos = 0.1; OrderSend(Symbol(),OP_BUY,Iznos,NormalizeDouble(Ask,Decimal),3,0,0,EA_Tester,Magic); LastBuy = TimeCurrent(); return(0); } //-------------------------------------------------------------------- //-------------------------------------------------------------------- //-------------------------------------------------------------------- void OpenbySelling(bool Safe) { double Iznos = NormalizeDouble(LotsOptimized() * MultiplierSell/15,2); if (Iznos < 0.1) Iznos = 0.1; OrderSend(Symbol(),OP_SELL,Iznos,NormalizeDouble(Bid,Decimal),3,0,0,EA_Tester,Magic); LastSell = TimeCurrent(); return(0); } //-------------------------------------------------------------------- //-------------------------------------------------------------------- //-------------------------------------------------------------------- int CountOrders(int Magic, int alType) { int _CountOrd = 0; for(int i=0;i0) { for(int i=orders-1; i >= 0; i--) { if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY)==false) { Print("Error in history!"); break; } if(OrderSymbol()!=Symbol() || OrderMagicNumber()!=Magic || OrderType()>OP_SELL) continue; //---- if(OrderProfit() > 0) break; if(OrderProfit() < 0) losses++; } if(losses > 1) lot = NormalizeDouble(lot-lot*losses/DecreaseFactor,1); } //---- return lot size lot = NormalizeDouble(AccountEquity()/5000,2); if(lot > 999) lot = 999; //if(lot < MinLot) lot = MinLot; return(lot); } //+-------------------End Calculate optimal lot size-----------------+ //-------------------------------------------------------------------- //-------------------------------------------------------------------- //-------------------------------------------------------------------- bool IsTradeTime() { if (Hour() < 12) return (false); return (true); } //-------------------------------------------------------------------- //-------------------------------------------------------------------- //--------------------------------------------------------------------