Simple MA Crossover with very powerful money management for both MQL4 and MQL5

Şartname

//+------------------------------------------------------------------+
//| $10 Smart Scalping Bot for MT5 |
//| EURGBP + AUDUSD + XAGUSD Optimized |
//+------------------------------------------------------------------+
#property strict

#include <Trade/Trade.mqh>
CTrade trade;

//========================= INPUTS ==================================
input double LotSize = 0.01;

input int FastEMA = 20;
input int SlowEMA = 50;
input int RSIPeriod = 14;

input double BuyRSI = 55.0;
input double SellRSI = 45.0;

input int StopLoss = 150;
input int TakeProfit = 350;

input int MaxSpread = 35;

input int MaxOpenTrades = 1;
input int MaxDailyLosses = 3;

input bool UseTrailingStop = true;
input int TrailingStop = 80;

//========================= VARIABLES ===============================
int fastEMAHandle;
int slowEMAHandle;
int rsiHandle;

double fastEMA[];
double slowEMA[];
double rsi[];

int dailyLosses = 0;

//+------------------------------------------------------------------+
//| Expert Initialization |
//+------------------------------------------------------------------+
int OnInit()
{
   // Allow only these symbols
   if(_Symbol != "EURGBP" &&
      _Symbol != "AUDUSD" &&
      _Symbol != "XAGUSD")
   {
      Print("Use only EURGBP, AUDUSD or XAGUSD");
      return(INIT_FAILED);
   }

   // Create indicators
   fastEMAHandle = iMA(_Symbol, PERIOD_M5, FastEMA, 0, MODE_EMA, PRICE_CLOSE);
   slowEMAHandle = iMA(_Symbol, PERIOD_M5, SlowEMA, 0, MODE_EMA, PRICE_CLOSE);
   rsiHandle = iRSI(_Symbol, PERIOD_M5, RSIPeriod, PRICE_CLOSE);

   if(fastEMAHandle == INVALID_HANDLE ||
      slowEMAHandle == INVALID_HANDLE ||
      rsiHandle == INVALID_HANDLE)
   {
      Print("Indicator creation failed");
      return(INIT_FAILED);
   }

   Print("Smart $10 Scalper Loaded");

   return(INIT_SUCCEEDED);
}

//+------------------------------------------------------------------+
//| Main Trading Logic |
//+------------------------------------------------------------------+
void OnTick()
{
   // Daily protection
   if(dailyLosses >= MaxDailyLosses)
   {
      Print("Daily loss limit reached.");
      return;
   }

   // Max open trades protection
   if(PositionsTotal() >= MaxOpenTrades)
   {
      ManageTrailingStop();
      return;
   }

   // Spread filter
   double spread =
      (SymbolInfoDouble(_Symbol, SYMBOL_ASK) -
       SymbolInfoDouble(_Symbol, SYMBOL_BID)) / _Point;

   if(spread > MaxSpread)
      return;

   // Get indicator values
   CopyBuffer(fastEMAHandle, 0, 0, 3, fastEMA);
   CopyBuffer(slowEMAHandle, 0, 0, 3, slowEMA);
   CopyBuffer(rsiHandle, 0, 0, 3, rsi);

   double ask = SymbolInfoDouble(_Symbol, SYMBOL_ASK);
   double bid = SymbolInfoDouble(_Symbol, SYMBOL_BID);

   //================ BUY CONDITIONS =================
   bool buySignal =
      fastEMA[1] < slowEMA[1] &&
      fastEMA[0] > slowEMA[0] &&
      rsi[0] > BuyRSI;

   if(buySignal)
   {
      double sl = ask - StopLoss * _Point;
      double tp = ask + TakeProfit * _Point;

      trade.Buy(LotSize, _Symbol, ask, sl, tp, "BUY");
   }

   //================ SELL CONDITIONS ================
   bool sellSignal =
      fastEMA[1] > slowEMA[1] &&
      fastEMA[0] < slowEMA[0] &&
      rsi[0] < SellRSI;

   if(sellSignal)
   {
      double sl = bid + StopLoss * _Point;
      double tp = bid - TakeProfit * _Point;

      trade.Sell(LotSize, _Symbol, bid, sl, tp, "SELL");
   }

   // Trailing stop
   ManageTrailingStop();
}

//+------------------------------------------------------------------+
//| Trailing Stop Function |
//+------------------------------------------------------------------+
void ManageTrailingStop()
{
   if(!UseTrailingStop)
      return;

   for(int i = PositionsTotal() - 1; i >= 0; i--)
   {
      ulong ticket = PositionGetTicket(i);

      if(PositionSelectByTicket(ticket))
      {
         double currentSL = PositionGetDouble(POSITION_SL);
         double tp = PositionGetDouble(POSITION_TP);

         ENUM_POSITION_TYPE type =
            (ENUM_POSITION_TYPE)PositionGetInteger(POSITION_TYPE);

         double priceCurrent;

         // BUY POSITION
         if(type == POSITION_TYPE_BUY)
         {
            priceCurrent = SymbolInfoDouble(_Symbol, SYMBOL_BID);

            double newSL = priceCurrent - TrailingStop * _Point;

            if(newSL > currentSL)
            {
               trade.PositionModify(ticket, newSL, tp);
            }
         }

         // SELL POSITION
         if(type == POSITION_TYPE_SELL)
         {
            priceCurrent = SymbolInfoDouble(_Symbol, SYMBOL_ASK);

            double newSL = priceCurrent + TrailingStop * _Point;

            if(currentSL == 0 || newSL < currentSL)
            {
               trade.PositionModify(ticket, newSL, tp);
            }
         }
      }
   }
}

//+------------------------------------------------------------------+
//| Track Losing Trades |
//+------------------------------------------------------------------+
void OnTradeTransaction(
   const MqlTradeTransaction &trans,
   const MqlTradeRequest &request,
   const MqlTradeResult &result)
{
   if(trans.type == TRADE_TRANSACTION_DEAL_ADD)
   {
      double profit = HistoryDealGetDouble(trans.deal, DEAL_PROFIT);

      if(profit < 0)
      {
         dailyLosses++;
      }
   }
}
//+------------------------------------------------------------------+

Yanıtlandı

1
Geliştirici 1
Derecelendirme
(258)
Projeler
322
30%
Arabuluculuk
34
26% / 65%
Süresi dolmuş
10
3%
Çalışıyor
2
Geliştirici 2
Derecelendirme
(382)
Projeler
493
23%
Arabuluculuk
59
56% / 25%
Süresi dolmuş
57
12%
Yüklendi
3
Geliştirici 3
Derecelendirme
(2)
Projeler
2
0%
Arabuluculuk
0
Süresi dolmuş
0
Serbest
4
Geliştirici 4
Derecelendirme
(104)
Projeler
127
24%
Arabuluculuk
23
30% / 52%
Süresi dolmuş
8
6%
Serbest
5
Geliştirici 5
Derecelendirme
(279)
Projeler
376
72%
Arabuluculuk
19
32% / 47%
Süresi dolmuş
14
4%
Serbest
Yayınlandı: 14 kod
6
Geliştirici 6
Derecelendirme
Projeler
0
0%
Arabuluculuk
0
Süresi dolmuş
0
Serbest
7
Geliştirici 7
Derecelendirme
(2)
Projeler
3
0%
Arabuluculuk
0
Süresi dolmuş
0
Serbest
8
Geliştirici 8
Derecelendirme
(258)
Projeler
265
29%
Arabuluculuk
0
Süresi dolmuş
3
1%
Serbest
Yayınlandı: 2 kod
9
Geliştirici 9
Derecelendirme
(454)
Projeler
717
34%
Arabuluculuk
34
71% / 9%
Süresi dolmuş
22
3%
Serbest
10
Geliştirici 10
Derecelendirme
Projeler
0
0%
Arabuluculuk
0
Süresi dolmuş
0
Serbest
11
Geliştirici 11
Derecelendirme
(198)
Projeler
255
21%
Arabuluculuk
22
50% / 18%
Süresi dolmuş
0
Çalışıyor
12
Geliştirici 12
Derecelendirme
(578)
Projeler
669
32%
Arabuluculuk
42
45% / 45%
Süresi dolmuş
12
2%
Meşgul
13
Geliştirici 13
Derecelendirme
(33)
Projeler
36
33%
Arabuluculuk
5
0% / 80%
Süresi dolmuş
0
Çalışıyor
Yayınlandı: 2 kod
14
Geliştirici 14
Derecelendirme
(46)
Projeler
59
53%
Arabuluculuk
7
86% / 0%
Süresi dolmuş
2
3%
Çalışıyor
15
Geliştirici 15
Derecelendirme
Projeler
0
0%
Arabuluculuk
0
Süresi dolmuş
0
Serbest
16
Geliştirici 16
Derecelendirme
(314)
Projeler
560
35%
Arabuluculuk
80
31% / 44%
Süresi dolmuş
203
36%
Yüklendi
17
Geliştirici 17
Derecelendirme
(2)
Projeler
2
0%
Arabuluculuk
0
Süresi dolmuş
0
Serbest
18
Geliştirici 18
Derecelendirme
(268)
Projeler
600
35%
Arabuluculuk
64
20% / 58%
Süresi dolmuş
147
25%
Çalışıyor
Yayınlandı: 1 makale, 22 kod
19
Geliştirici 19
Derecelendirme
Projeler
0
0%
Arabuluculuk
0
Süresi dolmuş
0
Serbest
20
Geliştirici 20
Derecelendirme
(640)
Projeler
864
48%
Arabuluculuk
29
38% / 17%
Süresi dolmuş
63
7%
Çalışıyor
21
Geliştirici 21
Derecelendirme
(512)
Projeler
551
53%
Arabuluculuk
13
69% / 15%
Süresi dolmuş
3
1%
Serbest
22
Geliştirici 22
Derecelendirme
(11)
Projeler
18
28%
Arabuluculuk
4
50% / 50%
Süresi dolmuş
1
6%
Serbest
23
Geliştirici 23
Derecelendirme
(62)
Projeler
90
29%
Arabuluculuk
24
13% / 58%
Süresi dolmuş
7
8%
Çalışıyor
24
Geliştirici 24
Derecelendirme
(4)
Projeler
5
0%
Arabuluculuk
1
100% / 0%
Süresi dolmuş
1
20%
Yüklendi
25
Geliştirici 25
Derecelendirme
(363)
Projeler
436
54%
Arabuluculuk
21
52% / 14%
Süresi dolmuş
30
7%
Yüklendi
26
Geliştirici 26
Derecelendirme
(250)
Projeler
460
26%
Arabuluculuk
139
20% / 60%
Süresi dolmuş
100
22%
Serbest
27
Geliştirici 27
Derecelendirme
(6)
Projeler
7
43%
Arabuluculuk
1
0% / 100%
Süresi dolmuş
0
Serbest
28
Geliştirici 28
Derecelendirme
(8)
Projeler
8
0%
Arabuluculuk
2
50% / 0%
Süresi dolmuş
1
13%
Çalışıyor
29
Geliştirici 29
Derecelendirme
Projeler
0
0%
Arabuluculuk
0
Süresi dolmuş
0
Serbest
30
Geliştirici 30
Derecelendirme
Projeler
0
0%
Arabuluculuk
0
Süresi dolmuş
0
Serbest
Benzer siparişler
Am looking for Professional programmer who can build below analysis bot as specified below. The indicators will be provided. 🔷 1. CORE ARCHITECTURE OF YOUR EA Your EA has 3 modes: ✅ Mode 1: Indicator 1 Strategy (9-Signal Engine) ✅ Mode 2: Indicator 2 Strategy (Multi-indicator confluence) ✅ Mode 3: Hybrid Mode (Indicator 1 filters Indicator 2) 🔷 2. PAIR SELECTION LOGIC EA will NOT auto-scan market (based on your
Matriks programında güzel bir stratejim var, meta da kayıtlı olmayan iki indikatörümü de metaya yükledim, stratejim belli, ama robot oluşturmak konusunda bilgim eksik. Yardım istiyorum. Acil dönüş bekliyorum. 12-276 üssel ortalamayı hangi yöne keserse, alphatrend indikaörüde bunu desteklesin, kendi gömdüpüm diğer bir indikatörde seviyelere göre alsın satsın
Hi. Could you slightly rewrite my cBot for me to use a 5-minute chart without a fixed target? The stop should be a trailing stop at the level of the initial range
MT5 EA Developer for Structured ICT/SMC Market Logic Requirements Specification: I need an MT5 Expert Advisor only in MQL5. No indicator, no script, no DLL, and no external API. The EA must be built on a rule-based ICT/SMC-style framework with objective, backtestable logic. I am not looking for social-media-style ICT/SMC interpretation. I need a developer who can convert trading concepts into clear coding rules. The
Hi all, I am looking for a top-rated, experienced MQL5 developer to code Phase 1 (Retail Version) of an advanced Expert Advisor for MetaTrader 5. Key Requirements: 1. Pure Price Action Strategy: Uses H4 Trend Filter (Swing High/Low) and H1 Execution (Wick Scanning >= 66% & Engulfing Candlesticks). Places orders via Buy/Sell Limit at Fibonacci 50% level of the candle body (with Giant Candle threshold rules). 2
I want a mobile bot to trade automatically on my behalf must have experience and be willing to verify your work. It must be profitable and user friendly be easy to use and connect. You'll be given a share of profits
Szukam doświadczonego programisty do stworzenia dedykowanego doradcy eksperckiego (EA) do tradingu. Programista powinien posiadać solidną wiedzę z zakresu MT5, logiki strategii, wskaźników, zarządzania ryzykiem i backtestingu. Doświadczenie w tworzeniu niezawodnych i profesjonalnych robotów handlowych będzie dodatkowym atutem. Proszę o kontakt, jeśli zrealizowałeś już podobne projekty. wszystkie szczeguły podam w
Looking for an experienced programmer to create a fully automated trading system. The EA must be able to detect SPECIFIC H&Shoulder patterns, identify entry point and open a position. Parameters: Candle Count : EX: 50 - meaning the max amount of candle history to look for a pattern. (user adjustable) RISK: EG "2" Meaning the position that must be opened must be 2% of the Balance of the account (user adjustable). The
I’m looking for an experienced MetaTrader 4 (MT4) developer to analyze, repair, and live-test an existing .EX4 Expert Advisor. Project Details Existing file: GannMadeEasy_pro.ex4 Platform: MetaTrader 4 Issue: EA is not loading properly on charts in newer MT4 builds Goal: Make the EA fully functional and compatible with current MT4 versions Requirements The developer must: Analyze the existing EX4 file Identify
i need the EA same working on trading view chart with same specifications of enter in a trade and sl/tp open 2 trades and 1 trade set tp1 & second trade set to tp 3 but sl should move to breakeven when tp1 hit and go to tp2 sl on tp1

Proje bilgisi

Bütçe
30 - 300 USD
KDV (21%): 6.3 - 63 USD
Toplam: 36 - 363 USD
Geliştirici için
27 - 270 USD
Son teslim tarihi
from 5 to 20 gün

Müşteri

Verilmiş siparişler1
Arabuluculuk sayısı0