Discussing the article: "Automated Risk Management for Passing Prop Firm Challenges"

 

Check out the new article: Automated Risk Management for Passing Prop Firm Challenges.

This article explains the design of a prop-firm Expert Advisor for GOLD, featuring breakout filters, multi-timeframe analysis, robust risk management, and strict drawdown protection. The EA helps traders pass prop-firm challenges by avoiding rule breaches and stabilizing trade execution under volatile market conditions.

This is an article that I have written with the sole aim of addressing a recently emerged phenomenon in the form of prop firm trading. The thing is, prop firm trading as a whole is a very niche, lucrative, and rewarding endeavor but has vast challenges and hindrances once one decides to go towards this path. The most common hindrance that most traders attempting prop firm challenges face is not a lack of strategy, technique, or skill but rather strict limitations and trading rules set by the prop firm that have to be respected and adhered to in order for a trader to prove he can be granted access to a live trading account.

The thing is a trader can analyze the market well, stick to his/her trading plan, execute trades, and even see trends, which may easily be good enough for personal live funds trading but not prop-firm trading, which requires a trader to stick to its rules and set limits.

Some of the most common rules, targets, and limits are:

  • One should not exceed the set daily drawdown limit, which usually resets at midnight. Different prop firms have different limits, and also the type of account one purchases may be a factor in the drawdown limit.
  • A trader should not violate the overall drawdown limit set, as this will put a stop to trading in that particular account. The limits vary for different prop firms and also types of accounts.  
  • A trader should avoid trying to take advantage of sudden, violent, and volatile movements in the market during news releases, as this may pose a very dangerous and high level of risk to the account because of the lack of direction or choppy price action.
  • A trader is also supposed to keep the same risk profile and exposure during the trading period  for a steady and stable equity curve to shun away traders who over leverage or try to bet it all in one trade. 
  • Traders are also required to trade with discipline every day and not engage in activities that pose risk to the prop firm or account or engage in unwarranted practices such as arbitrage trading or high-frequency trading.


Author: Eugene Mmene

 
Breakout_and_Risk_manager_EA.mq5
Trade.mqh
Object.mqh
StdLibErr.mqh
OrderInfo.mqh
HistoryOrderInfo.mqh
PositionInfo.mqh
DealInfo.mqh
idenfitier 'SymbolName' already used Breakout_and_Risk_manager_EA.mq5 41 8
   built-in 'SymbolName' 0
open parenthesis expected Breakout_and_Risk_manager_EA.mq5 83 18
open parenthesis expected Breakout_and_Risk_manager_EA.mq5 85 18
open parenthesis expected Breakout_and_Risk_manager_EA.mq5 86 45
open parenthesis expected Breakout_and_Risk_manager_EA.mq5 88 31
implicit conversion from 'number' to 'string' Breakout_and_Risk_manager_EA.mq5 88 21
open parenthesis expected Breakout_and_Risk_manager_EA.mq5 89 51
open parenthesis expected Breakout_and_Risk_manager_EA.mq5 106 37
implicit conversion from 'number' to 'string' Breakout_and_Risk_manager_EA.mq5 106 27
open parenthesis expected Breakout_and_Risk_manager_EA.mq5 107 41
implicit conversion from 'number' to 'string' Breakout_and_Risk_manager_EA.mq5 107 31
open parenthesis expected Breakout_and_Risk_manager_EA.mq5 108 39
implicit conversion from 'number' to 'string' Breakout_and_Risk_manager_EA.mq5 108 29
open parenthesis expected Breakout_and_Risk_manager_EA.mq5 116 29
implicit conversion from 'number' to 'string' Breakout_and_Risk_manager_EA.mq5 116 19
open parenthesis expected Breakout_and_Risk_manager_EA.mq5 117 29
implicit conversion from 'number' to 'string' Breakout_and_Risk_manager_EA.mq5 117 19
open parenthesis expected Breakout_and_Risk_manager_EA.mq5 206 96
implicit conversion from 'unknown' to 'string' Breakout_and_Risk_manager_EA.mq5 206 85
open parenthesis expected Breakout_and_Risk_manager_EA.mq5 241 164
implicit conversion from 'number' to 'string' Breakout_and_Risk_manager_EA.mq5 241 154
open parenthesis expected Breakout_and_Risk_manager_EA.mq5 241 216
implicit conversion from 'number' to 'string' Breakout_and_Risk_manager_EA.mq5 241 206
open parenthesis expected Breakout_and_Risk_manager_EA.mq5 253 51
implicit conversion from 'number' to 'string' Breakout_and_Risk_manager_EA.mq5 253 41
open parenthesis expected Breakout_and_Risk_manager_EA.mq5 255 177
implicit conversion from 'number' to 'string' Breakout_and_Risk_manager_EA.mq5 255 167
open parenthesis expected Breakout_and_Risk_manager_EA.mq5 262 67
implicit conversion from 'number' to 'string' Breakout_and_Risk_manager_EA.mq5 262 57
open parenthesis expected Breakout_and_Risk_manager_EA.mq5 262 99
open parenthesis expected Breakout_and_Risk_manager_EA.mq5 262 131
implicit conversion from 'number' to 'string' Breakout_and_Risk_manager_EA.mq5 262 121
implicit conversion from 'number' to 'string' Breakout_and_Risk_manager_EA.mq5 262 89
open parenthesis expected Breakout_and_Risk_manager_EA.mq5 263 53
open parenthesis expected Breakout_and_Risk_manager_EA.mq5 263 84
implicit conversion from 'number' to 'string' Breakout_and_Risk_manager_EA.mq5 263 74
implicit conversion from 'number' to 'string' Breakout_and_Risk_manager_EA.mq5 263 43
open parenthesis expected Breakout_and_Risk_manager_EA.mq5 263 149
implicit conversion from 'number' to 'string' Breakout_and_Risk_manager_EA.mq5 263 139
open parenthesis expected Breakout_and_Risk_manager_EA.mq5 270 52
implicit conversion from 'number' to 'string' Breakout_and_Risk_manager_EA.mq5 270 42
open parenthesis expected Breakout_and_Risk_manager_EA.mq5 275 39
open parenthesis expected Breakout_and_Risk_manager_EA.mq5 277 51
open parenthesis expected Breakout_and_Risk_manager_EA.mq5 284 52
implicit conversion from 'number' to 'string' Breakout_and_Risk_manager_EA.mq5 284 42
open parenthesis expected Breakout_and_Risk_manager_EA.mq5 289 40
open parenthesis expected Breakout_and_Risk_manager_EA.mq5 291 51
open parenthesis expected Breakout_and_Risk_manager_EA.mq5 143 93
implicit conversion from 'unknown' to 'string' Breakout_and_Risk_manager_EA.mq5 143 83
open parenthesis expected Breakout_and_Risk_manager_EA.mq5 147 75
open parenthesis expected Breakout_and_Risk_manager_EA.mq5 306 94
implicit conversion from 'unknown' to 'string' Breakout_and_Risk_manager_EA.mq5 306 83
open parenthesis expected Breakout_and_Risk_manager_EA.mq5 313 103
implicit conversion from 'number' to 'string' Breakout_and_Risk_manager_EA.mq5 313 93
open parenthesis expected Breakout_and_Risk_manager_EA.mq5 313 146
implicit conversion from 'number' to 'string' Breakout_and_Risk_manager_EA.mq5 313 136
open parenthesis expected Breakout_and_Risk_manager_EA.mq5 323 35
open parenthesis expected Breakout_and_Risk_manager_EA.mq5 329 35
open parenthesis expected Breakout_and_Risk_manager_EA.mq5 336 47
implicit conversion from 'number' to 'string' Breakout_and_Risk_manager_EA.mq5 336 37
open parenthesis expected Breakout_and_Risk_manager_EA.mq5 356 35
open parenthesis expected Breakout_and_Risk_manager_EA.mq5 434 35
implicit conversion from 'number' to 'string' Breakout_and_Risk_manager_EA.mq5 434 25
open parenthesis expected Breakout_and_Risk_manager_EA.mq5 465 34
open parenthesis expected Breakout_and_Risk_manager_EA.mq5 465 59
implicit conversion from 'number' to 'string' Breakout_and_Risk_manager_EA.mq5 465 49
implicit conversion from 'number' to 'string' Breakout_and_Risk_manager_EA.mq5 465 24
open parenthesis expected Breakout_and_Risk_manager_EA.mq5 466 46
implicit conversion from 'number' to 'string' Breakout_and_Risk_manager_EA.mq5 466 36
open parenthesis expected Breakout_and_Risk_manager_EA.mq5 472 32
open parenthesis expected Breakout_and_Risk_manager_EA.mq5 472 56
implicit conversion from 'number' to 'string' Breakout_and_Risk_manager_EA.mq5 472 46
implicit conversion from 'number' to 'string' Breakout_and_Risk_manager_EA.mq5 472 22
open parenthesis expected Breakout_and_Risk_manager_EA.mq5 473 46
implicit conversion from 'number' to 'string' Breakout_and_Risk_manager_EA.mq5 473 36
open parenthesis expected Breakout_and_Risk_manager_EA.mq5 479 47
implicit conversion from 'number' to 'string' Breakout_and_Risk_manager_EA.mq5 479 37
open parenthesis expected Breakout_and_Risk_manager_EA.mq5 482 47
implicit conversion from 'number' to 'string' Breakout_and_Risk_manager_EA.mq5 482 37
open parenthesis expected Breakout_and_Risk_manager_EA.mq5 483 47
implicit conversion from 'number' to 'string' Breakout_and_Risk_manager_EA.mq5 483 37
47 errors, 34 warnings 47 34

I downloaded the Mql5 source code, that's a lot of work, thank you for that, but, above are all the warnings and errors that the MetaEditor throws out when compiling the code.

How could this be rectified, please?

 
MetaQuotes:

Check out the new article: Automated Risk Management for Passing Prop Firm Challenges.

Author: Eugene Mmene

Replace string TradeSymbol = _Symbol;

Then replace all occurences of SymbolName by TradeSymbol

 
Austin Reade #:

I downloaded the Mql5 source code, that's a lot of work, thank you for that, but, above are all the warnings and errors that the MetaEditor throws out when compiling the code.

How could this be rectified, please?

Aaah sorry about that  I think I know where the errors originate from I will debug and upload again
 
Laurent Xavier Richer #:

Replace string TradeSymbol = _Symbol;

Then replace all occurences of SymbolName by TradeSymbol

Spot on
 
#property copyright "Copyright 2025, Crystal Forex"
#property link ""
#property version   "1.50"
#property description "🚀 DOMINATE PROP FIRMS: Engineered exclusively for XAUUSD to crush challenges."
#property description "🛡️ INSTITUTIONAL PROTECTION: Hard-coded Drawdown & Equity Guards ensure you never breach rules."
#property description "📈 ADAPTIVE BREAKOUTS: Smart News Filters & Multi-Timeframe logic capture massive Gold moves."
#property description "💰 FUNDED READY: Fully automated discipline to turn your trading into a professional career."

#include <Trade\Trade.mqh>

//+------------------------------------------------------------------+
//| Input Parameters                                                 |
//+------------------------------------------------------------------+
input group "Risk Management"
input double RiskPct = 2.0;               // Base risk per trade %
input double MaxLossUSD = 110.0;          // Maximum loss per trade in USD (Hard Cap)
input double DailyDDLimit = 2.5;          // Daily Drawdown Limit (%)
input double OverallDDLimit = 5.5;        // Overall Drawdown Limit (%)
input double TargetBalanceOrEquity = 108000.0; // Target to pass challenge

input group "Strategy Settings"
input int    ATR_Prd = 14;                // ATR period
input int    Brk_Prd = 10;                // Breakout lookback (Bars)
input double MinBrkStr = 0.1;             // Minimum breakout strength (ATR Multiplier)
input int    EMA_Prd = 20;                // EMA period for Trend Filter
input bool   useHTF = true;               // Use HTF (D1/H4) Direction Filter

input group "News Filter"
input bool   NewsFilt = true;             // Enable News Filter
input int    NewsPause = 15;              // Mins to pause before/after news

//+------------------------------------------------------------------+
//| Global Variables                                                 |
//+------------------------------------------------------------------+
double CurRisk = RiskPct;
double LastEqHigh = 0;
double StartingBalance = 0;
double DailyBalance = 0;
datetime LastDay = 0;
bool ProfitTargetReached = false;
bool DailyDDReached = false;
double dynBrkStr = MinBrkStr; 

CTrade trade;
int h_ema_d1 = INVALID_HANDLE;
int h_ema_h4 = INVALID_HANDLE;
string WorkSymbol; // Renamed to avoid conflict with built-in SymbolName() function

// Structure for Timeframe specific data
struct TimeframeData {
   ENUM_TIMEFRAMES tf;
   int h_atr;
   datetime lastSig;
   datetime lastBar;
};
TimeframeData tfs[];

// Structure for News Events
struct NewsEvt {
   datetime time;
   int impact; // 0=Low, 1=Med, 2=High
};
NewsEvt newsCal[];
int newsCnt = 0;

//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
{
datetime ExpiryDate = D'2025.12.30'; // Set your expiration date here (YYYY.MM.DD)
   
   if(TimeCurrent() > ExpiryDate)
   {
      Alert("Trial Expired! Please contact the developer: https://www.mql5.com/en/users/jawadtrader22/seller");
      Print("Trial Expired! Please contact the developer.");
      return(INIT_FAILED); // This stops the EA from initializing
   }
   if(AccountInfoDouble(ACCOUNT_BALANCE) < 100.0) {
      Print("Error: Balance too low for Prop Firm logic.");
      return(INIT_FAILED);
   }

   WorkSymbol = _Symbol;
   if(!SymbolSelect(WorkSymbol, true)) {
      Print("Failed to select symbol.");
      return(INIT_FAILED);
   }

   StartingBalance = AccountInfoDouble(ACCOUNT_BALANCE);
   LastEqHigh = AccountInfoDouble(ACCOUNT_EQUITY);
   DailyBalance = StartingBalance;
   LastDay = (datetime)(TimeCurrent() / 86400 * 86400); 

   ArrayResize(tfs, 2);
   tfs[0].tf = PERIOD_M15;
   tfs[1].tf = PERIOD_H1;

   for(int i = 0; i < 2; i++) {
      tfs[i].h_atr = iATR(WorkSymbol, tfs[i].tf, ATR_Prd);
      tfs[i].lastBar = 0;
      if(tfs[i].h_atr == INVALID_HANDLE) {
         Print("Failed to create ATR handle.");
         return(INIT_FAILED);
      }
   }

   h_ema_d1 = iMA(WorkSymbol, PERIOD_D1, EMA_Prd, 0, MODE_EMA, PRICE_CLOSE);
   h_ema_h4 = iMA(WorkSymbol, PERIOD_H4, EMA_Prd, 0, MODE_EMA, PRICE_CLOSE);

   if(h_ema_d1 == INVALID_HANDLE || h_ema_h4 == INVALID_HANDLE) {
      Print("Failed to create HTF EMA handles.");
      return(INIT_FAILED);
   }

   if(NewsFilt) FetchNewsCalendar();

   Print("EA Initialized. Target: ", DoubleToString(TargetBalanceOrEquity, 2));
   return(INIT_SUCCEEDED);
}

//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
   IndicatorRelease(h_ema_d1);
   IndicatorRelease(h_ema_h4);
   for(int i = 0; i < ArraySize(tfs); i++) {
      IndicatorRelease(tfs[i].h_atr);
   }
   Print("EA Deinitialized.");
}

//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
{
   // --- Daily Reset Logic ---
   datetime currentDay = (datetime)(TimeCurrent() / 86400 * 86400);
   if(currentDay > LastDay) {
      DailyBalance = AccountInfoDouble(ACCOUNT_BALANCE);
      LastDay = currentDay;
      DailyDDReached = false;
      Print("New Day. Daily Balance Reset to: ", DoubleToString(DailyBalance, 2));
   }

   // --- Prop Firm Checks ---
   if(DailyDDReached || ProfitTargetReached) return;

   double equity = AccountInfoDouble(ACCOUNT_EQUITY);
   double balance = AccountInfoDouble(ACCOUNT_BALANCE);

   if(balance >= TargetBalanceOrEquity || equity >= TargetBalanceOrEquity) {
      CloseAllPositions();
      ProfitTargetReached = true;
      Print("PROFIT TARGET REACHED! Trading Stopped.");
      return;
   }

   double dailyDD = (DailyBalance - equity) / DailyBalance * 100.0;
   double overallDD = (StartingBalance - equity) / StartingBalance * 100.0;

   if(dailyDD >= DailyDDLimit || overallDD >= OverallDDLimit) {
      CloseAllPositions();
      DailyDDReached = true;
      Print("DRAWDOWN LIMIT BREACHED! Daily: ", DoubleToString(dailyDD, 2), "%, Overall: ", DoubleToString(overallDD, 2), "%");
      return;
   }

   // --- News Update ---
   static datetime lastNewsFetch = 0;
   if(NewsFilt && TimeCurrent() >= lastNewsFetch + 4*3600) {
      FetchNewsCalendar();
      lastNewsFetch = TimeCurrent();
   }
   if(NewsFilt && IsNews()) return;

   // --- Strategy Loop ---
   for(int i = 0; i < ArraySize(tfs); i++) 
   {
      ManageTrades(tfs[i].tf);

      if(!NewBar(tfs[i].tf, tfs[i].lastBar)) continue;

      if(PositionsTotal() < 5) 
      {
         double atrVal = GetIndicatorVal(tfs[i].h_atr, 0);
         
         bool buySignal = BuyBrk(tfs[i].tf) && (!useHTF || BullTrend());
         bool sellSignal = SellBrk(tfs[i].tf) && (!useHTF || BearTrend());

         if(buySignal) {
             double sl = SymbolInfoDouble(WorkSymbol, SYMBOL_ASK) - (atrVal * 1.5);
             double tp = SymbolInfoDouble(WorkSymbol, SYMBOL_ASK) + (atrVal * 3.0);
             double lots = CalcLots(MathAbs(SymbolInfoDouble(WorkSymbol, SYMBOL_ASK) - sl));
             
             if(lots > 0) {
                 trade.SetExpertMagicNumber(MagicNumber(tfs[i].tf));
                 trade.Buy(lots, WorkSymbol, 0, sl, tp, "Gold Breakout Buy");
             }
         }
         else if(sellSignal) {
             double sl = SymbolInfoDouble(WorkSymbol, SYMBOL_BID) + (atrVal * 1.5);
             double tp = SymbolInfoDouble(WorkSymbol, SYMBOL_BID) - (atrVal * 3.0);
             double lots = CalcLots(MathAbs(sl - SymbolInfoDouble(WorkSymbol, SYMBOL_BID)));
             
             if(lots > 0) {
                 trade.SetExpertMagicNumber(MagicNumber(tfs[i].tf));
                 trade.Sell(lots, WorkSymbol, 0, sl, tp, "Gold Breakout Sell");
             }
         }
      }
   }
}

//+------------------------------------------------------------------+
//| Helper Functions                                                 |
//+------------------------------------------------------------------+
double CalcLots(double slPointsDistance)
{
   if(slPointsDistance <= 0) return 0.0;
   double accountBalance = AccountInfoDouble(ACCOUNT_BALANCE);
   double riskMoney = accountBalance * (CurRisk / 100.0);
   if(riskMoney > MaxLossUSD) riskMoney = MaxLossUSD; // Hard Cap
   
   double tickValue = SymbolInfoDouble(WorkSymbol, SYMBOL_TRADE_TICK_VALUE);
   double tickSize = SymbolInfoDouble(WorkSymbol, SYMBOL_TRADE_TICK_SIZE);
   if(tickValue == 0 || tickSize == 0) return 0.0;
   
   double lots = riskMoney / ( (slPointsDistance / tickSize) * tickValue );
   double minLot = SymbolInfoDouble(WorkSymbol, SYMBOL_VOLUME_MIN);
   double maxLot = SymbolInfoDouble(WorkSymbol, SYMBOL_VOLUME_MAX);
   double stepLot = SymbolInfoDouble(WorkSymbol, SYMBOL_VOLUME_STEP);
   
   lots = MathFloor(lots / stepLot) * stepLot;
   if(lots < minLot) return 0.0;
   if(lots > maxLot) lots = maxLot;
   return lots;
}

void ManageTrades(ENUM_TIMEFRAMES tf)
{
   for(int i = PositionsTotal()-1; i >= 0; i--)
   {
      ulong ticket = PositionGetTicket(i);
      if(!PositionSelectByTicket(ticket)) continue;
      if(PositionGetString(POSITION_SYMBOL) != WorkSymbol) continue;
      if(PositionGetInteger(POSITION_MAGIC) != MagicNumber(tf)) continue; 

      double openPrice = PositionGetDouble(POSITION_PRICE_OPEN);
      double sl = PositionGetDouble(POSITION_SL);
      double tp = PositionGetDouble(POSITION_TP);
      double lots = PositionGetDouble(POSITION_VOLUME);
      double currentPrice = PositionGetDouble(POSITION_PRICE_CURRENT);
      long type = PositionGetInteger(POSITION_TYPE);
      
      int tfIdx = (tf == PERIOD_M15) ? 0 : 1;
      double atr = GetIndicatorVal(tfs[tfIdx].h_atr, 0);

      // Emergency Exit
      if(type == POSITION_TYPE_BUY && SellBrk(tf)) { trade.PositionClose(ticket); continue; }
      if(type == POSITION_TYPE_SELL && BuyBrk(tf)) { trade.PositionClose(ticket); continue; }

      // Partial Close & BE
      double dist = (type == POSITION_TYPE_BUY) ? (currentPrice - openPrice) : (openPrice - currentPrice);
      if(dist > (atr * 2.5)) {
         bool isBE = (type == POSITION_TYPE_BUY && sl >= openPrice) || (type == POSITION_TYPE_SELL && sl <= openPrice);
         if(!isBE && lots >= SymbolInfoDouble(WorkSymbol, SYMBOL_VOLUME_MIN) * 2) {
             trade.PositionClosePartial(ticket, lots / 2.0);
             trade.PositionModify(ticket, openPrice, tp);
         }
      }

      // Trailing Stop
      double trailDist = atr * 1.6;
      if(type == POSITION_TYPE_BUY) {
         double newSL = currentPrice - trailDist;
         if(newSL > sl && newSL < currentPrice) trade.PositionModify(ticket, newSL, tp);
      }
      else if(type == POSITION_TYPE_SELL) {
         double newSL = currentPrice + trailDist;
         if(newSL < sl || sl == 0) trade.PositionModify(ticket, newSL, tp);
      }
   }
}

bool BuyBrk(ENUM_TIMEFRAMES tf)
{
   double close1 = iClose(WorkSymbol, tf, 1);
   int highIdx = iHighest(WorkSymbol, tf, MODE_HIGH, Brk_Prd, 2);
   if(highIdx < 0) return false;
   double highVal = iHigh(WorkSymbol, tf, highIdx);
   int tfIdx = (tf == PERIOD_M15) ? 0 : 1;
   double atr = GetIndicatorVal(tfs[tfIdx].h_atr, 1);
   return (close1 > (highVal + (atr * dynBrkStr)));
}

bool SellBrk(ENUM_TIMEFRAMES tf)
{
   double close1 = iClose(WorkSymbol, tf, 1);
   int lowIdx = iLowest(WorkSymbol, tf, MODE_LOW, Brk_Prd, 2);
   if(lowIdx < 0) return false;
   double lowVal = iLow(WorkSymbol, tf, lowIdx);
   int tfIdx = (tf == PERIOD_M15) ? 0 : 1;
   double atr = GetIndicatorVal(tfs[tfIdx].h_atr, 1);
   return (close1 < (lowVal - (atr * dynBrkStr)));
}

bool BullTrend()
{
   double d1_ema = GetIndicatorVal(h_ema_d1, 1);
   double d1_close = iClose(WorkSymbol, PERIOD_D1, 1);
   return (d1_close > d1_ema);
}

bool BearTrend()
{
   double d1_ema = GetIndicatorVal(h_ema_d1, 1);
   double d1_close = iClose(WorkSymbol, PERIOD_D1, 1);
   return (d1_close < d1_ema);
}

bool IsNews()
{
   datetime now = TimeCurrent();
   for(int i=0; i<newsCnt; i++) {
       if(newsCal[i].impact < 2) continue; 
       if(now >= newsCal[i].time - (NewsPause * 60) && now <= newsCal[i].time + (NewsPause * 60)) return true;
   }
   return false;
}

void FetchNewsCalendar()
{
   // Placeholder: Reset news counter for safety
   newsCnt = 0; 
}

void CloseAllPositions()
{
   for(int i = PositionsTotal() - 1; i >= 0; i--) {
      ulong ticket = PositionGetTicket(i);
      if(PositionSelectByTicket(ticket) && PositionGetString(POSITION_SYMBOL) == WorkSymbol) {
         trade.PositionClose(ticket);
      }
   }
}

double GetIndicatorVal(int handle, int index)
{
   double buf[1];
   if(CopyBuffer(handle, 0, index, 1, buf) < 0) return 0.0;
   return buf[0];
}

bool NewBar(ENUM_TIMEFRAMES tf, datetime &last_bar_time)
{
   datetime curr_bar_time = iTime(WorkSymbol, tf, 0);
   if(curr_bar_time != last_bar_time) {
      last_bar_time = curr_bar_time;
      return true;
   }
   return false;
}

long MagicNumber(ENUM_TIMEFRAMES tf)
{
   if(tf == PERIOD_M15) return 1015;
   if(tf == PERIOD_H1) return 1060;
   return 1000;
}
Complete Copy Paste code 
Files:
propfirm.mq5  27 kb
 
Austin Reade #:

I downloaded the Mql5 source code, that's a lot of work, thank you for that, but, above are all the warnings and errors that the MetaEditor throws out when compiling the code.

How could this be rectified, please?

here is corrected code
 
Muhammad Jawad Shabir #:
Complete Copy Paste code 
The code is not the same even results are very different my guy