Quote:
Originally Posted by MrPip
burn0050,
There is a problem with your LotSize function that I have seen before.
It will not work with IBFX or those brokers no longer using lots. IBFX uses 1 for a minilots in a mini account while FXDD uses .1 for a minilot in a mini account. FXDD does not allow partial lots in a standard account while I believe IBFX does.
Some brokers are now using actual dollar amounts like $10000 instead of lots..
This causes problems writing MM functions in EAs.
For now I will simply post the code as is. I will work on figuring how to use your method with IBFX and update the EA for repost.
All results posted were using Nix version of AutoLots.
Robert
|
This modification of my previous AutoLot function should do the trick and takes the StopLoss value into consideration:
Code:
double AutoLots(int Risk, int StopLossInPips, double MIN_lots = 0.1, double MAX_lots = 5)
{
int Decimals = 0;
double LotStep = MarketInfo(Symbol(), MODE_LOTSTEP);
double LotSize = MarketInfo(Symbol(), MODE_LOTSIZE);
double LotTickValue = MarketInfo(Symbol(), MODE_TICKVALUE);
if(LotStep == 0.01)
Decimals = 2;
if(LotStep == 0.1)
Decimals = 1;
double LotsToRisk = ((AccountFreeMargin()*Risk)/100)/StopLossInPips;
double Lots = StrToDouble(DoubleToStr(LotsToRisk/LotTickValue,Decimals));
if (Lots < MIN_lots)
Lots = MIN_lots;
if (Lots > MAX_lots)
Lots = MAX_lots;
return(Lots);
}