
Originally Posted by
jezzer1961
Funyoo,
I think that I have identified the problem here. It is to do with some brokers (such as Alpari) who quote their prices to an extra decimal place.
As a result, the result which is returned for the size of lot can potentially be out by a factor of 10 depending upon which broker the EA was designed for and which broker it is being used with.
I think the solution is to replace MarketInfo(Symbol(),MODE_LOTSIZE) with MarketInfo(Symbol(),MODE_TICKVALUE). You would also need to adjust the multiplier and I think you should also normalise the double.
What do you think?
Hi jezzer1961,
This is an interesting idea. We should see in demo what is the result.
I'm using another way with my new template, maybe more simple :
After extern parameters :
Code:
extern double Lots=0.1;//|-----------------------lots size
extern bool RiskMM=false;//|---------------------risk management
extern double RiskPercent=1;//|------------------risk percentage
extern double MinLots=0.01;//|-------------------minlots
extern double MaxLots=100;//|--------------------maxlots
After start(){ :
Code:
if(RiskMM)CalculateMM();
At the end of the code :
Code:
void CalculateMM()
{
double MinLots=MarketInfo(Symbol(),MODE_MINLOT);
double MaxLots=MarketInfo(Symbol(),MODE_MAXLOT);
Lots=AccountFreeMargin()/100000*RiskPercent;
Lots=MathMin(MaxLots,MathMax(MinLots,Lots));
if(MinLots<0.1)Lots=NormalizeDouble(Lots,2);
else
{
if(MinLots<1)Lots=NormalizeDouble(Lots,1);
else Lots=NormalizeDouble(Lots,0);
}
if(Lots<MinLots)Lots=MinLots;
if(Lots>MaxLots)Lots=MaxLots;
return(0);
}