Files
ironsan2kk-pixel 6450d1efc6 Fix download links
2026-06-08 10:36:15 +02:00

104 lines
2.9 KiB
Plaintext

//+------------------------------------------------------------------+
//| XAUUSD / USDJPY ATR Scalper EA |
//| Author: GIMS_Dev |
//| Platform: MetaTrader 4 |
//| Strategy: ATR + Trend + Price Action |
//+------------------------------------------------------------------+
#property strict
// ================= INPUTS =================
input double Lots = 0.01;
input int ATR_Period = 14;
input double ATR_Multiplier_SL = 1.2;
input double ATR_Multiplier_TP = 1.5;
input int EMA_Fast = 50;
input int EMA_Slow = 200;
input int Slippage = 3;
input int BreakevenPips = 20;
input int TrailingStopPips = 15;
input int MaxTradesPerSymbol = 3;
input int MagicNumber = 123456;
// ================= SYMBOLS =================
string Symbols[] = {"XAUUSD", "USDJPY"};
//+------------------------------------------------------------------+
int OnInit()
{
CreateDashboard();
Print("ATR Scalper EA initialized");
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
ObjectsDeleteAll(0, OBJ_LABEL);
}
//+------------------------------------------------------------------+
void OnTick()
{
for(int i=0; i<ArraySize(Symbols); i++)
{
string sym = Symbols[i];
if(!SymbolSelect(sym, true)) continue;
ManageTrades(sym);
if(CanOpenTrade(sym))
EvaluateEntry(sym);
UpdateDashboard(sym);
}
}
//+------------------------------------------------------------------+
// ================= ENTRY LOGIC =================
void EvaluateEntry(string sym)
{
if(!TrendIsValid(sym)) return;
if(!EngulfingPattern(sym)) return;
PlaceMarketOrder(sym);
}
// ================= TREND FILTER =================
bool TrendIsValid(string sym)
{
double fast = iMA(sym, PERIOD_H1, EMA_Fast, 0, MODE_EMA, PRICE_CLOSE, 0);
double slow = iMA(sym, PERIOD_H1, EMA_Slow, 0, MODE_EMA, PRICE_CLOSE, 0);
return (fast > slow || fast < slow);
}
// ================= PRICE ACTION =================
bool EngulfingPattern(string sym)
{
double o1 = iOpen(sym, PERIOD_M5, 1);
double c1 = iClose(sym, PERIOD_M5, 1);
double o2 = iOpen(sym, PERIOD_M5, 2);
double c2 = iClose(sym, PERIOD_M5, 2);
bool bullish = c2 < o2 && c1 > o1 && c1 > o2;
bool bearish = c2 > o2 && c1 < o1 && c1 < o2;
return (bullish || bearish);
}
// ================= ORDER PLACEMENT =================
void PlaceMarketOrder(string sym)
{
double atr = iATR(sym, PERIOD_M5, ATR_Period, 0);
if(atr <= 0) return;
double point = MarketInfo(sym, MODE_POINT);
int digits = (int)MarketInfo(sym, MODE_DIGITS);
double ask = MarketInfo(sym, MODE_ASK);
double bid = MarketInfo(sym, MODE_BID);
double sl, tp;
int type;
}