Checking and Modifying Code So it Works

MQL5 专家

指定

Hello,



i have this EA attached but its not working as it should on demo account. When using the strategy tester its different and good but

on demo account its opens randomly orders any lot amount and not as it should be. You should check the EA and modify it so its working in demo account correctly as

in the strategy tester. You can test it in EURUSD H1 for the last 9 months (default settings).



Thank youextern bool StopOrders=true;
extern bool LimitOrders=true;
extern bool CloseLock=FALSE;
extern double ProfitMultiplier=3;
extern string DateToStart="01.02.2012 00:00";
extern double Spread=2;
extern double OrdersCount=5;
extern double OrderDistance=20;
extern double TralDistance=5;
extern double TralStart=5;
extern double TralStep=5;
extern bool SimpleTraling=FALSE;
extern double Lot=0.1;
extern double LotAddon=0.01;
extern int MartingaleOrders=10;
extern double SL=0;
extern double TP=0;
extern int Slippage=3;
extern string st1="Параметры индикатора Линии безубытка";
extern double Profit=0; // Размер предполагаемой прибыли в тиках (0,1 пункта)
extern double Commission=6; // Размер комиссии в USD - сумма за открытие и закрытие позиции в 1 лот = 6 для Альпари счета NDD
extern color ColorBuy = MediumBlue;
extern color ColorSell = FireBrick;
extern color ColorBuyAll = C'132,132,255';
extern color ColorSellAll = C'227,113,113';
string Buy = "LineBuy";
string BuyPrice = "PriceLineBuy";
string Sell = "LineSell";
string SellPrice = "PriceLineSell";
string BuyAll = "LineBuyAll";
string BuyAllPrice = "PriceLineAllBuy";
string SellAll = "LineSellAll";
string SellAllPrice = "PriceLineAllSell";
double z,MagicNumber=0;

int x=1;
double p20,firstbuyprice,BuyProfit,SellProfit,Level;
double buys[150][2],sells[150][2];
int buyC=-1,sellC=-1;
int tickettoclose1=0,tickettoclose2=0;
double lowestbuy=0.0,highestsell=0.0,lowestsell=0.0,highestbuy=0.0,bigestlotbuy=0.0,bigestlotsell=0.0,bigestlotbuyprice=0.0,bigestlotsellprice=0.0;
string dobavochniy;

int init(){
Spread=Spread*Point*x;
if(Digits==3 || Digits==5)x=10;
TP=TP*Point*x;
SL=SL*Point*x;
TralStart=TralStart*Point*x;
TralDistance=TralDistance*Point*x;
TralStep=TralStep*Point*x;
p20=OrderDistance*Point*x;
if(StringFind(AccountCompany(),"FOREX.com",0)>=0)
 dobavochniy="FXF";
}

int start(){
firstbuyprice=MathMod(Ask/Point/x,OrderDistance)*Point*x;
firstbuyprice=Ask-firstbuyprice;
Level=MarketInfo(Symbol(),MODE_FREEZELEVEL)*Point*x;
/*
if(AccountProfit()<-100)
 for(int w=OrdersTotal()-1;w>=0;w--)
  if(OrderSelect(w,SELECT_BY_POS))
   {if(OrderType()<2) OrderClose(OrderTicket(),OrderLots(),NO(OrderClosePrice()),3);
    else OrderDelete(OrderTicket());
   }*/

double loosestprofit=0.0;
int loosestticket=-1;

int otl=0,oppened=0;
buyC=-1;sellC=-1;
lowestbuy=0.0;highestsell=0.0;lowestsell=0.0;highestbuy=0.0;bigestlotbuy=0.0;bigestlotsell=0.0;bigestlotbuyprice=0.0;bigestlotsellprice=0.0;
double prof1=0.0,prof2=0.0;
int tiks1=0,tiks2=0;
for(int i=OrdersTotal()-1;i>=0;i--)
 if(OrderSelect(i,SELECT_BY_POS))
  {if(OrderType()<2)oppened++;else otl++;
   if(loosestprofit>OrderProfit() && OrderProfit()<0) {loosestprofit=OrderProfit();loosestticket=OrderTicket();}
   if(OrderMagicNumber()==5513 || OrderMagicNumber()==5514)
    if(!OrderDelete(OrderTicket()))return;
   if(OrderType()==0)
    {buyC++;
     buys[buyC][0]=OrderOpenPrice();
     buys[buyC][1]=PointCost(0.01,Symbol())*(OrderLots()/0.01);
     if(NO(lowestbuy)==0.0 || lowestbuy>OrderOpenPrice()){prof1=OrderProfit();tiks1=OrderTicket();lowestbuy=OrderOpenPrice();}
     if(highestbuy<OrderOpenPrice())highestbuy=OrderOpenPrice();
     if(OrderLots()>bigestlotbuy){bigestlotbuy=OrderLots();bigestlotbuyprice=OrderOpenPrice();}
    }
   if(OrderType()==1)
    {sellC++;
     sells[sellC][0]=OrderOpenPrice();
     sells[sellC][1]=PointCost(0.01,Symbol())*(OrderLots()/0.01);
     if(highestsell<OrderOpenPrice()){prof2=OrderProfit();tiks2=OrderTicket();highestsell=OrderOpenPrice();}
     if(NO(lowestsell)==0.0 || lowestsell>OrderOpenPrice())lowestsell=OrderOpenPrice();
     if(OrderLots()>bigestlotbuy){bigestlotsell=OrderLots();bigestlotsellprice=OrderOpenPrice();}
    }
  }

bool needreturn=false;

//Comment(tickettoclose1," ",tickettoclose2);
bool needopenmagic=false,needclosemagic=false;
int ticmagicorder=0;
if(tickettoclose1!=0 && tickettoclose2!=0)
 {for(int tr=0;tr<=OrdersHistoryTotal()-1;tr++)
   {if(!OrderSelect(tr,SELECT_BY_POS,MODE_HISTORY)) {Alert("!!!Не выбран ордер истории!!!");return(-100500);}
    if(OrderOpenTime()<StrToTime(DateToStart))break;
    if(OrderSymbol()!=Symbol() || OrderMagicNumber()<5513 || OrderMagicNumber()>5514)continue;
    if(OrderMagicNumber()==5513) {needopenmagic=true;break;}
   }
  if(!needopenmagic)
   {ticmagicorder=OrderSend(Symbol(),4,MarketInfo(Symbol(),MODE_MINLOT),NO(Ask+500*Point*x),3,NO(Ask+485*Point*x),NO(Ask+520*Point*x),"",5513);
    if(ticmagicorder==-1)return;
    if(!OrderDelete(ticmagicorder))return;
   }
 }

if(tickettoclose1==0 && tickettoclose2==0)
 {for(tr=0;tr<=OrdersHistoryTotal()-1;tr++)
  {if(!OrderSelect(tr,SELECT_BY_POS,MODE_HISTORY)) {Alert("!!!Не выбран ордер истории!!!");return(-100500);}
   if(OrderOpenTime()<StrToTime(DateToStart))break;
   if(OrderSymbol()!=Symbol() || OrderMagicNumber()<5513 || OrderMagicNumber()>5514)continue;
   if(OrderMagicNumber()==5514) {needclosemagic=true;break;}
  }
 if(!needclosemagic)
  {ticmagicorder=OrderSend(Symbol(),4,MarketInfo(Symbol(),MODE_MINLOT),NO(Ask+500*Point*x),3,NO(Ask+485*Point*x),NO(Ask+520*Point*x),"",5514);
   if(ticmagicorder==-1)return;
   if(!OrderDelete(ticmagicorder))return;
  }
}
 
if(tickettoclose1>0)
 {if(OrderSelect(tickettoclose1,SELECT_BY_TICKET) && OrderCloseTime()==0.0)
   {if(OrderClose(tickettoclose1,OrderLots(),NO(OrderClosePrice()),3))tickettoclose1=0;needreturn=true;}
  else tickettoclose1=0;
 }
 
if(tickettoclose2>0)
 {if(OrderSelect(tickettoclose2,SELECT_BY_TICKET) && OrderCloseTime()==0.0)
   {if(OrderClose(tickettoclose2,OrderLots(),NO(OrderClosePrice()),3))tickettoclose2=0;needreturn=true;}
  else tickettoclose2=0;
 }

if(needreturn)return;

if(NO(lowestbuy)>0.0 && NO(highestsell)>0.0 && lowestbuy<highestsell && NO(prof1+prof2)>0.0 && CloseLock)
 {tickettoclose1=tiks1; 
  tickettoclose2=tiks2;
 }


double sumtoclose=0;
double io1=0,io2=0;
bool maycount=true;
for(tr=OrdersHistoryTotal()-1;tr>=0;tr--)
 {if(!OrderSelect(tr,SELECT_BY_POS,MODE_HISTORY)) {Alert("!!!Не выбран ордер истории!!!");return(-100500);}
  if(OrderOpenTime()<StrToTime(DateToStart))break;//if(OrderType()<2)Comment(OrderProfit()," ",OrderMagicNumber()," ",maycount," ",sumtoclose);
  if(OrderSymbol()!=Symbol() || OrderMagicNumber()<5512 || OrderMagicNumber()>5514)continue;
  if(OrderMagicNumber()==5514)maycount=false;
  if(OrderMagicNumber()==5513)maycount=true;
  if(OrderType()>1)continue;
  if(!maycount)continue;
    
  if(OrderProfit()<0)break;
  sumtoclose=sumtoclose+OrderProfit()+OrderSwap()+OrderCommission();
  //if(OrderProfit()<0)io2+=OrderProfit();else io1+=OrderProfit();
 }

if(NO(loosestprofit)!=0.0)Comment(loosestprofit," ",sumtoclose," ",MathAbs(sumtoclose/loosestprofit));

if(NO(loosestprofit)<0.0 && sumtoclose>0)
 if(MathAbs(sumtoclose/loosestprofit)>ProfitMultiplier)
  if(OrderSelect(loosestticket,SELECT_BY_TICKET))
   {OrderClose(OrderTicket(),OrderLots(),OrderClosePrice(),3);
    return;
   }
  
//Comment("Отложенников ",otl," Открытых ",oppened);

StandPending();
DeleteUnnecessary();
if(SimpleTraling)TralOrders();
TralAllOrders();

   int counted_bars=IndicatorCounted();
   //if(Digits==2) z=0.01;
   if(Digits==3) z=0.001;
   //if(Digits==4) z=0.0001;
   if(Digits==5) z=0.00001;
   double PB = Price(Symbol(), OP_BUY, MagicNumber, Profit);
   double PS = Price(Symbol(), OP_SELL, MagicNumber, Profit);
   if (ObjectFind(Buy)==-1) ObjectCreate(Buy,OBJ_TREND,0,Time[5],PB,Time[0]+Period()*60*20,PB);
   ObjectSet(Buy,OBJPROP_TIME1,Time[5]);
   ObjectSet(Buy,OBJPROP_PRICE1,PB);
   ObjectSet(Buy,OBJPROP_TIME2,Time[0]+Period()*60*20);
   ObjectSet(Buy,OBJPROP_PRICE2,PB);
   ObjectSet(Buy,OBJPROP_RAY,false);
   ObjectSet(Buy,OBJPROP_COLOR,ColorBuy);
   if (ObjectFind(Sell)==-1) ObjectCreate(Sell,OBJ_TREND,0,Time[5],PS,Time[0]+Period()*60*20,PS);
   ObjectSet(Sell,OBJPROP_TIME1,Time[5]);
   ObjectSet(Sell,OBJPROP_PRICE1,PS);
   ObjectSet(Sell,OBJPROP_TIME2,Time[0]+Period()*60*20);
   ObjectSet(Sell,OBJPROP_PRICE2,PS);
   ObjectSet(Sell,OBJPROP_RAY,false);
   ObjectSet(Sell,OBJPROP_COLOR,ColorSell);
   if (ObjectFind(BuyPrice)==-1) ObjectCreate(BuyPrice,OBJ_ARROW,0,Time[5],PB);
   ObjectSet(BuyPrice,OBJPROP_TIME1,Time[5]);
   ObjectSet(BuyPrice,OBJPROP_PRICE1,PB);
   ObjectSet(BuyPrice,OBJPROP_ARROWCODE,5); 
   ObjectSet(BuyPrice,OBJPROP_COLOR,ColorBuy);
   if (ObjectFind(SellPrice)==-1) ObjectCreate(SellPrice,OBJ_ARROW,0,Time[5],PS);
   ObjectSet(SellPrice,OBJPROP_TIME1,Time[5]);
   ObjectSet(SellPrice,OBJPROP_PRICE1,PS);
   ObjectSet(SellPrice,OBJPROP_ARROWCODE,5); 
   ObjectSet(SellPrice,OBJPROP_COLOR,ColorSell);
   double PBAll = PriceBUYAll(Symbol(), MagicNumber, Profit);
   double PSAll = PriceSELLAll(Symbol(), MagicNumber, Profit);
   if (ObjectFind(BuyAll)==-1) ObjectCreate(BuyAll,OBJ_TREND,0,Time[5],PBAll,Time[0]+Period()*60*20,PBAll);
   ObjectSet(BuyAll,OBJPROP_TIME1,Time[5]);
   ObjectSet(BuyAll,OBJPROP_PRICE1,PBAll);
   ObjectSet(BuyAll,OBJPROP_TIME2,Time[0]+Period()*60*20);
   ObjectSet(BuyAll,OBJPROP_PRICE2,PBAll);
   ObjectSet(BuyAll,OBJPROP_RAY,false);
   ObjectSet(BuyAll, OBJPROP_STYLE, STYLE_DASH);
   ObjectSet(BuyAll,OBJPROP_COLOR,ColorBuyAll);
   if (ObjectFind(SellAll)==-1) ObjectCreate(SellAll,OBJ_TREND,0,Time[5],PSAll,Time[0]+Period()*60*20,PSAll);
   ObjectSet(SellAll,OBJPROP_TIME1,Time[5]);
   ObjectSet(SellAll,OBJPROP_PRICE1,PSAll);
   ObjectSet(SellAll,OBJPROP_TIME2,Time[0]+Period()*60*20);
   ObjectSet(SellAll,OBJPROP_PRICE2,PSAll);
   ObjectSet(SellAll,OBJPROP_RAY,false);
   ObjectSet(SellAll, OBJPROP_STYLE, STYLE_DASH);
   ObjectSet(SellAll,OBJPROP_COLOR,ColorSellAll);
   if (ObjectFind(BuyAllPrice)==-1) ObjectCreate(BuyAllPrice,OBJ_ARROW,0,Time[5],PBAll);
   ObjectSet(BuyAllPrice,OBJPROP_TIME1,Time[5]);
   ObjectSet(BuyAllPrice,OBJPROP_PRICE1,PBAll);
   ObjectSet(BuyAllPrice,OBJPROP_ARROWCODE,5); 
   ObjectSet(BuyAllPrice,OBJPROP_COLOR,ColorBuyAll);
   if (ObjectFind(SellAllPrice)==-1) ObjectCreate(SellAllPrice,OBJ_ARROW,0,Time[5],PSAll);
   ObjectSet(SellAllPrice,OBJPROP_TIME1,Time[5]);
   ObjectSet(SellAllPrice,OBJPROP_PRICE1,PSAll);
   ObjectSet(SellAllPrice,OBJPROP_ARROWCODE,5); 
   ObjectSet(SellAllPrice,OBJPROP_COLOR,ColorSellAll);
   
}

bool TralAllOrders(){
double ThePrice=0,TheSumm=0;
if(lowestbuy<Bid && buyC>=0) 
 {int yu=NormalizeDouble((Bid-TralDistance-lowestbuy)/Point/x,0);
  for(int cikl=yu;cikl>=yu-(TralStep+3*Point*x)/Point/x;cikl--)
   {ThePrice=lowestbuy+cikl*Point*x;
    if(Bid-ThePrice<Level)continue;
    TheSumm=0;
    for(int i=0;i<=buyC;i++)
     TheSumm=TheSumm+(ThePrice-buys[i][0])*buys[i][1];
    if(TheSumm>0)
     {for(i=0;i<OrdersTotal();i++)
       if(OrderSelect(i,SELECT_BY_POS) && OrderType()==0 && ThePrice-OrderStopLoss()>=TralStep)
        OrderModify(OrderTicket(),OrderOpenPrice(),NO(ThePrice),OrderTakeProfit(),0);
      break;
     }
   }
 }

ThePrice=0;TheSumm=0;
if(highestsell>Ask && sellC>=0) 
 {yu=NormalizeDouble((highestsell-Ask-TralDistance)/Point/x,0);
  for(cikl=yu;cikl>=yu-(TralStep+3*Point*x)/Point/x;cikl--)
   {ThePrice=highestsell-cikl*Point*x;
    if(ThePrice-Ask<Level)continue;
    TheSumm=0;
    for(i=0;i<=sellC;i++)
     TheSumm=TheSumm+(sells[i][0]-ThePrice)*sells[i][1];
    if(TheSumm>0)
     {for(i=0;i<OrdersTotal();i++)
       if(OrderSelect(i,SELECT_BY_POS) && OrderType()==1 && (OrderStopLoss()-ThePrice>=TralStep || NO(OrderStopLoss())==0.0))
         OrderModify(OrderTicket(),OrderOpenPrice(),NO(ThePrice),OrderTakeProfit(),0);
      break;
     }
   }
 }
}

bool TralOrders(){
double nTral;
for(int i=OrdersTotal()-1;i>=0;i--)
 if(OrderSelect(i,SELECT_BY_POS) && OrderType()<2 && NO(OrderStopLoss())==0.0) 
  {if(OrderType()==0)
    {nTral=Bid-TralDistance;
     if(Bid-OrderOpenPrice()>TralStart)
      {OrderModify(OrderTicket(),OrderOpenPrice(),NO(nTral),OrderTakeProfit(),0);}
    }
   if(OrderType()==1)
    {nTral=Ask+TralDistance;
     if(OrderOpenPrice()-Ask>TralStart)
      OrderModify(OrderTicket(),OrderOpenPrice(),NO(nTral),OrderTakeProfit(),0);
    }
  }
}

bool StandPending(){
double oppr;
for(int i=1;i<=OrdersCount;i++)
 {oppr=firstbuyprice+p20*i;
  if(StopOrders)OpenOrder(4,oppr,i);
  if(LimitOrders)OpenOrder(3,oppr+Spread,i);
 }
firstbuyprice+=p20;
for(i=1;i<=OrdersCount;i++)
 {oppr=firstbuyprice-p20*i;
  if(StopOrders)OpenOrder(5,oppr+Spread,i);
  if(LimitOrders)OpenOrder(2,oppr,i);
 }
firstbuyprice-=p20;

}

bool DeleteUnnecessary(){
for(int i=OrdersTotal()-1;i>=0;i--)
 if(OrderSelect(i,SELECT_BY_POS) && (NO(OrderOpenPrice())>NO(firstbuyprice+p20*OrdersCount+Spread*OrdersCount) || NO(OrderOpenPrice())<NO(firstbuyprice+p20-p20*OrdersCount)) && OrderType()>1)
  OrderDelete(OrderTicket());
}

bool OrderExist(int fType,int sType,int stType,double opPrice,double &lotes,int &tik){
for(int i=OrdersTotal()-1;i>=0;i--)
 if(OrderSelect(i,SELECT_BY_POS) && NO(OrderOpenPrice())==NO(opPrice) && (OrderType()==fType || OrderType()==sType || OrderType()==stType))
  {lotes=OrderLots();tik=OrderTicket();return(true);}

return(false);
}

bool OpenOrder(int ordType, double opPrice,int countorder){
double sl=0,tp=0;
int ttiik=0;
if(ordType==0 || ordType==2 || ordType==4)
 {if(NO(SL)!=0.0)sl=NO(opPrice-SL);
  if(NO(TP)!=0.0)tp=NO(opPrice+TP);
 }
 
if(ordType==1 || ordType==3 || ordType==5)
 {if(NO(SL)!=0.0)sl=NO(opPrice+SL);
  if(NO(TP)!=0.0)tp=NO(opPrice-TP);
 }
 
double nowlot=Lot,lotfromexist=0;
int mnogitel=0;
if(ordType==2 || ordType==4)
 {mnogitel=MathAbs(NormalizeDouble((bigestlotbuyprice-opPrice)/p20,0));
  if(mnogitel>MartingaleOrders)mnogitel=0;
  nowlot=bigestlotbuy+mnogitel*LotAddon;
  if(NO(bigestlotbuy)==0.0)nowlot=Lot;
 }
if(ordType==3 || ordType==5)
 {mnogitel=MathAbs(NormalizeDouble((opPrice-bigestlotsellprice)/p20,0));
  if(mnogitel>MartingaleOrders)mnogitel=0;
  nowlot=bigestlotsell+mnogitel*LotAddon;
  if(NO(bigestlotsell)==0.0)nowlot=Lot;
 }
//if(ordType==2 || ordType==4)nowlot=bigestlotbuy+countorder*LotAddon;
//if(ordType==3 || ordType==5)nowlot=bigestlotsell+countorder*LotAddon;
//if(NO(nowlot)>NO(MartingaleOrders*LotAddon))nowlot=Lot;

bool orhere=false;


 {if(ordType==4) orhere=OrderExist(0,2,4,opPrice,lotfromexist,ttiik);
  if(ordType==5) orhere=OrderExist(1,3,5,opPrice,lotfromexist,ttiik);
  if(orhere && NO(Lots(nowlot))!=NO(Lots(lotfromexist)))
   {if(OrderType()>1) OrderDelete(ttiik);}
  if(orhere)return;
 }

orhere=false;


 {if(ordType==3)orhere=OrderExist(1,3,5,opPrice,lotfromexist,ttiik);
  if(ordType==2)orhere=OrderExist(0,2,4,opPrice,lotfromexist,ttiik);
  if(orhere && NO(Lots(nowlot))!=NO(Lots(lotfromexist)))
   {if(OrderType()>1) OrderDelete(ttiik);}
  if(orhere)return;
 }
 
int ticket=OrderSend(Symbol(),ordType,Lots(nowlot),NO(opPrice),Slippage,NO(sl),NO(tp),"",5512,0,CLR_NONE);
}

double Lots(double pos){
double lot;
if(pos==-1)return(-1);
lot=pos;
 lot=MathMin(MarketInfo(Symbol(),MODE_MAXLOT),lot);
 lot=MathMax(MarketInfo(Symbol(),MODE_MINLOT),lot);
 if(MarketInfo(Symbol(),MODE_MINLOT)>Lot)
  {Alert(Symbol()+" Минимальный допустимый лот="+MarketInfo(Symbol(),MODE_MINLOT)+" больше чем Lot="+Lot);return(-1);}
 return(NormalizeDouble(lot,2));
}

double NO(double pp){return(NormalizeDouble(pp,Digits));}

double PointCost(double clots,string symb){
if(IsTesting() || IsVisualMode())return(clots*10);
string str="";
int localdigits=MarketInfo(symb,MODE_DIGITS);
if(localdigits==3 || localdigits==5)localdigits=localdigits-1;
if(StringSubstr(symb,3,3)=="USD")return(clots*100000*MathPow(0.1,localdigits)); else
if(StringSubstr(symb,0,3)=="USD")return(clots*100000*MathPow(0.1,localdigits)/MarketInfo(symb,10));else
 {if(StringSubstr(symb,0,3)=="EUR")str="EURUSD"+dobavochniy;else
  if(StringSubstr(symb,0,3)=="GBP")str="GBPUSD"+dobavochniy;else
  if(StringSubstr(symb,0,3)=="CHF")str="USDCHF"+dobavochniy;else
  if(StringSubstr(symb,0,3)=="CAD")str="USDCAD"+dobavochniy;else
  if(StringSubstr(symb,0,3)=="AUD")str="AUDUSD"+dobavochniy;else
  if(StringSubstr(symb,0,3)=="NZD")str="NZDUSD"+dobavochniy;
  return(clots*100000*MathPow(0.1,localdigits)*MarketInfo(str,10)/MarketInfo(symb,10));
 }
if(GetLastError()==4066)Alert("ошибка 4066 Запрошенные исторические данные в состоянии обновления ");
return(0);
}

//---------------------------------------------------------------------------------------------------------------------
void deinit()
  {if (ObjectFind(Buy)!=-1) ObjectDelete(Buy);
   if (ObjectFind(Sell)!=-1) ObjectDelete(Sell);
   if (ObjectFind(BuyAll)!=-1) ObjectDelete(BuyAll);
   if (ObjectFind(SellAll)!=-1) ObjectDelete(SellAll);
   if (ObjectFind(BuyPrice)!=-1) ObjectDelete(BuyPrice);
   if (ObjectFind(SellPrice)!=-1) ObjectDelete(SellPrice);
   if (ObjectFind(BuyAllPrice)!=-1) ObjectDelete(BuyAllPrice);
   if (ObjectFind(SellAllPrice)!=-1) ObjectDelete(SellAllPrice);
  }
  
double Price(string fSymbol, int fType, int fMagic=0, double MyProfit=0) //Функция возвращает цену, на которую необходимо установить уровень TakeProfit, чтобы получить прибыль Profit, для открытых ордеров
  {double SummPrice=0, SummLots=0, Formula=0, StoimTik, SummSwap=0, SummCom=0;
   int k;
   int total = OrdersTotal();
   for (int i=total-1; i>=0; i--)
     {OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
      if(OrderSymbol()==fSymbol)
        {if(OrderMagicNumber()==fMagic || fMagic==0)
           {if(OrderType()==fType)
              {k++;
               StoimTik=MarketInfo(fSymbol,MODE_TICKVALUE)/(MarketInfo(fSymbol,MODE_TICKSIZE)/MarketInfo(fSymbol,MODE_POINT)); //Стоимость 1 тика при ордере в 1 лот
               if(OrderSwap()!=0) SummSwap+=OrderSwap()/StoimTik;
               if(Commission>0)
                 {if(AccountCurrency()=="RUR") SummCom=Commission*MarketInfo("USDRUR",MODE_BID)/StoimTik;
                  if(AccountCurrency()=="USD") SummCom=Commission/StoimTik;
                 }
               SummLots+=OrderLots();
               SummPrice+=OrderOpenPrice()*OrderLots();
              }
           }
        }
     }//Next i  
   if(k>0)
     {if(fType==OP_BUY) Formula=SummPrice/SummLots+z*(SummCom+MyProfit-SummSwap/SummLots);
      if(fType==OP_SELL) Formula=SummPrice/SummLots-z*(SummCom+MyProfit-SummSwap/SummLots);
     }
   return(Formula);
  }//Price()
//+------------------------------------------------------------------+
double PriceBUYAll(string fSymbol, int fMagic=0, double MyProfit=0) //Функция возвращает цену, на которую необходимо установить уровень TakeProfit, чтобы получить прибыль Profit, для всех ордеров BUY
  {double SummPrice=0, SummLots=0, Formula=0, StoimTik, SummSwap=0, SummCom=0;
   int k;
   int total = OrdersTotal();
   for (int i = total-1; i >= 0; i--)
     {OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
      if(OrderSymbol()==fSymbol)
        {if(OrderMagicNumber()==fMagic || fMagic==0)
           {if(OrderType()==OP_BUY || OrderType()==OP_BUYSTOP || OrderType()==OP_BUYLIMIT)
              {if(OrderType()==OP_BUYSTOP || OrderType()==OP_BUYLIMIT) k++;
               if (OrderSwap()!=0 || Commission!=0)
                 {StoimTik=MarketInfo(fSymbol,MODE_TICKVALUE)/(MarketInfo(fSymbol,MODE_TICKSIZE)/MarketInfo(fSymbol,MODE_POINT)); //Стоимость 1 тика при ордере в 1 лот
                  SummSwap+=OrderSwap()/StoimTik;
                  if(AccountCurrency()=="RUR") SummCom=Commission*MarketInfo("USDRUR",MODE_BID)/StoimTik;
                  if(AccountCurrency()=="USD") SummCom=Commission/StoimTik;
                 }
               SummLots+=OrderLots();
               SummPrice+=OrderOpenPrice()*OrderLots();
              }
            if(k>0) Formula=SummPrice/SummLots+z*(SummCom+MyProfit-SummSwap/SummLots);
           }
        }
     }//Next i  
   return(Formula);
  }//PriceBUYAll()
//+------------------------------------------------------------------+
double PriceSELLAll(string fSymbol, int fMagic=0, double MyProfit=0) //Функция возвращает цену, на которую необходимо установить уровень TakeProfit, чтобы получить прибыль Profit, для всех ордеров SELL
  {double SummPrice=0, SummLots=0, Formula=0, StoimTik, SummSwap=0, SummCom=0;
   int k;
   int total = Order

反馈

1
开发者 1
等级
(44)
项目
60
53%
仲裁
3
0% / 0%
逾期
1
2%
工作中
2
开发者 2
等级
项目
0
0%
仲裁
0
逾期
0
工作中
3
开发者 3
等级
(473)
项目
535
33%
仲裁
27
41% / 44%
逾期
8
1%
繁忙
4
开发者 4
等级
项目
0
0%
仲裁
0
逾期
0
空闲
5
开发者 5
等级
(9)
项目
14
14%
仲裁
6
0% / 50%
逾期
1
7%
工作中
6
开发者 6
等级
项目
1
0%
仲裁
1
0% / 0%
逾期
0
工作中
7
开发者 7
等级
(17)
项目
19
26%
仲裁
3
67% / 33%
逾期
2
11%
工作中
相似订单
i need an ea triggered as soon as parabolic sar indicator changes its signal to buy or sell and open same size orders with an option to add additional 0.01 or a diferent value to the initial lot on every next order no matter if it is buy or sell i need it to open orders in a (value) pips or price distance. using only a tp no stop loss. and close all orders on tp in money also i need a trailing stop in case price
The goal is that if SL changes, TP1 and only TP1 changes by the same distance as SL. If there's also TP2, TP3 or TP4, then those levels aren't modified
I am looking for MQL5 coding expert to create a trading bot of my strategy. I am an HFT and looking to automate my gold trading strategy. The strategy is very simple and uses only one indicator that is RSI and also look for chart patterns. I want to keep it generic by not doing any hardcoding of position size, lot size, etc. and code should be easy to understand and manipulate in future
Good programme Skill needed, ability to built high frequency trading (hft) expert advisor that works on MT4 and MT5 no Grid, no Matin. just Short term trade that last 1sec - 5mins for profit take, that can be used to trade on demo and live accounts RAW ECN icmarket, Blackbullmarket, Fusion market, FPMarkets and 8cap. The EA has to be highly profitable, giving daily profit. If a test version is available, please send
EA's logic and trade 100 - 1200 USD
Good day, I hope this message finds you well. I would like to request the development of an Expert Advisor (EA) for MetaTrader, based on two specific indicators: the Trend Path indicator and the Diamond Reversal indicator. Below are the details for the EA's logic and trade execution criteria: Sell Trade Criteria: Indicators and Signals: Trend Path Indicator : Shows a red trend. Diamond Reversal Indicator : Provides a
Pls the bot take trade from any arrow indicator on the chart with buffer value buy or sell to place trade . The bot have 5 indicator filter to filter trade like rsi , sma , awesome oscillator, parabolic sar and ichimoku before the bot place trade. pls for detail about the bot and filter pls check the screenshot file
Can anyone build a MT4 or MT5 EA based off an indicator from Trading View. If so, please check Simple EMA Trend Filter (GTA Trend Filter EMA) Alternatively, if you can Automate this indicator via any connector like Pine Connector, that will work too. Please let me know. Thank you Sam
Good day I would like a new EA that removes other EA's when a certain drawdown is reached (e.g., 20%) The new EA must also create a perfect hedge after removing the other EA's. E.g., If there are xauusd sell trades with lot sum 10 and a drawdown of 20%, the new EA must stop and remove the other EA's then open lot sum 10 buy trades of the same pair. Or if lot sum 0.12 sell trades and lot sum 0.02 buy trades are open
our exciting software developer isnt responding to the bugs he made in the mt5 ea now we need somebody for the long run that can fix the bugs and also add additional fuction in the future feel free to contact me
I want a simple EA that is based on 2 envelopes(indicator). * The EA should open trades only when price is at the envelopes. * The EA should allow me to select my sl and my tp in points. * The EA should allow me to choose between buying and selling only(For each chart it's on) * The EA should also allow me to choose a manual lot size. Source code is required for further optimazition

项目信息

预算
200+ USD
截止日期
 2 天

客户

所下订单2
仲裁计数0