Lot size for MT5 EA
- [Archive] Learn how to make money villagers!
- several mt5 for one account
- Problem with the installation of an EA on MT4 platform
MT5 platform comes with a few pre-installed EA.One of them is good on 1H TF (ExpertMACD )
You need to replac Money Management classes.
For example on CMoneyFixedRisk:
//+------------------------------------------------------------------+ //| Include | //+------------------------------------------------------------------+ #include <Expert\Expert.mqh> #include <Expert\Signal\SignalMACD.mqh> #include <Expert\Trailing\TrailingNone.mqh> //#include <Expert\Money\MoneyNone.mqh> #include <Expert\Money\MoneyFixedRisk.mqh> //+------------------------------------------------------------------+ //| Inputs | //+------------------------------------------------------------------+ //--- inputs for expert input string Inp_Expert_Title ="ExpertMACD"; int Expert_MagicNumber =10981; bool Expert_EveryTick =false; //--- inputs for signal input int Inp_Signal_MACD_PeriodFast =12; input int Inp_Signal_MACD_PeriodSlow =24; input int Inp_Signal_MACD_PeriodSignal=9; input int Inp_Signal_MACD_TakeProfit =50; input int Inp_Signal_MACD_StopLoss =20; input double Inp_Money_Risk=5; // Risk in percent for a deal //+------------------------------------------------------------------+ //| Global expert object | //+------------------------------------------------------------------+ CExpert ExtExpert; |
//--- Creation of money object //CMoneyNone *money=new CMoneyNone; CMoneyFixedRisk *money=new CMoneyFixedRisk; 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 risk money.Percent(Inp_Money_Risk); //--- Set money parameters //--- Check money parameters
Thank you Vladimir but I want to trade by the Fixed Lots not by Percentage Risk .Please help.
I think it will be like this:
//+------------------------------------------------------------------+ //| Include | //+------------------------------------------------------------------+ #include <Expert\Expert.mqh> #include <Expert\Signal\SignalMACD.mqh> #include <Expert\Trailing\TrailingNone.mqh> //#include <Expert\Money\MoneyNone.mqh> #include <Expert\Money\CMoneyFixedLot.mqh> //+------------------------------------------------------------------+ //| Inputs | //+------------------------------------------------------------------+ //--- inputs for expert input string Inp_Expert_Title ="ExpertMACD"; int Expert_MagicNumber =10981; bool Expert_EveryTick =false; //--- inputs for signal input int Inp_Signal_MACD_PeriodFast =12; input int Inp_Signal_MACD_PeriodSlow =24; input int Inp_Signal_MACD_PeriodSignal=9; input int Inp_Signal_MACD_TakeProfit =50; input int Inp_Signal_MACD_StopLoss =20; input double Inp_Money_Lot=1.0; // Lots //+------------------------------------------------------------------+ //| Global expert object | //+------------------------------------------------------------------+ CExpert ExtExpert; |
sd
//--- Creation of money object //CMoneyNone *money=new CMoneyNone; 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 risk money.Lots(Inp_Money_Lot); //--- Set money parameters //--- Check money parameterssd
dzungsua: Why don't you try to compile it before posting .Thanks anyway.
| Why don't you try to figure out why it doesn't compile, before dismissing your helper. Or post the problem(s) - there are no mind readers here. |
... Why don't you try to compile it before posting ....
No, I didn't compile - was late and I wrote from a pad.
But if you compile a code, then you will see directly where I inserted single excess letters :)
Hello Vladimir ,your #1 post complied OK but your #3 post couldn't be complied.After I compare the code of those 2 posts I found in this line
#include <Expert\Money\CMoneyFixedLot.mqh>
one letter C extra; I took off that C and now it is OK .Thank a lot for your help and thank you whroder1 for your good idea.
Hello Vladimir ,your #1 post complied OK but your #3 post couldn't be complied.After I compare the code of those 2 posts I found in this line
#include <Expert\Money\CMoneyFixedLot.mqh>
one letter C extra; I took off that C and now it is OK .Thank a lot for your help and thank you whroder1 for your good idea.
Great! Excellent: You could do it yourself! Congratulations!
Hello, I am trying to get the risk volume with your same code but the result is always 0,0. Is there something wrong with this code or CMoneyFixedRisk class ? I only added 3 lines for this purpose. Thanks in advance.
#include <Expert\Expert.mqh> #include <Expert\Signal\SignalMACD.mqh> #include <Expert\Trailing\TrailingNone.mqh> //#include <Expert\Money\MoneyNone.mqh> #include <Expert\Money\MoneyFixedRisk.mqh> input string Inp_Expert_Title ="ExpertMACD"; int Expert_MagicNumber =10981; bool Expert_EveryTick =false; //--- inputs for signal input int Inp_Signal_MACD_PeriodFast =12; input int Inp_Signal_MACD_PeriodSlow =24; input int Inp_Signal_MACD_PeriodSignal=9; input int Inp_Signal_MACD_TakeProfit =50; input int Inp_Signal_MACD_StopLoss =20; input double Inp_Money_Risk=5; // Risk in percent for a deal CExpert ExtExpert; void OnTick() { double Ask = NormalizeDouble(SymbolInfoDouble(_Symbol,SYMBOL_ASK),_Digits); //CMoneyNone *money=new CMoneyNone; CMoneyFixedRisk *money=new CMoneyFixedRisk; 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 risk money.Percent(Inp_Money_Risk); //--- Set money parameters //--- Check money parameters //money.Percent(0.1); double vol = money.CheckOpenLong(Ask,Ask - (100*_Point)); Comment(vol); }

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use