mirror of
https://github.com/rithsila/MT5-EA-Sniper-Strategy.git
synced 2026-08-17 20:58:13 +00:00
Done for backtest with initial configuration
This commit is contained in:
Binary file not shown.
Binary file not shown.
@@ -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<InpMinLotSize || LotSize < SymbolInfoDouble(gSymbol,SYMBOL_VOLUME_MIN))
|
||||
if(gLotSize<InpMinLotSize || gLotSize < SymbolInfoDouble(gSymbol,SYMBOL_VOLUME_MIN))
|
||||
{
|
||||
LotSize=0;
|
||||
Print("Lot size too small : ", LotSize);
|
||||
gLotSize=0;
|
||||
Print("Lot size too small : ", gLotSize);
|
||||
}
|
||||
Print("LotSize3 ", gLotSize);
|
||||
}
|
||||
|
||||
@@ -74,7 +74,7 @@ input string Comment_0="=========="; //Risk M
|
||||
input double InpVolume = 0.01; //Default order size
|
||||
|
||||
input ENUM_RISK_DEFAULT_SIZE InpRiskDefaultSize=RISK_DEFAULT_AUTO; //Position Size Mode
|
||||
input double InpDefaultLotSize=1; //Position Size (if fixed or if no stop loss defined)
|
||||
input double InpDefaultLotSize=0.01; //Position Size (if fixed or if no stop loss defined)
|
||||
input ENUM_RISK_BASE InpRiskBase=RISK_BASE_BALANCE; //Risk Base
|
||||
input double InpMaxRiskPerTrade=0.5; //Percentage To Risk Each Trade
|
||||
input double InpMinLotSize=0.01; //Minimum Position Size Allowed
|
||||
@@ -129,8 +129,6 @@ long Spread = SymbolInfoInteger(gSymbol,SYMBOL_SPREAD) / 100; //Check the impac
|
||||
|
||||
int gOrderOpRetry = 10;
|
||||
|
||||
double LotSize=0;
|
||||
|
||||
MqlTick last_tick;
|
||||
MqlDateTime dt;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user