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%
작업중
비슷한 주문
@page { size: 21cm 29.7cm; margin: 2cm } p { line-height: 115%; margin-bottom: 0.25cm; background: transparent } Hi, The task involves adding functions to an existing EA and correcting an error. The developer must have a thorough understanding of the following: Trailing Take Profit function Calculating a decreasing distance between orders Ability to code a function for Global Profit decrement/increment size in
The first section will describe the EAs trading strategy logic and features. The second section is an outline of the inputs that the EA should contain. 1. The idea of the trading system is as follows : This EA enters trades based on fibonacci retracement levels when other (MACD, RSI) conditions are met. It will use a MACD from a particular time frame to establish the swing high and swing lows which the fibonacci
Expert Advisor (EA) will provide automatic entry and exit using Black Dragon indicator as per the description below. Long (entry): on the first blue candle. Long (exit): on the first red candle, stop loss or take profit/break-even. Whatever happens first. Short (entry): on the first red candle. Short (exit): on the first blue candle, stop loss or take profit/break-even. Whatever happens first. Long (stop loss value)
1. **Timeframe and Liquidity:** Focus on the 5-minute timeframe for liquidity analysis.(timeframe for liquidity should be editble) 2. **Candlestick MSS:** Monitor 1-minute candlestick patterns for entry signals.(should be editble) 3. **Swing Points:** Identify swing points using the high and low of the last three candles.(ict swimg high and low) 4. **Sell Setup:** - Wait for a 5-minute candle to take out the swing
Hello Greetings. I have a custom tradingview strategy I would like to convert to Metatrader 5 ( mt5 ) . I have the source code a and with me. Kindly bid if it is what you can do for me and let discuss about the project. Thanks
I'm looking for a developer who has already working on a HFT tailored to pass prop firm challenges within a short period, maintaining a very low drawdown. Here is a link to a video demonstrating an existing EA executing the same strategy: https://youtu.be/N6NEcIpPzV4 Any developer having already worked on this type of project and able to provide quickly a test version is welcome to contact me
have trade signals i get by telegram messaging, i would like to have a robot designed to read those message for trade inputs and open and close trades base on the signals Ea must be able to scan my telegram Message app Read signals sent Open trades on the mt4 and manage them to close Read signals every one minute (user changeable input) I also need the programmer to teach me how to install and make the robot work
MACD EA 50+ USD
Hello Freelancers, I am seeking an experienced developer to create an Expert Advisor (EA) for MetaTrader 5 (MT5). The EA will be based on the MACD indicator and should adhere to the following specifications: EA Requirements: Trading Logic: 1. Long Trades: • Entry: Open a long trade when the MACD line crosses above the signal line below the zero level. • Exit: Close the long trade when the signal line crosses above
EA Configuration. FIBO ------------------------------------------------------------------- Magic: 123456 Stop: Real or Virtual Order: Pending / CLOSE / price== LOT Description: 0.01 ------------------------------------------------------------------- STOP: -0.25 ------------------------------------------------------------------- ENT_1: 1.00 Lot_1: 0.01 ENT_2: 0.50 Lot_2: 0.01 ENT_3: 1.00 Lot_3: 0.01
Hi I'm looking for a professional programmer to modify my EA the EA send signal alert to telegram and screen shot of the chart patterns my EA is dased to the harmonic pattern but I want to see on the screen shot the pattern of the harmonic pattern and on the chat as well

프로젝트 정보

예산
30+ USD
VAT (20%): 6 USD
총: 36 USD
개발자에게
27 USD
기한
 3 일