BITCION AND GOLD

MQL5 Experten

Spezifikation

//+------------------------------------------------------------------+
//|                    LUMO EDGE - MT5 EA                            |
//|                    Owner: Gontse                                 |
//|                                                                  |
//| Automated Forex Scanner & Trading Expert Advisor                |
//| Strategy: EMA 50/200 + ATR + Momentum + Risk Management          |
//+------------------------------------------------------------------+
#property strict
#property version   "1.00"
#property description "Lumo Edge - Automated MT5 Forex Scanner"
#property description "Owner: Gontse"

#include <Trade/Trade.mqh>

CTrade trade;

//====================================================================
// INPUTS
//====================================================================

//--- General
input string   BotName                 = "LUMO EDGE";
input string   OwnerName               = "Gontse";
input long     MagicNumber             = 5050200;

//--- Scanner
input string   SymbolsToScan           =
"EURUSD,GBPUSD,USDJPY,USDCHF,AUDUSD,USDCAD,NZDUSD,"
"EURJPY,GBPJPY,EURGBP,AUDJPY";

//--- Timeframe
input ENUM_TIMEFRAMES SignalTimeframe  = PERIOD_M15;
input ENUM_TIMEFRAMES TrendTimeframe   = PERIOD_H1;

//--- EMA strategy
input int      FastEMA                 = 50;
input int      SlowEMA                 = 200;

//--- ATR
input int      ATRPeriod               = 14;
input double   ATR_SL_Multiplier       = 1.5;
input double   ATR_TP_Multiplier       = 2.0;

//--- Risk
input double   RiskPercent             = 1.0;
input double   MaxDailyLossPercent     = 5.0;
input int      MaxOpenTrades           = 3;

//--- Trade filters
input double   MaxSpreadPoints         = 30;
input int      MinimumSignalScore      = 70;

//--- Profit management
input bool     EnableProfitClose       = true;
input double   MinimumProfitMoney      = 5.00;

//--- Break-even
input bool     EnableBreakEven         = true;
input double   BreakEvenATR            = 1.0;

//--- Trailing stop
input bool     EnableTrailingStop      = true;
input double   TrailingATR             = 1.2;

//--- Trading hours
input bool     UseTradingHours         = true;
input int      StartHour               = 7;
input int      EndHour                 = 21;

//--- Direction
input bool     AllowBuy                = true;
input bool     AllowSell               = true;

//====================================================================
// GLOBALS
//====================================================================

string Symbols[];
datetime LastBarTime[];

//====================================================================
// INITIALIZATION
//====================================================================

int OnInit()
{
   trade.SetExpertMagicNumber(MagicNumber);
   trade.SetDeviationInPoints(20);

   ParseSymbols();

   ArrayResize(LastBarTime, ArraySize(Symbols));

   for(int i = 0; i < ArraySize(LastBarTime); i++)
      LastBarTime[i] = 0;

   Print("==========================================");
   Print(BotName, " initialized.");
   Print("Owner: ", OwnerName);
   Print("Symbols scanned: ", ArraySize(Symbols));
   Print("==========================================");

   return(INIT_SUCCEEDED);
}

//====================================================================
// MAIN LOOP
//====================================================================

void OnTick()
{
   ManageOpenTrades();

   if(!TradingAllowed())
      return;

   if(DailyLossExceeded())
      return;

   if(CountOurPositions() >= MaxOpenTrades)
      return;

   for(int i = 0; i < ArraySize(Symbols); i++)
   {
      string symbol = Symbols[i];

      if(!SymbolSelect(symbol, true))
         continue;

      if(HasOpenPosition(symbol))
         continue;

      if(!IsNewBar(symbol, i))
         continue;

      int signal = GetSignal(symbol);

      if(signal == 1 && AllowBuy)
      {
         if(GetSignalScore(symbol, 1) >= MinimumSignalScore)
            OpenTrade(symbol, ORDER_TYPE_BUY);
      }

      if(signal == -1 && AllowSell)
      {
         if(GetSignalScore(symbol, -1) >= MinimumSignalScore)
            OpenTrade(symbol, ORDER_TYPE_SELL);
      }

      if(CountOurPositions() >= MaxOpenTrades)
         break;
   }

   DrawDashboard();
}

//====================================================================
// SYMBOL PARSER
//====================================================================

void ParseSymbols()
{
   string raw[];
   int count = StringSplit(SymbolsToScan, ',', raw);

   ArrayResize(Symbols, count);

   for(int i = 0; i < count; i++)
   {
      StringTrimLeft(raw[i]);
      StringTrimRight(raw[i]);
      Symbols[i] = raw[i];
   }
}

//====================================================================
// NEW BAR CHECK
//====================================================================

bool IsNewBar(string symbol, int index)
{
   datetime currentBar =
      iTime(symbol, SignalTimeframe, 0);

   if(currentBar == 0)
      return false;

   if(currentBar != LastBarTime[index])
   {
      LastBarTime[index] = currentBar;
      return true;
   }

   return false;
}

//====================================================================
// EMA VALUE
//====================================================================

double GetEMA(string symbol,
              ENUM_TIMEFRAMES timeframe,
              int period,
              int shift)
{
   int handle = iMA(
      symbol,
      timeframe,
      period,
      0,
      MODE_EMA,
      PRICE_CLOSE
   );

   if(handle == INVALID_HANDLE)
      return 0;

   double buffer[];

   ArraySetAsSeries(buffer, true);

   if(CopyBuffer(handle, 0, shift, 1, buffer) <= 0)
   {
      IndicatorRelease(handle);
      return 0;
   }

   double value = buffer[0];

   IndicatorRelease(handle);

   return value;
}

//====================================================================
// ATR VALUE
//====================================================================

double GetATR(string symbol,
              ENUM_TIMEFRAMES timeframe,
              int period,
              int shift)
{
   int handle = iATR(
      symbol,
      timeframe,
      period
   );

   if(handle == INVALID_HANDLE)
      return 0;

   double buffer[];

   ArraySetAsSeries(buffer, true);

   if(CopyBuffer(handle, 0, shift, 1, buffer) <= 0)
   {
      IndicatorRelease(handle);
      return 0;
   }

   double value = buffer[0];

   IndicatorRelease(handle);

   return value;
}

//====================================================================
// SIGNAL
//====================================================================

int GetSignal(string symbol)
{
   double fastEMA =
      GetEMA(symbol, SignalTimeframe, FastEMA, 1);

   double slowEMA =
      GetEMA(symbol, SignalTimeframe, SlowEMA, 1);

   double trendFast =
      GetEMA(symbol, TrendTimeframe, FastEMA, 1);

   double trendSlow =
      GetEMA(symbol, TrendTimeframe, SlowEMA, 1);

   double closePrice =
      iClose(symbol, SignalTimeframe, 1);

   if(fastEMA == 0 ||
      slowEMA == 0 ||
      trendFast == 0 ||
      trendSlow == 0 ||
      closePrice == 0)
      return 0;

   // BUY
   if(fastEMA > slowEMA &&
      trendFast > trendSlow &&
      closePrice > fastEMA)
   {
      return 1;
   }

   // SELL
   if(fastEMA < slowEMA &&
      trendFast < trendSlow &&
      closePrice < fastEMA)
   {
      return -1;
   }

   return 0;
}

//====================================================================
// SIGNAL SCORE
//====================================================================

int GetSignalScore(string symbol, int direction)
{
   int score = 0;

   double fastEMA =
      GetEMA(symbol, SignalTimeframe, FastEMA, 1);

   double slowEMA =
      GetEMA(symbol, SignalTimeframe, SlowEMA, 1);

   double trendFast =
      GetEMA(symbol, TrendTimeframe, FastEMA, 1);

   double trendSlow =
      GetEMA(symbol, TrendTimeframe, SlowEMA, 1);

   double closePrice =
      iClose(symbol, SignalTimeframe, 1);

   double openPrice =
      iOpen(symbol, SignalTimeframe, 1);

   double previousClose =
      iClose(symbol, SignalTimeframe, 2);

   double atr =
      GetATR(symbol, SignalTimeframe, ATRPeriod, 1);

   if(atr <= 0)
      return 0;

   // Trend
   if(direction == 1)
   {
      if(fastEMA > slowEMA)
         score += 25;

      if(trendFast > trendSlow)
         score += 25;

      if(closePrice > fastEMA)
         score += 15;

      if(closePrice > openPrice)
         score += 10;

      if(closePrice > previousClose)
         score += 10;
   }

   if(direction == -1)
   {
      if(fastEMA < slowEMA)
         score += 25;

      if(trendFast < trendSlow)
         score += 25;

      if(closePrice < fastEMA)
         score += 15;

      if(closePrice < openPrice)
         score += 10;

      if(closePrice < previousClose)
         score += 10;
   }

   // Volatility condition
   double candleRange =
      MathAbs(closePrice - openPrice);

   if(candleRange > atr * 0.20)
      score += 15;

   return score;
}

//====================================================================
// OPEN TRADE
//====================================================================

void OpenTrade(string symbol, ENUM_ORDER_TYPE type)
{
   if(!SpreadAllowed(symbol))
      return;

   double atr =
      GetATR(symbol, SignalTimeframe, ATRPeriod, 1);

   if(atr <= 0)
      return;

   double price;

   if(type == ORDER_TYPE_BUY)
      price = SymbolInfoDouble(symbol, SYMBOL_ASK);
   else
      price = SymbolInfoDouble(symbol, SYMBOL_BID);

   double stopDistance =
      atr * ATR_SL_Multiplier;

   double takeDistance =
      atr * ATR_TP_Multiplier;

   double sl;
   double tp;

   if(type == ORDER_TYPE_BUY)
   {
      sl = price - stopDistance;
      tp = price + takeDistance;
   }
   else
   {
      sl = price + stopDistance;
      tp = price - takeDistance;
   }

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

   sl = NormalizeDouble(sl, digits);
   tp = NormalizeDouble(tp, digits);

   double volume =
      CalculateLotSize(symbol, stopDistance);

   if(volume <= 0)
      return;

   bool result = false;

   if(type == ORDER_TYPE_BUY)
   {
      result = trade.Buy(
         volume,
         symbol,
         price,
         sl,
         tp,
         "Lumo Edge BUY"
      );
   }
   else
   {
      result = trade.Sell(
         volume,
         symbol,
         price,
         sl,
         tp,
         "Lumo Edge SELL"
      );
   }

   if(result)
   {
      Print(
         BotName,
         " opened ",
         EnumToString(type),
         " on ",
         symbol,
         " | Lot: ",
         volume,
         " | SL: ",
         sl,
         " | TP: ",
         tp
      );
   }
   else
   {
      Print(
         "Trade failed on ",
         symbol,
         " | Error: ",
         trade.ResultRetcode(),
         " ",
         trade.ResultRetcodeDescription()
      );
   }
}

//====================================================================
// LOT CALCULATOR
//====================================================================

double CalculateLotSize(string symbol,
                        double stopDistance)
{
   double balance =
      AccountInfoDouble(ACCOUNT_BALANCE);

   double riskMoney =
      balance * RiskPercent / 100.0;

   double tickSize =
      SymbolInfoDouble(symbol, SYMBOL_TRADE_TICK_SIZE);

   double tickValue =
      SymbolInfoDouble(symbol, SYMBOL_TRADE_TICK_VALUE);

   double volumeStep =
      SymbolInfoDouble(symbol, SYMBOL_VOLUME_STEP);

   double minVolume =
      SymbolInfoDouble(symbol, SYMBOL_VOLUME_MIN);

   double maxVolume =
      SymbolInfoDouble(symbol, SYMBOL_VOLUME_MAX);

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

   double lossPerLot =
      (stopDistance / tickSize) * tickValue;

   if(lossPerLot <= 0)
      return 0;

   double volume =
      riskMoney / lossPerLot;

   volume =
      MathFloor(volume / volumeStep) * volumeStep;

   volume =
      MathMax(volume, minVolume);

   volume =
      MathMin(volume, maxVolume);

   int volumeDigits = 2;

   if(volumeStep == 0.1)
      volumeDigits = 1;

   if(volumeStep == 0.01)
      volumeDigits = 2;

   if(volumeStep == 0.001)
      volumeDigits = 3;

   return NormalizeDouble(volume, volumeDigits);
}

//====================================================================
// SPREAD FILTER
//====================================================================

bool SpreadAllowed(string symbol)
{
   double ask =
      SymbolInfoDouble(symbol, SYMBOL_ASK);

   double bid =
      SymbolInfoDouble(symbol, SYMBOL_BID);

   double point =
      SymbolInfoDouble(symbol, SYMBOL_POINT);

   if(point <= 0)
      return false;

   double spread =
      (ask - bid) / point;

   return spread <= MaxSpreadPoints;
}

//====================================================================
// POSITION CHECK
//====================================================================

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

      if(ticket == 0)
         continue;

      if(!PositionSelectByTicket(ticket))
         continue;

      string posSymbol =
         PositionGetString(POSITION_SYMBOL);

      long magic =
         PositionGetInteger(POSITION_MAGIC);

      if(posSymbol == symbol &&
         magic == MagicNumber)
      {
         return true;
      }
   }

   return false;
}

//====================================================================
// COUNT OUR POSITIONS
//====================================================================

int CountOurPositions()
{
   int count = 0;

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

      if(ticket == 0)
         continue;

      if(!PositionSelectByTicket(ticket))
         continue;

      long magic =
         PositionGetInteger(POSITION_MAGIC);

      if(magic == MagicNumber)
         count++;
   }

   return count;
}

//====================================================================
// TRADE MANAGEMENT
//====================================================================

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

      if(ticket == 0)
         continue;

      if(!PositionSelectByTicket(ticket))
         continue;

      long magic =
         PositionGetInteger(POSITION_MAGIC);

      if(magic != MagicNumber)
         continue;

      string symbol =
         PositionGetString(POSITION_SYMBOL);

      double profit =
         PositionGetDouble(POSITION_PROFIT);

      //==============================================================
      // PROFIT CLOSE
      //==============================================================

      if(EnableProfitClose &&
         profit >= MinimumProfitMoney)
      {
         if(trade.PositionClose(ticket))
         {
            Print(
               BotName,
               ": profit target reached on ",
               symbol,
               ". Trade closed. Searching for next setup."
            );
         }

         continue;
      }

      //==============================================================
      // BREAK EVEN / TRAILING
      //==============================================================

      double atr =
         GetATR(symbol, SignalTimeframe, ATRPeriod, 1);

      if(atr <= 0)
         continue;

      long positionType =
         PositionGetInteger(POSITION_TYPE);

      double openPrice =
         PositionGetDouble(POSITION_PRICE_OPEN);

      double currentSL =
         PositionGetDouble(POSITION_SL);

      double currentTP =
         PositionGetDouble(POSITION_TP);

      double bid =
         SymbolInfoDouble(symbol, SYMBOL_BID);

      double ask =
         SymbolInfoDouble(symbol, SYMBOL_ASK);

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

      // BUY
      if(positionType == POSITION_TYPE_BUY)
      {
         double profitDistance =
            bid - openPrice;

         if(EnableBreakEven &&
            profitDistance >= atr * BreakEvenATR)
         {
            double newSL = openPrice;

            if(currentSL < newSL)
            {
               trade.PositionModify(
                  ticket,
                  NormalizeDouble(newSL, digits),
                  currentTP
               );
            }
         }

         if(EnableTrailingStop)
         {
            double newSL =
               bid - atr * TrailingATR;

            if(newSL > currentSL &&
               newSL > openPrice)
            {
               trade.PositionModify(
                  ticket,
                  NormalizeDouble(newSL, digits),
                  currentTP
               );
            }
         }
      }

      // SELL
      if(positionType == POSITION_TYPE_SELL)
      {
         double profitDistance =
            openPrice - ask;

         if(EnableBreakEven &&
            profitDistance >= atr * BreakEvenATR)
         {
            double newSL = openPrice;

            if(currentSL == 0 ||
               currentSL > newSL)
            {
               trade.PositionModify(
                  ticket,
                  NormalizeDouble(newSL, digits),
                  currentTP
               );
            }
         }

         if(EnableTrailingStop)
         {
            double newSL =
               ask + atr * TrailingATR;

            if((currentSL == 0 ||
                newSL < currentSL) &&
               newSL < openPrice)
            {
               trade.PositionModify(
                  ticket,
                  NormalizeDouble(newSL, digits),
                  currentTP
               );
            }
         }
      }
   }
}

//====================================================================
// DAILY LOSS PROTECTION
//====================================================================

bool DailyLossExceeded()
{
   double balance =
      AccountInfoDouble(ACCOUNT_BALANCE);

   if(balance <= 0)
      return true;

   datetime dayStart =
      StringToTime(
         TimeToString(
            TimeCurrent(),
            TIME_DATE
         )
      );

   HistorySelect(dayStart, TimeCurrent());

   double todayProfit = 0;

   int deals =
      HistoryDealsTotal();

   for(int i = 0; i < deals; i++)
   {
      ulong deal =
         HistoryDealGetTicket(i);

      if(deal == 0)
         continue;

      long magic =
         HistoryDealGetInteger(
            deal,
            DEAL_MAGIC
         );

      if(magic != MagicNumber)
         continue;

      todayProfit +=
         HistoryDealGetDouble(
            deal,
            DEAL_PROFIT
         );

      todayProfit +=
         HistoryDealGetDouble(
            deal,
            DEAL_SWAP
         );

      todayProfit +=
         HistoryDealGetDouble(
            deal,
            DEAL_COMMISSION
         );
   }

   double lossLimit =
      balance * MaxDailyLossPercent / 100.0;

   return todayProfit <= -lossLimit;
}

//====================================================================
// TRADING HOURS
//====================================================================

bool TradingAllowed()
{
   if(!UseTradingHours)
      return true;

   MqlDateTime tm;

   TimeToStruct(TimeCurrent(), tm);

   if(StartHour < EndHour)
   {
      return tm.hour >= StartHour &&
             tm.hour < EndHour;
   }

   // Handles sessions crossing midnight
   return tm.hour >= StartHour ||
          tm.hour < EndHour;
}

//====================================================================
// DASHBOARD
//====================================================================

void DrawDashboard()
{
   string text = "";

   text += "================================\n";
   text += BotName + "\n";
   text += "Owner: " + OwnerName + "\n";
   text += "================================\n";

   text += "Scanner: ACTIVE\n";
   text += "Timeframe: " +
           EnumToString(SignalTimeframe) + "\n";

   text += "EMA: " +
           IntegerToString(FastEMA) +
           " / " +
           IntegerToString(SlowEMA) + "\n";

   text += "Open trades: " +

Bewerbungen

1
Entwickler 1
Bewertung
(2)
Projekte
4
0%
Schlichtung
0
Frist nicht eingehalten
0
Frei
2
Entwickler 2
Bewertung
(557)
Projekte
851
61%
Schlichtung
33
27% / 45%
Frist nicht eingehalten
24
3%
Frei
Veröffentlicht: 1 Beispiel
3
Entwickler 3
Bewertung
(22)
Projekte
30
40%
Schlichtung
8
25% / 38%
Frist nicht eingehalten
2
7%
Überlastet
Veröffentlicht: 8 Artikel, 35 Beispiele
4
Entwickler 4
Bewertung
(1)
Projekte
1
100%
Schlichtung
0
Frist nicht eingehalten
0
Arbeitet
Veröffentlicht: 2 Beispiele
5
Entwickler 5
Bewertung
Projekte
0
0%
Schlichtung
0
Frist nicht eingehalten
0
Frei
6
Entwickler 6
Bewertung
(2)
Projekte
3
67%
Schlichtung
0
Frist nicht eingehalten
0
Arbeitet
Veröffentlicht: 2 Beispiele
7
Entwickler 7
Bewertung
(263)
Projekte
309
76%
Schlichtung
15
67% / 0%
Frist nicht eingehalten
6
2%
Beschäftigt
8
Entwickler 8
Bewertung
(10)
Projekte
12
33%
Schlichtung
0
Frist nicht eingehalten
2
17%
Arbeitet
Veröffentlicht: 1 Beispiel
9
Entwickler 9
Bewertung
Projekte
0
0%
Schlichtung
0
Frist nicht eingehalten
0
Frei
10
Entwickler 10
Bewertung
Projekte
0
0%
Schlichtung
0
Frist nicht eingehalten
0
Frei
11
Entwickler 11
Bewertung
Projekte
0
0%
Schlichtung
0
Frist nicht eingehalten
0
Frei
12
Entwickler 12
Bewertung
(1)
Projekte
1
0%
Schlichtung
0
Frist nicht eingehalten
0
Frei
Veröffentlicht: 2 Beispiele
Ähnliche Aufträge
Trading bot ea 30+ USD
yoo i want to make a trading bot i have my strategy in videos and also the rules to if anyone can work it out for me i will be glad welcome your bid and it urget let connect here on mgl5 And if you know you can not do the project without getting paid first please don't bid thanks
MT5 EA make work on zone break and candle confirm. Hi i need one expert person who can make exact what i want. My EA logic very simple.... few hrs market high and low make line then candle body close above or low then candle confirmation then pullback then entry RR1:2 no trail nothing,,,,, the line high low create after few hrs of the day i wll tell you later,,,,then 1hrs no trade if break then no trade for the
Hi, I need an Expert Advisor (EA) for MetaTrader 5, for my IC Markets account. Account MT5, hedging account, type: [Raw Spread / Standard: fill in] Deposit: 100 USD, leverage 1:30, account currency: [USD / EUR: fill in] Instruments Forex (major pairs) and gold (XAUUSD) Strategy and parameters may differ per instrument; each instrument must be tested and optimized separately If an instrument cannot be traded safely
المطلوب موشر لتداول الذهب مجرب وقوية يعطي اشاره قوية فقط مع وقف خساره ومختبر ومجرب في حال الموافقه علي لموشر بعد التجربه لمدة ٣ ايام يتم الشراء دايم مبلغ ٢٠٠ دولار
Masoudahg1 999999+ USD
Hello world, thank you for your helping and supporting for us from your for all everyone that investments or working in this programing and supporting seven/24 hours in daily and nightly for customers
Laily Mahmudy 100000+ USD
Thank you very much and of trying supporting and helping for us and my investfolio portfolio id is:"investfolio portfolio masoudahg1 id is":"7Zk0iVh7zuytHkQ9OJSzeY" &"35VmgKWofZxWowQ7O6CL8K" https://leylimahmudi46.atlassian.net is my Atlassian programing that when I working of this programs
Hi there I need someone who will create an ea then test it .. the ea should only place order on the bid price of it breakout in 1 point using invisible buy and invisible sell,, example if bid breakout in 1 point up automatically invisible buy active then invisible stop loss at where the ask price was same in sell If the bid breakout in 1 point down automatically invisible sell active then invisible stop loss where
I’m looking for an experienced MT5/MQL5 freelancer to help install and configure several existing EAs on IC Markets MT5 accounts using a Windows VPS. The work will include setting up the EAs on separate demo accounts and later running several together on one account with different risk settings. I also need help with MT5 backtesting and strategy optimisation, including comparing different risk levels and reviewing
I am looking for someone to build me a modular auto trader in Sierra chart and an Innie builder so that I can replicate my current Algas that I already have built. I've sent examples below can you please let me know how much you would charge me. I'm pretty good at building the signals myself but I do not know how to build the ocos order entry and I'm trying to get quotes and go with the person who seems they can help
i need price action and candle logic understand programmer need for this job... first understand logic and interested please message .... first understand logic and interested please message .... 2 types of hedge entry conditions: 1 is candle based 1- when i start point ea hh candle buy entry, after ll made 2- below the previous candle hedge sell order 3- if market goes again hh, if sell order profit book again

Projektdetails

Budget
50+ USD
Ausführungsfristen
von 1 Tag(e)

Kunde

Veröffentlichte Aufträge1
Anzahl der Schlichtungen0