This is the code thats returning the zero divide problem . Which occurs when I change the lot size from MODE_LOTSIZE to MODE_MINLOT.
double optimalLotSize = NormalizeDouble(maxLossInQuoteCurr /(maxLossInPips * GetPipValue())/lotSize,2);
return optimalLotSize;
-
-
-
double lotSize = MarketInfo(NULL,MODE_MINLOT);
Print("lotSize: " + lotSize);
use some code to calculate the divide elements first, check they are not zero then perform the divide...
This is the code thats returning the zero divide problem . Which occurs when I change the lot size from MODE_LOTSIZE to MODE_MINLOT.
double optimalLotSize = NormalizeDouble(maxLossInQuoteCurr /(maxLossInPips * GetPipValue())/lotSize,2);
return optimalLotSize;
-
-
-
double lotSize = MarketInfo(NULL,MODE_MINLOT);
Print("lotSize: " + lotSize);
use a simple function like this and use in your code when you divide
//Use the function like this in your code when you divide //Example of usage; Division(xxx,xxx); //---- double Division(double numerator,double denominator) { if(denominator == 0) return(0); else return(numerator/denominator); }
use a simple function like this and use in your code when you divide
won't work in MT5
you need to use :
if (fabs(v) > 0)
- Why did you post your MT4 question in the Root / MT5 General
section instead of the MQL4 section, (bottom of the Root page?)
General rules and best pratices of the Forum. - General - MQL5 programming forum
Next time post in the correct place. The moderators will likely move this thread there soon. - Alan Juarez: double lotSize = MarketInfo(NULL,MODE_MINLOT);Don't use NULL.
- You can use NULL in place of _Symbol only in those calls that the documentation specially says you can. iHigh does, iCustom does, MarketInfo does not. OrderSend does not.
- Don't use NULL (except for pointers where you explicitly check for it.) Use _Symbol and _Period, that is minimalist as possible and more efficient.
- Zero is the same as PERIOD_CURRENT which means _Period. Don't hard code numbers.
- MT4: No need for a function call with iHigh(NULL,0,s) just use the predefined arrays, i.e. High[].
won't work in MT5
you need to use :
i was referring to MT4
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
This is the code thats returning the zero divide problem . Which occurs when I change the lot size from MODE_LOTSIZE to MODE_MINLOT.
double optimalLotSize = NormalizeDouble(maxLossInQuoteCurr /(maxLossInPips * GetPipValue())/lotSize,2);
return optimalLotSize;
-
-
-
double lotSize = MarketInfo(NULL,MODE_MINLOT);
Print("lotSize: " + lotSize);