//+------------------------------------------------------------------+ //| TheGoldenGhost_AI.mq5 | //| Specialist XAU/USD Quant Trader | //+------------------------------------------------------------------+ #property copyright "AI Expert - Global Competition" #property version "1.00" #property strict //--- INPUT PARAMETERS input double Risk_Per_Trade = 1.5; // Risiko 1.5% per Posisi input int ATR_Period = 14; // Filter Volatilitas Dinamis input int RSI_Period = 7; // Filter Momentum Cepat input int MagicNumber = 888168; // ID Unik AI //--- GLOBAL VARIABLES double min_lot, max_lot, lot_step; int stoplevel; //+------------------------------------------------------------------+ //| Expert initialization function | //+------------------------------------------------------------------+ int OnInit() { min_lot = SymbolInfoDouble(_Symbol, SYMBOL_VOLUME_MIN); max_lot = SymbolInfoDouble(_Symbol, SYMBOL_VOLUME_MAX); lot_step = SymbolInfoDouble(_Symbol, SYMBOL_VOLUME_STEP); return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| Core Logic: Liquidity Sweep & Mean Reversion | //+------------------------------------------------------------------+ void OnTick() { if(!IsNewBar()) return; // Eksekusi hanya di awal candle baru untuk efisiensi double rsi[]; double atr[]; int rsi_handle = iRSI(_Symbol, _Period, RSI_Period, PRICE_CLOSE); int atr_handle = iATR(_Symbol, _Period, ATR_Period); ArraySetAsSeries(rsi, true); ArraySetAsSeries(atr, true); CopyBuffer(rsi_handle, 0, 0, 3, rsi); CopyBuffer(atr_handle, 0, 0, 3, atr); double close_1 = iClose(_Symbol, _Period, 1); double high_1 = iHigh(_Symbol, _Period, 1); double low_1 = iLow(_Symbol, _Period, 1); // STRATEGI: BUY SAAT LIQUIDITY SWEEP (HARGA MENEMBUS LOW SEBELUMNYA LALU REJECT) if(close_1 > low_1 && iLow(_Symbol, _Period, 0) < low_1 && rsi[0] < 30) { double sl = low_1 - (atr[0] * 1.5); double tp = close_1 + (atr[0] * 3.0); ExecuteTrade(ORDER_TYPE_BUY, sl, tp); } // STRATEGI: SELL SAAT LIQUIDITY SWEEP (HARGA MENEMBUS HIGH SEBELUMNYA LALU REJECT) if(close_1 < high_1 && iHigh(_Symbol, _Period, 0) > high_1 && rsi[0] > 70) { double sl = high_1 + (atr[0] * 1.5); double tp = close_1 - (atr[0] * 3.0); ExecuteTrade(ORDER_TYPE_SELL, sl, tp); } } //+------------------------------------------------------------------+ //| Fungsi Eksekusi & Money Management | //+------------------------------------------------------------------+ void ExecuteTrade(ENUM_ORDER_TYPE type, double sl, double tp) { double balance = AccountInfoDouble(ACCOUNT_BALANCE); double dist = MathAbs(SymbolInfoDouble(_Symbol, SYMBOL_BID) - sl) / _Point; double lot = NormalizeDouble((balance * (Risk_Per_Trade/100)) / (dist * 10), 2); if(lot < min_lot) lot = min_lot; MqlTradeRequest request = {}; MqlTradeResult result = {}; request.action = TRADE_ACTION_DEAL; request.symbol = _Symbol; request.volume = lot; request.type = type; request.price = (type == ORDER_TYPE_BUY) ? SymbolInfoDouble(_Symbol, SYMBOL_ASK) : SymbolInfoDouble(_Symbol, SYMBOL_BID); request.sl = sl; request.tp = tp; request.deviation = 10; request.magic = MagicNumber; request.comment = "Golden Ghost AI - Mobile Dominance"; request.type_filling = ORDER_FILLING_IOC; OrderSend(request, result); } bool IsNewBar() { static datetime last_time = 0; datetime curr_time = iTime(_Symbol, _Period, 0); if(last_time != curr_time) { last_time = curr_time; return true; } return false; }