How select the biggest lot position

To add comments, please log in or register
Saeid Reza Bahman Abadi
168
Saeid Reza Bahman Abadi  

Hi 

I want writing a martingle EA code

How I can select the biggest lot position for *2 for new position?

Please write sample code

Alain Verleyen
38676
Alain Verleyen  

Forum on trading, automated trading systems and testing trading strategies

General rules and best practices of the Forum.

Alain Verleyen, 2018.08.03 22:51

About getting coding free help.


Welcome,

  • Usually people who cannot code do not receive free help on this forum, although it could happen if you are lucky. Be patient.
  • If you show your attempts and describe your problem clearly, you will most probably receive an answer from the community.
  • If you do not want to learn to code, that is not a problem. You can either look at the Codebase if something free already exists, or in the Market for paid products (also sometimes free).

Good luck.

--------------------

Just to remind:

Coders (any coder) are coding for free:

  • if it is interesting for them personally, or
  • if it is interesting for many members of this forum.

and Freelance section of the forum should be used in most of the cases.

Urgent help.


Saeid Reza Bahman Abadi
168
Saeid Reza Bahman Abadi  
Alain Verleyen:

i start learing mql4 but i don,t now about source of learning ?

what is the best source of learning mql4?

i want sample code and not all code 

Mehmet Bastem
1672
Mehmet Bastem  
saeedmyheart:

Hi 

I want writing a martingle EA code

How I can select the biggest lot position for *2 for new position?

Please write sample code

//+------------------------------------------------------------------+
//|                                                            d.mq4 |
//|                        Copyright 2018, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2018, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict
 double ResultSell=0;
  double ResultBuy=0;
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//---
   
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---
   
  }
  int BuySellCount()
{
  ResultSell=0;
  ResultBuy=0;
    int total = OrdersTotal();
   for(int i=total-1;i>=0;i--)
    {
      if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false)        break;
      if(OrderSymbol()!=Symbol()) continue;
      if (OrderType()==OP_SELL) ResultSell=ResultSell+OrderLots();
      if (OrderType()==OP_BUY)  ResultBuy=ResultBuy+OrderLots();
    }
    return(0); 
    }
 
   
   


//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//---
double Lots=0.0;
   BuySellCount();
   if (ResultBuy>ResultSell) Lots=ResultBuy*2;
   if (ResultBuy<ResultSell) Lots=ResultSell*2;
   
  }
//+------------------------------------------------------------------+
To add comments, please log in or register