mql5/Experts/Mistral/XPTUSD.mq5
darashikoh 945312b13e Add new optimization profiles for ERMT_7.1_ERMT-ML on EURUSD M5
- Created two new INI files for optimization:
  - ERMT_7.1_ERMT-ML.EURUSD.M5.20251001_20251102.210.ini
  - ERMT_7.1_ERMT-ML.EURUSD.M5.20251001_20251111.210.ini
- Each file includes detailed configuration settings for the trading strategy, including system configuration, entry system, risk management, trade management, technical analysis, dashboard settings, and reporting options.
- The profiles are set for the period from October 1, 2025, to November 2, 2025, and November 1, 2025, respectively.
2025-11-13 07:52:49 +00:00

92 行
3.6 KiB
MQL5

//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
// Inputs
double riskPercentage = 1.0; // 1% risk per trade
double stopLossPips = 20;
double pipValue = 0.01; // Adjust based on your broker (e.g., 0.01 for XPT/USD)
int atrPeriod = 14;
double atrMultiplier = 1.5; // Adjust based on volatility tolerance
// Indicator Handles
int aoHandle = iCustom(_Symbol, _Period, "AO");
int cciHandle = iCCI(_Symbol, _Period, 14, PRICE_TYPICAL);
int adxHandle = iADX(_Symbol, _Period, 14);
int stochHandle = iStochastic(_Symbol, _Period, 14, 3, 3, MODE_SMA, STO_LOWHIGH);
int rsiHandle = iRSI(_Symbol, _Period, 14, PRICE_CLOSE);
int macdHandle = iMACD(_Symbol, _Period, 12, 26, 9, PRICE_CLOSE);
// Get Indicator Values
double ao[2], cci[1], adx[1], diPlus[1], diMinus[1];
double stochKLine[1], stochDLine[1], rsi[1];
double macdLine[1], signalLine[1];
double atr[1];
CopyBuffer(aoHandle, 0, 0, 2, ao);
CopyBuffer(cciHandle, 0, 0, 1, cci);
CopyBuffer(adxHandle, 1, 0, 1, diPlus); // +DI is buffer 1
CopyBuffer(adxHandle, 2, 0, 1, diMinus); // -DI is buffer 2
CopyBuffer(adxHandle, 0, 0, 1, adx); // ADX is buffer 0
CopyBuffer(stochHandle, 0, 0, 1, stochKLine);
CopyBuffer(stochHandle, 1, 0, 1, stochDLine);
CopyBuffer(rsiHandle, 0, 0, 1, rsi);
CopyBuffer(macdHandle, 0, 0, 1, macdLine);
CopyBuffer(macdHandle, 1, 0, 1, signalLine);
CopyBuffer(iATR(_Symbol, _Period, atrPeriod), 0, 0, 1, atr);
// Calculate Dynamic Lot Size
double accountBalance = AccountInfoDouble(ACCOUNT_BALANCE);
double riskAmount = (accountBalance * riskPercentage) / 100;
double lotSize = NormalizeDouble((riskAmount / (atr[0] * atrMultiplier * pipValue)), 2);
// Entry Conditions
bool longCondition =
(ao[0] > 0 && ao[1] <= 0) && // AO crosses above zero
(cci[0] > -100) && // CCI not oversold
(adx[0] > 20) && // ADX shows trend strength
(diPlus[0] > diMinus[0]) && // +DI > -DI (bullish directional movement)
(stochKLine[0] > stochDLine[0]) && // Stochastic bullish crossover
(rsi[0] > 50) && // RSI above neutral
(macdLine[0] > signalLine[0]); // MACD bullish crossover
// Exit Conditions
double takeProfit = SymbolInfoDouble(_Symbol, SYMBOL_BID) + 50 * pipValue;
double stopLoss = SymbolInfoDouble(_Symbol, SYMBOL_BID) - stopLossPips * pipValue;
// Check for Open Orders
bool openOrders = false;
if (OrdersTotal() > 0)
openOrders = true;
// Strategy Execution
if (longCondition && !openOrders)
{
MqlTradeRequest request = {0};
MqlTradeResult result = {0};
request.action = TRADE_ACTION_DEAL; // Correctly set to TRADE_ACTION_DEAL
request.symbol = _Symbol;
request.volume = lotSize;
request.type = ORDER_TYPE_BUY;
request.price = SymbolInfoDouble(_Symbol, SYMBOL_ASK);
request.sl = stopLoss;
request.tp = takeProfit;
request.deviation = 3;
request.magic = 12345; // Unique identifier for the EA
if (!OrderSend(request, result))
{
Print("OrderSend failed with error #", GetLastError());
}
}
}