Position size multiplication bug

MQL4 Эксперты

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

Время выполнения 2 часа
Отзыв от заказчика
Nice work, thank you
Отзыв от исполнителя
Thanks

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

Hello, I have a small bug of position size multiplication.

Example:

I have 3 position sizes (0.02, 0.07, 0.40 Lots) that should open if my
 stop loss is hit but by the time I manually reset my stop loss there is a bug
 instead of opening a position at 0.40 lots because the 0.02 then 0.07 lots are hit
 it opens 0.02 or 0.07.

to know that I place several experts and that each expert has a
 different magic number


//+------------------------------------------------------------------+
//|                                                       test35.mq4 |
//|                                                              xxx |
//|                                              http://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "xxx"
#property link      "http://www.mql5.com"
#property version   "1.00"
#property strict
extern double  lots1          = 0.02;
extern double  lots2          = 0.07;
extern double  lots3          = 0.40;


input int      TakeProfit1     =   10  ;
input int      StopLoss1       =   50  ;
input int      TakeProfit2     =   10  ;
input int      StopLoss2       =   50;
input int      TakeProfit3     =   10  ;
input int      StopLoss3       =   50;



extern int     magic          = 222222;
//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;


//+------------------------------------------------------------------+
//| 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;
   
      
     }
   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;
            }
         }
        }                
       
      
      
       }
      }
     
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
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)
          {
             if(OrderProfit()>0)
             {
               if(count==0)
               {
                   OnInit();
                   EaStartTime=TimeCurrent();
               }
               return count;
             }else
             {
               count++;
             }
          }
          if(count > 2 && 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);
}

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

1
Разработчик 1
Оценка
(319)
Проекты
520
66%
Арбитраж
52
21% / 38%
Просрочено
165
32%
Загружен
Похожие заказы
Hello, send robot models with a solid strategy (to trade forex), I want to use it to make money for the week. It is important that you present me with your profitability graph and a test. I also want to hire him for future jobs
I am looking to develop an automated trading bot based on a strategy involving the crossing of four Simple Moving Averages (SMA). The bot should be capable of entering trades based on this strategy. Additionally, I would like to incorporate some custom diversions tailored for NinjaTrader
Seeking an experienced MQL5 developer to create a sophisticated Expert Advisor focused on harmonic pattern trading . The EA will be designed to identify and trade based on popular harmonic patterns in the forex market. Entry and Exit Logic: Develop smart entry and exit rules based on pattern completions and price action confirmations. Risk Management: Incorporate adjustable risk-per-trade settings and position sizing
preciso de um robô com duas médias móveis, uma exponencial high e uma exponencial low. preciso também ter a opção de utilizar e todos os tempos gráficos e alterar os parâmetros das médias. entrada de compra será feita quando um candle de alta romper e fechar a cima da média high e fechará a posição quando um candle de baixa romper e fechar a baixo da média low. a venda será feita quando o candle de baixa romper e
Description - An expert advisor(s), placing sell trades in EUR/USD, based on the close price of the previous two candles, as shown in the figure below. The trades would be made in the 5 minute, 1 hour, and 1 day timeframes. In the 5 minute and 1 hour timeframes the market orders would be placed at the start of a new candle, at specific times EST. The order would be cancelled at the close of that candle, i.e after 5
Hi, I have an indicator from my friend, I want to copy it to my own Traidingview or MT5 can you do that for me. Here is the link
Develop a simple trading robot from rainbow oscillator Additional features Include timeframe specification in rainbow oscillator trailing features moving average filter TP (true/false) SL (true/false) Fixed lot Risk percentage Percentage profit lock
Hi, I have an indicator from my friend, I want to copy it to my own Traidingview or MT5 can you do that for me. Here is the link
I need a dashboard that shows my various accounts that shows balance, equity, number of trades open, drawdown and some more information. I want to use it to monitor my accounts in one screen or chart. If there is anyone who can do it please show me the screenshot of your sample
Hi, I need a robot, which wil get instructions to trade in 3 symbols at the same time based on few parameters and calculations. Example: There is 1 symbol called Gold-Near and the rate for it is 1000-1002 If i specify that when the rate reaches 1050, it should sell 1 lot Upon execution it will have to sell 1 lot of cme gold, buy 3 lots of mcx gold and buy currently (lots will be based on calculation). All the

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

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