Please edit your post and use the code button (Alt+S) to paste code.
I didn't know that. done
I am finally trying to take the first steps with programming and I am inserting a lot calculator system on one of my EAs that does not have one. The code is this.
Unfortunately, while changing the various parameters and the balance, it continues to open positions from 1 lot. This is unthinkable in reality if the account has an available margin of 500 USD.
Don't think you can write an EA to change the operation of another EA ?
He said that he is writing code to insert into another EA
I am finally trying to take the first steps with programming and I am inserting a lot calculator system on one of my EAs that does not have one. The code is this.
Unfortunately, while changing the various parameters and the balance, it continues to open positions from 1 lot. This is unthinkable in reality if the account has an available margin of 500 USD.
double lot=MathCeil(AccountFreeMargin()*Risk/1000)/100;
I don't know what you are trying to achieve here
MathCeil(AccountFreeMargin()*Risk/1000)
If Risk==1
any free margin below 1000, 1 will be returned
between 1000 and 2000, 2 will be returned
etc
Then you divide that by 100
Is that what you want?
I am finally trying to take the first steps with programming and I am inserting a lot calculator system on one of my EAs that does not have one. The code is this.
Unfortunately, while changing the various parameters and the balance, it continues to open positions from 1 lot. This is unthinkable in reality if the account has an available margin of 500 USD.
Try like something that...
extern double LotSize = 0.01; extern bool UseMM = false; extern int Risk = 1; //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ void OnTick() { if(UseMM==true) LotSize=NormalizeLot(((AccountBalance()*AccountLeverage())/100000000)*Risk); else LotSize=NormalizeLot(LotSize); } double NormalizeLot(double _LotsSize) { //--------------------------------------------------------------------- if(IsConnected()) { return(MathMin(MathMax((MathRound(_LotsSize/MarketInfo(Symbol(),MODE_LOTSTEP))*MarketInfo(Symbol(),MODE_LOTSTEP)),MarketInfo(Symbol(),MODE_MINLOT)),MarketInfo(Symbol(),MODE_MAXLOT))); } else { return(NormalizeDouble(_LotsSize,2)); } //--------------------------------------------------------------------- }
'NormalizeLot' - function not defined Blue&Jellow_EA 4.0_2.mq4 164 28 'NormalizeLot' - function not defined Blue&Jellow_EA 4.0_2.mq4 164 110 'NormalizeLot' - function declarations are allowed on global, namespace or class scope only Blue&Jellow_EA 4.0_2.mq4 169 8
Thanks everyone for the tips. I get these errors on compilation. I don't understand, the function seems defined to me.
I don't know what you are trying to achieve here
If Risk==1
any free margin below 1000, 1 will be returned
between 1000 and 2000, 2 will be returned
etc
Then you divide that by 100
Is that what you want?
I also tried with a margin of 5000 USD, setting the risk at 0.5, but unfortunately the result is always 1 lot.
You probably have mismatched { }
//+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ void OnTick() { { if(UseMM==true) LotSize=NormalizeLot(((AccountBalance()*AccountLeverage())/100000000)*Risk); else LotSize=NormalizeLot(LotSize); } //+----------------------------------------------------------- double NormalizeLot(double LotsSize) { //--------------------------------------------------------------------- if(IsConnected()) { return(MathMin(MathMax((MathRound(LotsSize/MarketInfo(Symbol(),MODE_LOTSTEP))*MarketInfo(Symbol(),MODE_LOTSTEP)),MarketInfo(Symbol(),MODE_MINLOT)),MarketInfo(Symbol(),MODE_MAXLOT))); } else { return(NormalizeDouble(LotsSize,2)); } //---------------------------------------------------------------------
This is the code that gives the three errors

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I am finally trying to take the first steps with programming and I am inserting a lot calculator system on one of my EAs that does not have one. The code is this.
Unfortunately, while changing the various parameters and the balance, it continues to open positions from 1 lot. This is unthinkable in reality if the account has an available margin of 500 USD.