Ea scalper

MQL5 Esperti

Specifiche


//+------------------------------------------------------------------+
//| BTCUSD & XAUUSD SIMPLE SCALPING EA                                |
//| Strategy: EMA 9/21 + RSI 14 + ATR 14                             |
//| Platform: MetaTrader 5                                           |
//+------------------------------------------------------------------+
#property strict
#property version "1.01"

#include <Trade/Trade.mqh>

CTrade trade;

//--- Trading settings
input ENUM_TIMEFRAMES Timeframe = PERIOD_M5;
input double RiskPercent = 1.0;
input int FastEMA = 9;
input int SlowEMA = 21;
input int RSIPeriod = 14;
input int ATRPeriod = 14;
input double SL_ATR_Multiplier = 1.5;
input double TP_RR = 1.5;
input double BreakEvenRR = 1.0;
input int MaxSpreadPoints = 0;
input ulong MagicNumber = 20261205;

//--- Indicator handles
int fastHandle;
int slowHandle;
int rsiHandle;
int atrHandle;

datetime lastBar = 0;

//+------------------------------------------------------------------+
//| Initialization                                                   |
//+------------------------------------------------------------------+
int OnInit()
{
   trade.SetExpertMagicNumber(MagicNumber);
   trade.SetTypeFillingBySymbol(_Symbol);

   fastHandle = iMA(_Symbol, Timeframe, FastEMA, 0,
                    MODE_EMA, PRICE_CLOSE);

   slowHandle = iMA(_Symbol, Timeframe, SlowEMA, 0,
                    MODE_EMA, PRICE_CLOSE);

   rsiHandle = iRSI(_Symbol, Timeframe, RSIPeriod,
                     PRICE_CLOSE);

   atrHandle = iATR(_Symbol, Timeframe, ATRPeriod);

   if(fastHandle == INVALID_HANDLE ||
      slowHandle == INVALID_HANDLE ||
      rsiHandle == INVALID_HANDLE ||
      atrHandle == INVALID_HANDLE)
   {
      Print("Indicator initialization failed.");
      return INIT_FAILED;
   }

   return INIT_SUCCEEDED;
}

//+------------------------------------------------------------------+
//| Release indicators                                               |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
   IndicatorRelease(fastHandle);
   IndicatorRelease(slowHandle);
   IndicatorRelease(rsiHandle);
   IndicatorRelease(atrHandle);
}

//+------------------------------------------------------------------+
//| Detect new candle                                                |
//+------------------------------------------------------------------+
bool NewBar()
{
   datetime currentBar = iTime(_Symbol, Timeframe, 0);

   if(currentBar == 0)
      return false;

   if(currentBar != lastBar)
   {
      lastBar = currentBar;
      return true;
   }

   return false;
}

//+------------------------------------------------------------------+
//| Check existing positions                                         |
//+------------------------------------------------------------------+
bool HasPosition()
{
   for(int i = PositionsTotal() - 1; i >= 0; i--)
   {
      ulong ticket = PositionGetTicket(i);

      if(ticket > 0 &&
         PositionGetString(POSITION_SYMBOL) == _Symbol &&
         PositionGetInteger(POSITION_MAGIC) == (long)MagicNumber)
      {
         return true;
      }
   }

   return false;
}

//+------------------------------------------------------------------+
//| Normalize lot size                                               |
//+------------------------------------------------------------------+
double NormalizeVolume(double lots)
{
   double minLot = SymbolInfoDouble(_Symbol, SYMBOL_VOLUME_MIN);
   double maxLot = SymbolInfoDouble(_Symbol, SYMBOL_VOLUME_MAX);
   double step = SymbolInfoDouble(_Symbol, SYMBOL_VOLUME_STEP);

   if(step <= 0)
      return 0;

   lots = MathFloor(lots / step) * step;

   lots = MathMin(lots, maxLot);

   if(lots < minLot)
      return 0;

   return NormalizeDouble(lots, 8);
}

//+------------------------------------------------------------------+
//| Calculate risk-based lot size                                    |
//+------------------------------------------------------------------+
double CalculateLot(double stopDistance)
{
   double equity = AccountInfoDouble(ACCOUNT_EQUITY);

   double riskMoney = equity * RiskPercent / 100.0;

   double tickSize =
      SymbolInfoDouble(_Symbol, SYMBOL_TRADE_TICK_SIZE);

   double tickValue =
      SymbolInfoDouble(_Symbol, SYMBOL_TRADE_TICK_VALUE_LOSS);

   if(tickValue <= 0)
      tickValue = SymbolInfoDouble(_Symbol, SYMBOL_TRADE_TICK_VALUE);

   if(tickSize <= 0 || tickValue <= 0 || stopDistance <= 0)
      return 0;

   double lossPerLot = (stopDistance / tickSize) * tickValue;

   if(lossPerLot <= 0)
      return 0;

   return NormalizeVolume(riskMoney / lossPerLot);
}

//+------------------------------------------------------------------+
//| Break-even management                                            |
//+------------------------------------------------------------------+
void ManageBreakEven()
{
   for(int i = PositionsTotal() - 1; i >= 0; i--)
   {
      ulong ticket = PositionGetTicket(i);

      if(ticket == 0)
         continue;

      if(PositionGetString(POSITION_SYMBOL) != _Symbol ||
         PositionGetInteger(POSITION_MAGIC) != (long)MagicNumber)
         continue;

      ENUM_POSITION_TYPE type =
         (ENUM_POSITION_TYPE)PositionGetInteger(POSITION_TYPE);

      double openPrice =
         PositionGetDouble(POSITION_PRICE_OPEN);

      double sl = PositionGetDouble(POSITION_SL);
      double tp = PositionGetDouble(POSITION_TP);

      if(sl <= 0)
         continue;

      double currentPrice;

      if(type == POSITION_TYPE_BUY)
         currentPrice = SymbolInfoDouble(_Symbol, SYMBOL_BID);
      else
         currentPrice = SymbolInfoDouble(_Symbol, SYMBOL_ASK);

      double initialRisk = MathAbs(openPrice - sl);

      if(initialRisk <= 0)
         continue;

      double profitDistance;

      if(type == POSITION_TYPE_BUY)
         profitDistance = currentPrice - openPrice;
      else
         profitDistance = openPrice - currentPrice;

      if(profitDistance >= initialRisk * BreakEvenRR)
      {
         double newSL = NormalizeDouble(
            openPrice,
            (int)SymbolInfoInteger(_Symbol, SYMBOL_DIGITS)
         );

         if(type == POSITION_TYPE_BUY && sl < newSL)
            trade.PositionModify(ticket, newSL, tp);

         if(type == POSITION_TYPE_SELL && sl > newSL)
            trade.PositionModify(ticket, newSL, tp);
      }
   }
}

//+------------------------------------------------------------------+
//| Main trading function                                            |
//+------------------------------------------------------------------+
void OnTick()
{
   ManageBreakEven();

   if(!NewBar())
      return;

   if(HasPosition())
      return;

   // Dynamic arrays - corrected
   double fast[];
   double slow[];
   double rsi[];
   double atr[];

   ArrayResize(fast, 3);
   ArrayResize(slow, 3);
   ArrayResize(rsi, 3);
   ArrayResize(atr, 3);

   ArraySetAsSeries(fast, true);
   ArraySetAsSeries(slow, true);
   ArraySetAsSeries(rsi, true);
   ArraySetAsSeries(atr, true);

   // Copy indicator values
   if(CopyBuffer(fastHandle, 0, 0, 3, fast) < 3)
      return;

   if(CopyBuffer(slowHandle, 0, 0, 3, slow) < 3)
      return;

   if(CopyBuffer(rsiHandle, 0, 0, 3, rsi) < 3)
      return;

   if(CopyBuffer(atrHandle, 0, 0, 3, atr) < 3)
      return;

   MqlTick tick;

   if(!SymbolInfoTick(_Symbol, tick))
      return;

   double point = SymbolInfoDouble(_Symbol, SYMBOL_POINT);

   if(point <= 0)
      return;

   // Spread filter
   if(MaxSpreadPoints > 0)
   {
      double spread = (tick.ask - tick.bid) / point;

      if(spread > MaxSpreadPoints)
         return;
   }

   // Confirmed candle signals
   bool buySignal =
      fast[2] <= slow[2] &&
      fast[1] > slow[1] &&
      rsi[1] > 50;

   bool sellSignal =
      fast[2] >= slow[2] &&
      fast[1] < slow[1] &&
      rsi[1] < 50;

   double slDistance = atr[1] * SL_ATR_Multiplier;

   if(slDistance <= 0)
      return;

   double lots = CalculateLot(slDistance);

   if(lots <= 0)
      return;

   int digits =
      (int)SymbolInfoInteger(_Symbol, SYMBOL_DIGITS);

   // BUY
   if(buySignal)
   {
      double sl = NormalizeDouble(
         tick.ask - slDistance, digits);

      double tp = NormalizeDouble(
         tick.ask + slDistance * TP_RR, digits);

      bool result = trade.Buy(
         lots,
         _Symbol,
         0,
         sl,
         tp,
         "EMA RSI Scalping BUY"
      );

      if(!result)
         Print("BUY failed: ", trade.ResultRetcodeDescription());
   }

   // SELL
   if(sellSignal)
   {
      double sl = NormalizeDouble(
         tick.bid + slDistance, digits);

      double tp = NormalizeDouble(
         tick.bid - slDistance * TP_RR, digits);

      bool result = trade.Sell(
         lots,
         _Symbol,
         0,
         sl,
         tp,
         "EMA RSI Scalping SELL"
      );

      if(!result)
         Print("SELL failed: ", trade.ResultRetcodeDescription());
   }
}
//+------------------------------------------------------------------+

Con risposta

1
Sviluppatore 1
Valutazioni
(61)
Progetti
61
51%
Arbitraggio
1
0% / 100%
In ritardo
1
2%
Gratuito
2
Sviluppatore 2
Valutazioni
(23)
Progetti
34
53%
Arbitraggio
1
100% / 0%
In ritardo
1
3%
Gratuito
3
Sviluppatore 3
Valutazioni
Progetti
0
0%
Arbitraggio
0
In ritardo
0
Gratuito
Pubblicati: 2 codici
4
Sviluppatore 4
Valutazioni
(2)
Progetti
2
50%
Arbitraggio
0
In ritardo
0
Gratuito
Pubblicati: 7 codici
5
Sviluppatore 5
Valutazioni
(30)
Progetti
37
38%
Arbitraggio
0
In ritardo
2
5%
In elaborazione
Pubblicati: 1 codice
6
Sviluppatore 6
Valutazioni
Progetti
0
0%
Arbitraggio
0
In ritardo
0
Gratuito
7
Sviluppatore 7
Valutazioni
Progetti
0
0%
Arbitraggio
0
In ritardo
0
Gratuito
8
Sviluppatore 8
Valutazioni
Progetti
0
0%
Arbitraggio
0
In ritardo
0
Gratuito
9
Sviluppatore 9
Valutazioni
Progetti
0
0%
Arbitraggio
0
In ritardo
0
Gratuito
Pubblicati: 3 codici
10
Sviluppatore 10
Valutazioni
Progetti
0
0%
Arbitraggio
0
In ritardo
0
Gratuito
11
Sviluppatore 11
Valutazioni
Progetti
0
0%
Arbitraggio
0
In ritardo
0
Gratuito
12
Sviluppatore 12
Valutazioni
Progetti
0
0%
Arbitraggio
0
In ritardo
0
Gratuito
13
Sviluppatore 13
Valutazioni
(2)
Progetti
2
0%
Arbitraggio
1
0% / 100%
In ritardo
0
Gratuito
14
Sviluppatore 14
Valutazioni
Progetti
0
0%
Arbitraggio
0
In ritardo
0
Gratuito
Pubblicati: 1 codice
Ordini simili
I am looking for one existing MT5 trading strategy with documented net profit after trading costs. I am open to different instruments and timeframes. I want to run the strategy in my own MT5 Strategy Tester using the same fixed settings. To apply, briefly describe how the strategy trades, name the instrument and timeframe, and share one link or report showing its results. Please say whether it is a verified live
Gulu 30+ USD
create money on forex ensuring nothing but profit basically also crypto an d ensure you use every means possible to ensure in turn a profit is made that what i want i want perfection
If you already have a working gold order-flow EA that matches the logic described here, I'm open to buying or licensing it instead of a custom build. Please provide: A demo version that I can run in the MT5 Strategy Tester (for example, a time-limited or demo-account-only build) A clear explanation of the trading logic: what triggers an entry, how the stop loss and take profit are set, and which order-flow or
Mega booster ea 30+ USD
Automated trade execution. Entry and exit conditions. Stop-loss and take-profit management. Risk management. Daily drawdown protection. Compatibility with prop firm accounts. MT5 compatibility. 24/5 operation. Protection against violating prop firm trading rules
I'm looking to purchase an already-developed, profitable trading bot specifically for Deriv. I'm not interested in building a new one from scratch. The bot must have a test version that I can try out, as well as verifiable historical live trading results demonstrating its profitability. I'm only interested in proven bots with a track record of real-market performance
I am looking to purchase an existing, fully developed and operational XAUUSD scalping Expert Advisor (EA) for MetaTrader 5. IMPORTANT: I am NOT looking for new development, custom programming, or an experimental strategy. I am only interested in an existing, ready-made and proven trading system. Requirements: Fully automated XAUUSD scalping EA for MT5. Short-duration trades with an active trading frequency. Hard Stop
UPGRADE OF EXISTING MT5 MULTI-ASSET TREND EA I want to upgrade my existing MT5 Expert Advisor into a professional multi-asset trend-following trading system. The EA must support three asset categories: 1. Forex – 7 recommended currency pairs. 2. Synthetic Indices – 2 recommended instruments. 3. Gold – XAUUSD. The EA must support two independent trading modes: - Scalping Mode. - Swing Mode. 1. INDEPENDENT INSTRUMENT
The idea of the trading system is as follows : market entries are performed when MACD's main and signal lines intersect in the current trend direction . 2. Trend is determined based on the Exponential Moving Average with the specified period (InpMATrendPeriod). If the current EMA value is greater than the previous one, the trend is seen as growing (ema_current > ema_previous). Alternatively, if current EMA is
I want experience developer , developing on new ea , but my hand in ex5 file only .I need modify my ea file iwant to fixing on daily profit maximum percentage and maximum loss production
hello my friends i do spx and qqq trading options in my school a learned to use tc 2000 charts but not accurate im looking for good strategies that include marketmaker moving too and support resistencies tendencies too how can you help me? thanks

Informazioni sul progetto

Budget
30+ USD

Cliente

Ordini effettuati1
Numero di arbitraggi0