Little closing position problem on my EA

MQL4 Эксперты C++

Работа завершена

Время выполнения 2 минуты
Отзыв от заказчика
Great job, very professional and fast.
Отзыв от исполнителя
Great customer, very co-operative and easy to work with.

Техническое задание

Hello,
when I close my position manually all is well my EA works great,
but when I close my position with another EA it does not go.


Example:

I drag my EA on my chart the first order opens at 0.01 and if my StopLoss is hit it opens
a second position at 0.02 and if my SL is hit he opens a position at 0.03 ect ... and it works well
but when I get in profit and my other EA closes the position and they close them well, my EA should
start again from the beginning 0.01 then 0.02 then 0.03 ect .. but it opens my first position to 0.02
and if my trade is a winner it goes to 0.03 instead of 0.01.



I put you the other EA that closes the positions.

#property copyright "xxx"
#property link      "http://www.mql5.com"
#property version   "1.00"
#property strict
extern double  lots1          = 0.01;
extern double  lots2          = 0.02;
extern double  lots3          = 0.03;
extern double  lots4          = 0.04;
extern double  lots5          = 0.05;

input int      TakeProfit1     =   1000  ;
input int      StopLoss1       =   3  ;
input int      TakeProfit2     =   1000  ;
input int      StopLoss2       =   2  ;
input int      TakeProfit3     =   1000  ;
input int      StopLoss3       =   3  ;
input int      TakeProfit4     =   1000  ;
input int      StopLoss4       =   4  ;
input int      TakeProfit5     =   1000  ;
input int      StopLoss5       =   4  ;


extern int     magic          = 111112;
//extern double  Level          = 1.3509;
//extern double  MaxDeviation   = 9;         // Max Deviation, points

bool RunOnce=false;


int last_order_check = false;

datetime EaStartTime=TimeCurrent();




double takeprofit1=TakeProfit1;
double stoploss1 =StopLoss1;
double takeprofit2=TakeProfit2;
double stoploss2 =StopLoss2;
double takeprofit3=TakeProfit3;
double stoploss3 =StopLoss3;
double takeprofit4=TakeProfit4;
double stoploss4 =StopLoss4;
double takeprofit5=TakeProfit5;
double stoploss5 =StopLoss5;

//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()

  {
   RunOnce=false;
   MathSrand(GetTickCount());
   if(Digits==5 || Digits==3)
     {
      takeprofit1  =TakeProfit1*10;
      stoploss1    =StopLoss1*10;
      takeprofit2  =TakeProfit2*10;
      stoploss2    =StopLoss2*10;
      takeprofit3  =TakeProfit3*10;
      stoploss3    =StopLoss3*10;
      takeprofit4  =TakeProfit4*10;
      stoploss4    =StopLoss4*10;
      takeprofit5  =TakeProfit5*10;
  
     }
   return(INIT_SUCCEEDED);
  }
 
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnTimer()
{
OnTick();        
}
void OnDeinit(const int reason)
  {
//---
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
{

  if(IsLastOrderClose())
    {
    OnInit();
    Print("Ea Closed Manually ");
    EaStartTime=TimeCurrent();
    }

   int ticet;
   int t=MathRand();
  
   if(CountVsego()==0)
     {
      if(t>16384)
        {
         if(Counts()==0)// && (RunOnce || (Ask >=Level && Ask<=Level+(MaxDeviation*_Point) && Level !=0)))
         {
            ticet=OrderSend(Symbol(),OP_BUY,lots1,Ask,3,Bid-stoploss1*Point,Ask+takeprofit1*Point,"1",magic,0,clrGreen);
            if(ticet>0)
            {
               RunOnce=true;
            }
         }
        }
// Partie 1 
     else if(t<16384)
        {
         if(Counts()==0)// && (RunOnce || (Bid <=Level && Bid >= Level-(MaxDeviation*_Point) && Level !=0)))
         {
            ticet=OrderSend(Symbol(),OP_SELL,lots1,Bid,3,Ask+stoploss1*Point,Bid-takeprofit1*Point,"1",magic,0,clrRed);
            if(ticet>0)
            {
               RunOnce=true;
            }
         }
        }
      if(t>16384)
        {
         if(Counts()==1)// && (RunOnce || (Ask >=Level && Ask<=Level+(MaxDeviation*_Point) && Level !=0)))
         {
            ticet=OrderSend(Symbol(),OP_BUY,lots2,Ask,3,Bid-stoploss2*Point,Ask+takeprofit2*Point,"2",magic,0,clrGreen);
            if(ticet>0)
            {
               RunOnce=true;
            }
         }
        }
// Partie 2 
     else if(t<16384)
        {
         if(Counts()==1)// && (RunOnce || (Bid <=Level && Bid >= Level-(MaxDeviation*_Point) && Level !=0)))
         {
            ticet=OrderSend(Symbol(),OP_SELL,lots2,Bid,3,Ask+stoploss2*Point,Bid-takeprofit2*Point,"2",magic,0,clrRed);
            if(ticet>0)
            {
               RunOnce=true;
            }
         }
        }
      if(t>16384)
        {
         if(Counts()==2)// && (RunOnce || (Ask >=Level && Ask<=Level+(MaxDeviation*_Point) && Level !=0)))
         {
            ticet=OrderSend(Symbol(),OP_BUY,lots3,Ask,3,Bid-stoploss3*Point,Ask+takeprofit3*Point,"3",magic,0,clrGreen);
            if(ticet>0)
            {
               RunOnce=true;
            }
         }
        }
//Partie 3 
     else if(t<16384)
        {
         if(Counts()==2)// && (RunOnce || (Bid <=Level && Bid >= Level-(MaxDeviation*_Point) && Level !=0)))
         {
            ticet=OrderSend(Symbol(),OP_SELL,lots3,Bid,3,Ask+stoploss3*Point,Bid-takeprofit3*Point,"3",magic,0,clrRed);
            if(ticet>0)
            {
               RunOnce=true;
            }
         }
        }                
       if(t>16384)
        {
         if(Counts()==3)// && (RunOnce || (Ask >=Level && Ask<=Level+(MaxDeviation*_Point) && Level !=0)))
         {
            ticet=OrderSend(Symbol(),OP_BUY,lots4,Ask,3,Bid-stoploss4*Point,Ask+takeprofit4*Point,"4",magic,0,clrGreen);
            if(ticet>0)
            {
               RunOnce=true;
            }
         }
        }
// Partie 4 
     else if(t<16384)
        {
         if(Counts()==3)// && (RunOnce || (Bid <=Level && Bid >= Level-(MaxDeviation*_Point) && Level !=0)))
         {
            ticet=OrderSend(Symbol(),OP_SELL,lots4,Bid,3,Ask+stoploss4*Point,Bid-takeprofit4*Point,"4",magic,0,clrRed);
            if(ticet>0)
            {
               RunOnce=true;
            }
         }
        }
      if(t>16384)
        {
         if(Counts()==4)// && (RunOnce || (Ask >=Level && Ask<=Level+(MaxDeviation*_Point) && Level !=0)))
         {
            ticet=OrderSend(Symbol(),OP_BUY,lots5,Ask,3,Bid-stoploss5*Point,Ask+takeprofit5*Point,"5",magic,0,clrGreen);
            if(ticet>0)
            {
               RunOnce=true;
            }
         }
        }
// Partie 5 
     else if(t<16384)
        {
         if(Counts()==4)// && (RunOnce || (Bid <=Level && Bid >= Level-(MaxDeviation*_Point) && Level !=0)))
         {
            ticet=OrderSend(Symbol(),OP_SELL,lots5,Bid,3,Ask+stoploss5*Point,Bid-takeprofit5*Point,"5",magic,0,clrRed);
            if(ticet>0)
            {
               RunOnce=true;
            }
         }
        }
     
       }
      }
     
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int CountSELL()
  {
   int count=0;
   int i;
   for(i=OrdersTotal()-1;i>=0;i--)
     {
      if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
        {
         if(OrderSymbol()==Symbol() && OrderMagicNumber()==magic && OrderType()==OP_SELL)
            count++;
        }
     }
   return(count);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int CountBUY()
  {
   int count=0;
   int i;
   for(i=OrdersTotal()-1;i>=0;i--)
     {
      if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
        {
         if(OrderSymbol()==Symbol() && OrderMagicNumber()==magic && OrderType()==OP_BUY)
            count++;
        }
     }
   return(count);
  }
//+------------------------------------------------------------------+
int Counts()
  {
   int count=0,i;
   
   for(i=OrdersHistoryTotal()-1;i>=0;i--)
      {
       if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY))
         {
          if(OrderSymbol()==Symbol() && OrderMagicNumber()==magic && OrderCloseTime()>=EaStartTime) count++;
          if(count > 4 && OrderCloseTime()>=EaStartTime) count=0;
         }
      }
   return(count);
  }  
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int CountVsego()
  {
   int Vsego;
   Vsego=CountBUY()+CountSELL();

   return(Vsego);
  }
//+------------------------------------------------------------------+
bool IsLastOrderClose()
{
bool signal = false;
for(int i=OrdersHistoryTotal()-1;i>=0;i--)
  {
   bool select = OrderSelect(i,SELECT_BY_POS,MODE_HISTORY);
   if(select && OrderSymbol()==_Symbol && OrderMagicNumber()==magic)
     {
     if(OrderType()==OP_BUY && OrderCloseTime()>=EaStartTime)
       {
       if(OrderClosePrice()>OrderStopLoss() && OrderClosePrice()<OrderTakeProfit())
         {
         signal = true;
         
         }
         break;
       }
     else if(OrderType()==OP_SELL && OrderCloseTime()>=EaStartTime)
       {
       if(OrderClosePrice()<OrderStopLoss() && OrderClosePrice()>OrderTakeProfit())
         {
         signal = true;
         
         }
         break;
       }
       break;
     }
  }
return(signal);
}

the other EA that closes the positions.


//+------------------------------------------------------------------+
//|                    TakeProfit 1 |
//+------------------------------------------------------------------+

#property copyright ""
#property link      ""


                                       
extern double My_Money_Equity_Target=0.10;  
                                         
int Slippage=4;                                        
int i;

double   EquityTarget;
//+------------------------------------------------------------------+
                                  
//+------------------------------------------------------------------+
int init()
  {
//---- 
   EquityTarget = AccountBalance()+My_Money_Equity_Target;
//----
   return(0);
  }
//+------------------------------------------------------------------+
                               
//+------------------------------------------------------------------+
int deinit()
  {
//---- 
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
                                         
//+------------------------------------------------------------------+


int start()
{
if (AccountEquity()>= EquityTarget)

   {
    for(i=OrdersTotal()-1;i>=0;i--)
       {
         if(OrderSelect(i,SELECT_BY_POS))
         {
            bool Res=false;
            if(OrderType()==OP_BUY)
            {
               Res = OrderClose(OrderTicket(),OrderLots(),MarketInfo(OrderSymbol(),MODE_BID),Slippage,clrNONE);
            }else if(OrderType()==OP_SELL)
            {
               Res = OrderClose(OrderTicket(),OrderLots(),MarketInfo(OrderSymbol(),MODE_ASK),Slippage,clrNONE);
            }else
            {
               Res = OrderDelete(OrderTicket());
            }
         } 
       }
      Print ("Equity reached to ",DoubleToStr(AccountEquity(),2));
      if(!Res)    return(0);
      EquityTarget = AccountBalance()+My_Money_Equity_Target;
   }  
   
   Comment("Balance: ",AccountBalance(),", Account Equity: ",AccountEquity(),", Account Profit: ",AccountProfit(),
           "\nMy Account Equity Target: ",EquityTarget);
   
  return(0);
}


Откликнулись

1
Разработчик 1
Оценка
(202)
Проекты
206
27%
Арбитраж
0
Просрочено
3
1%
Свободен
2
Разработчик 2
Оценка
(620)
Проекты
680
57%
Арбитраж
25
16% / 60%
Просрочено
228
34%
Свободен
3
Разработчик 3
Оценка
(590)
Проекты
789
71%
Арбитраж
9
33% / 33%
Просрочено
22
3%
Свободен
4
Разработчик 4
Оценка
(362)
Проекты
506
40%
Арбитраж
148
18% / 72%
Просрочено
99
20%
Занят
5
Разработчик 5
Оценка
(1130)
Проекты
1432
62%
Арбитраж
21
57% / 10%
Просрочено
43
3%
Свободен
6
Разработчик 6
Оценка
(43)
Проекты
72
49%
Арбитраж
4
0% / 50%
Просрочено
19
26%
Свободен
Похожие заказы
Hello The EA will work on particular zone choose by the user and can mark it on any TF and with some rules can open trades and mange the trade by some unique rules. the EA need to check the difference by RSI as well and with some extra rules . developer should have good attitude and good communication (englsih) with high performence and knowledge with coding EA. # MANUAL ZONE MARKING # THREE TYPES OF ENTRIES (
There are six conditions in total . source code from an existing expert will be provided to aid the completion of this job . - Install the following by the Panel (copy paste form my existing Expert ) 1. Pips Lost : number of pips lost ( monthly reset ) 2. Pips Gained : number of pips gained ( monthly reset ) 3. Have a black background to avoid the
Hey greetings. Am in need of a developer that has already made profitable MT4 or MT5 EA that I can buy with the backtesting and proven result. How is the draw down ? What is the winning rate ? Kindly reply and let proceed
I need a TradingView script (not mine) converted to an Mt5 EA. There is some specifications for the robots on when to be able to take a trade. Attached bellow is the file of the script I want translated and converted to MT5 then EA
GOODAY TO YOU I AM NEED OF A FAST, TALENTED AND HIGH QUALITY CODER TO THIS JOB FOR ME. THE EA TRADE MANAGER WILL HAVE THE FOLLOWING: STOPLOSS & TAKEPROFIT IN PIPS LOT SIZE IN PIPS NUMBER OF TRADES (1-30 TRADES MAXIMUM) PLEASE LOOK AT THE PICTURE ABOVE FOR A GUIDE
evalq({ #نوع دالة التنشيط. الحقيقة <- c( "sig" , #: sigmoid "sin" , #: sine "radbas" , #: radial basis "hardlim" , #: hard-limit "hardlims" , #: symmetric hard-limit "satlins" , #: satlins "tansig" , #: tan -sigmoid "tribas" , #: triangular basis "poslin" , #: positive linear "purelin" ) #: linear السندات
Hello, I want to create an EA with the belowspecification. EA will check conditions based on following input parameters: ● High Price ● Low Price ● Move Value (in Price) ● Gap (in price) After start, EA will mark High and Low prices based on input parameters. EA will start trading when the current price will hit any of the price POSITION at High , Low, Control Buy or Control Sell . EA will open
Necesito una placa EA que me permita ejecutar órdenes buy limit sell limit buy stop sell stop pero estas órdenes su tp su stop loss si triling stopp su punto de equilibrio debe ser virtual y algunas especificaciones mas solo aplican si tienes experiencia adjunta un ejemplo quiero algo como esto pero mas simple https://www.mql5.com/es/market/product/73489?source=Site +Market+MT5+Search+Rating006%3aEasyGRID+MT5
I have a mql4 license mql4 code,, there have a 1 error '( WebRequest' - no one of the overloads can be applied to the function call) fix this error,, and make sure it work properly,,{ it's bass on kernel32.dll } this license system Base on pc volume serial number. If you're a expert developer kindly contact with me ,, Write a text " License system devoloper " Telegram @Gw_rakib1
hi. I hv a strategy on tradingview need to convert to mt4/mt5 expert advisor for algo trading. would like to add some tradingview strategy setting to the mt4/mt5 EA(not included in my tradingview source code): recalculate after order is filled, order size: xx% of equity

Информация о проекте

Бюджет
30+ USD
VAT (20%): 6 USD
Итого: 36 USD
Исполнителю
27 USD
Сроки выполнения
до 8 дн.