Changing lot size in expertmama.mq5

 

I have an EA. I want to change lot size in this EA. it takes 0.001 lot size for currency pairs and 0.10 for metals. 

Can anyone help me to change LOT SIZE.

Please find attached file.... 

Files:
 
Amitt:

I have an EA. I want to change lot size in this EA. it takes 0.001 lot size for currency pairs and 0.10 for metals. 

Can anyone help me to change LOT SIZE.

Please find attached file.... 

Hi Amitt   You must add below code

//--- inputs for money
input double             Money_FixLot_Percent          =10.0;         // Percent
input double             Money_FixLot_Lots             =0.1;          // Fixed volume


........


int OnInit()
  {


.......


//--- Set money parameters
   money.Percent(Money_FixLot_Percent);
   money.Lots(Money_FixLot_Lots);
//--- Check all trading objects parameters
   if(!ExtExpert.ValidationSettings())
     {
      //--- failed
      ExtExpert.Deinit();
      return(-8);
     }
 

Amitt:

I have an EA. I want to change lot size in this EA. it takes 0.001 lot size for currency pairs and 0.10 for metals. 

Can anyone help me to change LOT SIZE.

Please find attached file.... 

You can modify/add the script like this one (marked as yellow color):

//+------------------------------------------------------------------+
//|                                                   ExpertMAMA.mq5 |
//|                        Copyright 2010, MetaQuotes Software Corp. |
//|                                              http://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2010, MetaQuotes Software Corp."
#property link      "http://www.mql5.com"
#property version   "1.00"
//+------------------------------------------------------------------+
//| Include                                                          |
//+------------------------------------------------------------------+
#include <Expert\Expert.mqh>
#include <Expert\Signal\SignalMA.mqh>
#include <Expert\Trailing\TrailingMA.mqh>
#include <Expert\Money\MoneyFixedLot.mqh>
//+------------------------------------------------------------------+
//| Inputs                                                           |
//+------------------------------------------------------------------+
//--- inputs for expert
input string             Inp_Expert_Title       ="ExpertMAMA";
int                      Expert_MagicNumber     =12003;
bool                     Expert_EveryTick       =false;
//--- inputs for signal
input int                Inp_Signal_MA_Period   =12;
input int                Inp_Signal_MA_Shift    =6;
input ENUM_MA_METHOD     Inp_Signal_MA_Method   =MODE_SMA;
input ENUM_APPLIED_PRICE Inp_Signal_MA_Applied  =PRICE_CLOSE;
//--- inputs for trailing
input int                Inp_Trailing_MA_Period =12;
input int                Inp_Trailing_MA_Shift  =0;
input ENUM_MA_METHOD     Inp_Trailing_MA_Method =MODE_SMA;
input ENUM_APPLIED_PRICE Inp_Trailing_MA_Applied=PRICE_CLOSE;

//--- inputs for money
input double             Money_FixLot_Percent =10.0;            // Percent
input double             Money_FixLot_Lots    =0.001;           // Fixed volume
//+------------------------------------------------------------------+
//| Global expert object                                             |
//+------------------------------------------------------------------+
CExpert ExtExpert;
//+------------------------------------------------------------------+
//| Initialization function of the expert                            |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- Initializing expert
   if(!ExtExpert.Init(Symbol(),Period(),Expert_EveryTick,Expert_MagicNumber))
     {
      //--- failed
      printf(__FUNCTION__+": error initializing expert");
      ExtExpert.Deinit();
      return(-1);
     }
//--- Creation of signal object
   CSignalMA *signal=new CSignalMA;
   if(signal==NULL)
     {
      //--- failed
      printf(__FUNCTION__+": error creating signal");
      ExtExpert.Deinit();
      return(-2);
     }
//--- Add signal to expert (will be deleted automatically))
   if(!ExtExpert.InitSignal(signal))
     {
      //--- failed
      printf(__FUNCTION__+": error initializing signal");
      ExtExpert.Deinit();
      return(-3);
     }
//--- Set signal parameters
   signal.PeriodMA(Inp_Signal_MA_Period);
   signal.Shift(Inp_Signal_MA_Shift);
   signal.Method(Inp_Signal_MA_Method);
   signal.Applied(Inp_Signal_MA_Applied);
//--- Check signal parameters
   if(!signal.ValidationSettings())
     {
      //--- failed
      printf(__FUNCTION__+": error signal parameters");
      ExtExpert.Deinit();
      return(-4);
     }
//--- Creation of trailing object
   CTrailingMA *trailing=new CTrailingMA;
   if(trailing==NULL)
     {
      //--- failed
      printf(__FUNCTION__+": error creating trailing");
      ExtExpert.Deinit();
      return(-5);
     }
//--- Add trailing to expert (will be deleted automatically))
   if(!ExtExpert.InitTrailing(trailing))
     {
      //--- failed
      printf(__FUNCTION__+": error initializing trailing");
      ExtExpert.Deinit();
      return(-6);
     }
//--- Set trailing parameters
   trailing.Period(Inp_Trailing_MA_Period);
   trailing.Shift(Inp_Trailing_MA_Shift);
   trailing.Method(Inp_Trailing_MA_Method);
   trailing.Applied(Inp_Trailing_MA_Applied);
//--- Check trailing parameters
   if(!trailing.ValidationSettings())
     {
      //--- failed
      printf(__FUNCTION__+": error trailing parameters");
      ExtExpert.Deinit();
      return(-7);
     }
//--- Creation of money object
   CMoneyFixedLot *money=new CMoneyFixedLot;
   if(money==NULL)
     {
      //--- failed
      printf(__FUNCTION__+": error creating money");
      ExtExpert.Deinit();
      return(-8);
     }
//--- Add money to expert (will be deleted automatically))
   if(!ExtExpert.InitMoney(money))
     {
      //--- failed
      printf(__FUNCTION__+": error initializing money");
      ExtExpert.Deinit();
      return(-9);
     }
//--- Set money parameters
   money.Percent(Money_FixLot_Percent);
   money.Lots(Money_FixLot_Lots);
//--- Check money parameters
   if(!money.ValidationSettings())
     {
      //--- failed
      printf(__FUNCTION__+": error money parameters");
      ExtExpert.Deinit();
      return(-10);
     }
//--- Tuning of all necessary indicators
   if(!ExtExpert.InitIndicators())
     {
      //--- failed
      printf(__FUNCTION__+": error initializing indicators");
      ExtExpert.Deinit();
      return(-11);
     }
//--- ok
   return(0);
  }
//+------------------------------------------------------------------+
//| Deinitialization function of the expert                          |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
   ExtExpert.Deinit();
  }
//+------------------------------------------------------------------+
//| Function-event handler "tick"                                    |
//+------------------------------------------------------------------+
void OnTick()
  {
   ExtExpert.OnTick();
  }
//+------------------------------------------------------------------+
//| Function-event handler "trade"                                   |
//+------------------------------------------------------------------+
void OnTrade()
  {
   ExtExpert.OnTrade();
  }
//+------------------------------------------------------------------+
//| Function-event handler "timer"                                   |
//+------------------------------------------------------------------+
void OnTimer()
  {
   ExtExpert.OnTimer();
  }
//+------------------------------------------------------------------+
 

Hello, I followed the direction above,

but I still cannot choose lot from expert setting, could you check my code?

//+------------------------------------------------------------------+

//|                                                   ExpertMAMA.mq5 |

//|                   Copyright 2009-2013, MetaQuotes Software Corp. |

//|                                              http://www.mql5.com |

//+------------------------------------------------------------------+

#property copyright   "2009-2013, MetaQuotes Software Corp."

#property link      "http://www.mql5.com"

#property version   "1.00"

//+------------------------------------------------------------------+

//| Include                                                          |

//+------------------------------------------------------------------+

#include <Expert\Expert.mqh>

#include <Expert\Signal\SignalMA.mqh>

#include <Expert\Trailing\TrailingMA.mqh>

//---alpha

#include <Expert\Money\MoneyFixedLot.mqh>

//+------------------------------------------------------------------+

//| Inputs                                                           |

//+------------------------------------------------------------------+

//--- inputs for expert

input string             Inp_Expert_Title       ="ExpertMAMA";

int                      Expert_MagicNumber     =12003;

bool                     Expert_EveryTick       =false;

//--- inputs for signal

input int                Inp_Signal_MA_Period   =12;

input int                Inp_Signal_MA_Shift    =6;

input ENUM_MA_METHOD     Inp_Signal_MA_Method   =MODE_SMA;

input ENUM_APPLIED_PRICE Inp_Signal_MA_Applied  =PRICE_CLOSE;

//--- inputs for trailing

input int                Inp_Trailing_MA_Period =12;

input int                Inp_Trailing_MA_Shift  =0;

input ENUM_MA_METHOD     Inp_Trailing_MA_Method =MODE_SMA;

input ENUM_APPLIED_PRICE Inp_Trailing_MA_Applied=PRICE_CLOSE;



//---alpha inputs for money

input double Money_FixLot_Percent =10.0; // Percent

input double Money_FixLot_Lots =0.001; // Fixed volume



//+------------------------------------------------------------------+

//| Global expert object                                             |

//+------------------------------------------------------------------+

CExpert ExtExpert;

//+------------------------------------------------------------------+

//| Initialization function of the expert                            |

//+------------------------------------------------------------------+

int OnInit(void)

  {

//--- Initializing expert

   if(!ExtExpert.Init(Symbol(),Period(),Expert_EveryTick,Expert_MagicNumber))

     {

      //--- failed

      printf(__FUNCTION__+": error initializing expert");

      ExtExpert.Deinit();

      return(-1);

     }

//--- Creation of signal object

   CSignalMA *signal=new CSignalMA;

   if(signal==NULL)

     {

      //--- failed

      printf(__FUNCTION__+": error creating signal");

      ExtExpert.Deinit();

      return(-2);

     }

//--- Add signal to expert (will be deleted automatically))

   if(!ExtExpert.InitSignal(signal))

     {

      //--- failed

      printf(__FUNCTION__+": error initializing signal");

      ExtExpert.Deinit();

      return(-3);

     }

//--- Set signal parameters

   signal.PeriodMA(Inp_Signal_MA_Period);

   signal.Shift(Inp_Signal_MA_Shift);

   signal.Method(Inp_Signal_MA_Method);

   signal.Applied(Inp_Signal_MA_Applied);

//--- Check signal parameters

   if(!signal.ValidationSettings())

     {

      //--- failed

      printf(__FUNCTION__+": error signal parameters");

      ExtExpert.Deinit();

      return(-4);

     }

//--- Creation of trailing object

   CTrailingMA *trailing=new CTrailingMA;

   if(trailing==NULL)

     {

      //--- failed

      printf(__FUNCTION__+": error creating trailing");

      ExtExpert.Deinit();

      return(-5);

     }

//--- Add trailing to expert (will be deleted automatically))

   if(!ExtExpert.InitTrailing(trailing))

     {

      //--- failed

      printf(__FUNCTION__+": error initializing trailing");

      ExtExpert.Deinit();

      return(-6);

     }

//--- Set trailing parameters

   trailing.Period(Inp_Trailing_MA_Period);

   trailing.Shift(Inp_Trailing_MA_Shift);

   trailing.Method(Inp_Trailing_MA_Method);

   trailing.Applied(Inp_Trailing_MA_Applied);

//--- Check trailing parameters

   if(!trailing.ValidationSettings())

     {

      //--- failed

      printf(__FUNCTION__+": error trailing parameters");

      ExtExpert.Deinit();

      return(-7);

     }

//---alpha Creation of money object

   CMoneyFixedLot *money=new CMoneyFixedLot;

   if(money==NULL)

     {

      //--- failed

      printf(__FUNCTION__+": error creating money");

      ExtExpert.Deinit();

      return(-8);

     }

//--- Add money to expert (will be deleted automatically))

   if(!ExtExpert.InitMoney(money))

     {

      //--- failed

      printf(__FUNCTION__+": error initializing money");

      ExtExpert.Deinit();

      return(-9);

     }

//---alpha Set money parameters

      money.Percent(Money_FixLot_Percent);

      money.Lots(Money_FixLot_Lots);



//--- Check money parameters

   if(!money.ValidationSettings())

     {

      //--- failed

      printf(__FUNCTION__+": error money parameters");

      ExtExpert.Deinit();

      return(-10);

     }

//--- Tuning of all necessary indicators

   if(!ExtExpert.InitIndicators())

     {

      //--- failed

      printf(__FUNCTION__+": error initializing indicators");

      ExtExpert.Deinit();

      return(-11);

     }

//--- succeed

   return(INIT_SUCCEEDED);

  }

//+------------------------------------------------------------------+

//| Deinitialization function of the expert                          |

//+------------------------------------------------------------------+

void OnDeinit(const int reason)

  {

   ExtExpert.Deinit();

  }

//+------------------------------------------------------------------+

//| Function-event handler "tick"                                    |

//+------------------------------------------------------------------+

void OnTick(void)

  {

   ExtExpert.OnTick();

  }

//+------------------------------------------------------------------+

//| Function-event handler "trade"                                   |

//+------------------------------------------------------------------+

void OnTrade(void)

  {

   ExtExpert.OnTrade();

  }

//+------------------------------------------------------------------+

//| Function-event handler "timer"                                   |

//+------------------------------------------------------------------+

void OnTimer(void)

  {

   ExtExpert.OnTimer();

  }

//+------------------------------------------------------------------+
Automated Trading and Strategy Testing
Automated Trading and Strategy Testing
  • www.mql5.com
MQL5: language of trade strategies built-in the MetaTrader 5 Trading Platform, allows writing your own trading robots, technical indicators, scripts and libraries of functions
Files:
 
urusa7:

Hello, I followed the direction above,

but I still cannot choose lot from expert setting, could you check my code?

Hello urusa7,

Please try to use the SRC button next time you paste any code on MQL5.com.

 

Regarding your "problem", if you don't specify exactly what error you're getting, it will be very difficult to find any help from users.

Try to be a little more specific about what errors you're getting. 

Regards,
Malacarne 

 

Good day to all!!!

I was able to find how to set Volume size on my ExpertMAMA.mq5

Would someone please show the code so that I can collect say $3 to $5 every time the transaction reaches this point? And of course let ExpertMAMA continue working

Thanks!!

 
alexrodang:

Good day to all!!!

I was able to find how to set Volume size on my ExpertMAMA.mq5

Would someone please show the code so that I can collect say $3 to $5 every time the transaction reaches this point? And of course let ExpertMAMA continue working

Thanks!!

Thanks for answering. I want to be able to set TP at will in my ExpertMAMA.mq5

 

Please let me know if this is the place to make the changes for TP and what is equivalent to. I mean if I reduce from 10 to 5.0 or to 0.5 what amount in $$ would it represent


//--- inputs for money input double             Money_FixLot_Percent =10.0;            // Percent

 
Rodrigo Malacarne #:

Hello urusa7,

Please try to use the SRC button next time you paste any code on MQL5.com.

 

Regarding your "problem", if you don't specify exactly what error you're getting, it will be very difficult to find any help from users.

Try to be a little more specific about what errors you're getting. 

Regards,
Malacarne 

Hello Rodrigo, Im trying to copy paste the code, but I cant find the SRC button, could you please tell where I can find it?

Thanks 

Andres

 
andresogorman #:

Hello Rodrigo, Im trying to copy paste the code, but I cant find the SRC button, could you please tell where I can find it?

Thanks 

Andres

Changed years ago. Rodrigo is no more active here these days.

Improperly formatted code removed by moderator. Please EDIT your post and use the CODE button (Alt-S) when inserting code.

Code button in editor

Hover your mouse over your post and select "edit" ... 

 
Alain Verleyen #:

Changed years ago. Rodrigo is no more active here these days.

Improperly formatted code removed by moderator. Please EDIT your post and use the CODE button (Alt-S) when inserting code.

Hover your mouse over your post and select "edit" ... 

Alain thanks,  but didnt understant very well, 

If a copy the code to change lot from here to Meta editor, what do I have to do?

ThanksAndres

Reason: