//+------------------------------------------------------------------+ //| GOLD_SCALPER_MT4.mq4 | //+------------------------------------------------------------------+ #property strict // === PARAMÈTRES === input double LotSize = 0.01; input int StopLoss = 200; // points input int TakeProfit = 300; // points input int Slippage = 3; input int MagicNumber = 777; input int FastEMA = 20; input int SlowEMA = 50; input int RSIPeriod = 14; // === FILTRE === input int MaxTradesPerDay = 20; input int StartHour = 8; input int EndHour = 20; // === VARIABLES === int tradesToday = 0; datetime lastTradeDay; //+------------------------------------------------------------------+ int OnInit() { lastTradeDay = TimeDay(TimeCurrent()); return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ void OnTick() { // Reset trades journaliers if (TimeDay(TimeCurrent()) != lastTradeDay) { tradesToday = 0; lastTradeDay = TimeDay(TimeCurrent()); } // Filtre horaires int hour = TimeHour(TimeCurrent()); if (hour < StartHour || hour > EndHour) return; if (tradesToday >= MaxTradesPerDay) return; if (OrdersTotal() > 0) return; // Indicateurs double emaFast = iMA(Symbol(), 0, FastEMA, 0, MODE_EMA, PRICE_CLOSE, 0); double emaSlow = iMA(Symbol(), 0, SlowEMA, 0, MODE_EMA, PRICE_CLOSE, 0); double rsi = iRSI(Symbol(), 0, RSIPeriod, PRICE_CLOSE, 0); double ask = NormalizeDouble(Ask, Digits); double bid = NormalizeDouble(Bid, Digits); // === BUY === if (emaFast > emaSlow && rsi > 55) { OrderSend(Symbol(), OP_BUY, LotSize, ask, Slippage, ask - StopLoss * Point, ask + TakeProfit * Point, "Gold Buy", MagicNumber, 0, clrGreen); tradesToday++; } // === SELL === if (emaFast < emaSlow && rsi < 45) { OrderSend(Symbol(), OP_SELL, LotSize, bid, Slippage, bid + StopLoss * Point, bid - TakeProfit * Point, "Gold Sell", MagicNumber, 0, clrRed); tradesToday++; } } //+------------------------------------------------------------------+