diff --git a/Experts/Nkanven/TheChallenger.ex5 b/Experts/Nkanven/TheChallenger.ex5 index 5f66dbf..546b5bf 100644 Binary files a/Experts/Nkanven/TheChallenger.ex5 and b/Experts/Nkanven/TheChallenger.ex5 differ diff --git a/Include/Nkanven/TheChallenger/EntriesManager.mqh b/Include/Nkanven/TheChallenger/EntriesManager.mqh index d9d98d5..9070bdf 100644 Binary files a/Include/Nkanven/TheChallenger/EntriesManager.mqh and b/Include/Nkanven/TheChallenger/EntriesManager.mqh differ diff --git a/Include/Nkanven/TheChallenger/LotSizeCal.mqh b/Include/Nkanven/TheChallenger/LotSizeCal.mqh index 5ff8fc3..6b0afde 100644 --- a/Include/Nkanven/TheChallenger/LotSizeCal.mqh +++ b/Include/Nkanven/TheChallenger/LotSizeCal.mqh @@ -17,6 +17,7 @@ void LotSizeCalculate(double SL=0) if(SL!=0) { double RiskBaseAmount=0; + Print("Compute lot size"); //TickValue is the value of the individual price increment for 1 lot of the instrument, expressed in the account currenty double TickValue=SymbolInfoDouble(gSymbol,SYMBOL_TRADE_TICK_VALUE); @@ -29,28 +30,32 @@ void LotSizeCalculate(double SL=0) RiskBaseAmount=AccountInfoDouble(ACCOUNT_FREEMARGIN); //Calculate the Position Size - LotSize=((RiskBaseAmount*InpMaxRiskPerTrade/100)/(SL*TickValue)); + gLotSize=((RiskBaseAmount*InpMaxRiskPerTrade/100)/(SL*TickValue)); + + Print("(RiskBaseAmount ", RiskBaseAmount, " InpMaxRiskPerTrade ", InpMaxRiskPerTrade, " SL ", SL, " TickValue ", TickValue); } + //If the stop loss is zero then the lot size is the default one - if(SL==0) + /*if(SL==0) { - LotSize=InpDefaultLotSize; - } + gLotSize=InpDefaultLotSize; + }*/ } //Normalize the Lot Size to satisfy the allowed lot increment and minimum and maximum position size - LotSize=MathFloor(LotSize/SymbolInfoDouble(gSymbol,SYMBOL_VOLUME_STEP))*SymbolInfoDouble(gSymbol,SYMBOL_VOLUME_STEP); + gLotSize=MathFloor(gLotSize/SymbolInfoDouble(gSymbol,SYMBOL_VOLUME_STEP))*SymbolInfoDouble(gSymbol,SYMBOL_VOLUME_STEP); -//Limit the lot size in case it is greater than the maximum allowed by the user - if(LotSize>InpMaxLotSize) - LotSize=InpMaxLotSize; +Print("LotSize ", gLotSize); //Limit the lot size in case it is greater than the maximum allowed by the broker - if(LotSize>SymbolInfoDouble(gSymbol,SYMBOL_VOLUME_MAX)) - LotSize=SymbolInfoDouble(gSymbol,SYMBOL_VOLUME_MAX); - Print("Lot ", LotSize, " Max lot ", SymbolInfoDouble(gSymbol,SYMBOL_VOLUME_MAX)); + if(gLotSize>SymbolInfoDouble(gSymbol,SYMBOL_VOLUME_MAX)) + gLotSize=SymbolInfoDouble(gSymbol,SYMBOL_VOLUME_MAX); + Print("Lot ", gLotSize, " Max lot ", SymbolInfoDouble(gSymbol,SYMBOL_VOLUME_MAX)); + +Print("LotSize2 ", gLotSize); //If the lot size is too small then set it to 0 and don't trade - if(LotSize