Mastering PD Arrays: Optimizing Trading from Imbalances in PD Arrays
Introduction
This article aims to address traders who have a difficulty in identifying, determining, and utilizing the correct PD arrays occurring in price action to find and execute high-probability trades and hence choose the correct trade action to execute when price is at different positions at this PD arrays. We will also look at imbalances occurring in this respective PD arrays and how we may utilize them and make trade executions from them.
From my prior experience and traders charter it has occurred to me that very many traders do not understand how to correctly determine, identify, evaluate and measure PD arrays, they also make wrong decisions because of lack of experience or skill when it comes to utilizing PD arrays and imbalances as traders are not keen or skilled enough to know correct PD arrays to use or imbalances that price will trade away from that will work hence picking the wrong one which quickly results into losses and drawdowns hence giving rise to unbased rumours and chatter that the imbalances and PD array concepts do not work.
The second group this article will be very beneficial to is the traders who have partially moderate skills and experience when trading these concepts and hence have a sort of hit-and-miss record where sometimes they are successful in their selection of trading setups, but sometimes they also fail terribly and lack consistency. This article will aim to reinforce their knowledge base and in detail thoroughly explain how PD arrays work, how they form, where, why, and how to effectively optimize the use of imbalances in PD arrays and hence try to identify high-probability trades that occur from this imbalances found in respective PD arrays. It will clearly demonstrate that PD arrays and imbalances, when used optimally, can be very effective and rewarding. The article will clearly describe checkmarks for use when identifying either a valid PD array or imbalance to use; hence, a trader can quickly reference these checkmarks and ascertain his trading decisions, bringing calm, which helps avoid both impulse trading and execution paralysis.
As a trader myself, I know most new and intermediate traders who trade using ICT concepts are faced with this challenge, in-fact all traders face almost similar, if not identical, challenges at some point in their trading careers, but what separates all of them is that different traders handle, react to, and anticipate this challenges differently; hence the difference in trading results, which has proven to be colossal even when traders who are evenly matched and separated by fine margins in skill, experience, composure, decision-making, and technique are different. Also, the same challenge might just be named differently using other concepts, e.g., breakouts; thus, this article will prove beneficial to such traders too and not only to ICT concepts traders, because PD arrays and imbalances will always occur in price action regardless of what trading strategy you are using.
This article will explore in detail an EA that is specifically designed for traders who are keen on learning how to optimally identify and use PD arrays, which usually offer excellent trading opportunities when trading in an identified trend and narrative, avoiding trading against the trend direction, and selling at a discount or buying at a premium. It will also be designed to identify market structure shifts as a trade entry criterion as they occurs at specific market points, such as the end of trends or some major reversals on the higher time frame. It is also specifically optimized to identify PD arrays, and once it determines if price is at discounted or premium, it executes accordingly. Lastly, it keeps track of imbalances on this PD arrays, as they can be very key reaction areas, providing ample opportunity for trade setups.
This EA is also critical for intraday traders and short-term traders since it also helps them trade according to the most possible price movement in the trend's direction likely to occur on that day, hence increasing the success rate as buys only occur in discount and sells in premium arrays, almost daily in different pairs and at least multiple times a week on the same pair.
Definitions: PD Arrays, Imbalances, Market Structure Shifts, Fractal Structure, and OTE
In this chapter I will make definitions and explanations of the most common phrases and tools we will try to use and utilize in this article, since I am very confident not all who will utilize this article are familiar with this concepts and this may be their first time hearing of them, so we have to be inclusive and accommodate everyone onboard for fair learning.
1.Imbalances/Inefficiencies
These imbalances/inefficiencies are created when there are rapid price movements in either direction, indicating strong buying or selling pressure, primarily from institutional players. In simple terms, this trading pressure often leads to a scenario where traders do not have equal opportunities to place or execute trades; therefore, in a bullish inefficiency, where price has left a point with force and speed toward higher prices and sellers have not had enough time or opportunity to execute them, while in a bearish inefficiency, where price has left a point with force and speed toward lower prices and buyers have not had enough time or opportunity to execute them, this area is called an unbalanced price range, as there has been no price movement in the opposite direction from where the expansion came from.
This can be explained most clearly through painter's logic: when a painter paints a wall, they must paint it with equal, or even similar, brushstrokes in opposite directions so that the paint is applied evenly and is balanced, or rather, of high quality. This same logic applies to price. When a bullish candle expands and breaks through a price point, for example, from 1.3010 to 1.3030, a bearish candle must also break through that price point to balance the price, and if it doesn't, it becomes an imbalance. Often, if not always, the price will return to this point eventually. This may occur in any timeframe.

2.Market Structure Shifts
This refers to a particular phenomenon in the price action and trading where price, which was initially moving towards a particular direction, for example, bullish, and making new higher lows and new higher highs, suddenly shifts from the bullish structure being created to a new bearish structure where price breaks the most recent higher low with power and speed and begins pushing lower and lower, now creating lower lows and lower highs. For a market structure to be valid, there must be that break and shift in price action structure with speed and power.
Also, for market structure shifts to be high probability and not false structure shifts/Judas swings/liquidity grabs, price must come from high-interest points, which we often refer to as liquidity. Market structure shifts that occur after liquidity grabs are very high probability in terms of success. Furthermore, this phenomenon occurs in any time frame from M1 to MN.

3.PD Arrays
PD Arrays in full simply stands for premium and discount array; basically, all this tries to do or function in the market is just use a simple logic in reading price. This can be explained in the way that in real business world terms, where businessmen or women or even shoppers would always prefer to buy items at a cheap discount and sell at a high premium, this same phenomenon can be applied to price in trading: traders should always buy at a cheap discount and sell only in premium markets. Because selling at a discount and buying at a premium would guarantee losses.
PD arrays in trading can easily help identify ideal places to execute trades and where to avoid the typical form of long price legs, trends, and price swings, or rather expansion moves, meaning after an explosive expansion, one can measure it and find the equilibrium point and hence divide it and classify it as premium and discount.

4.Fractal Structure
Fractal structure refers to how price forms similar patterns across different time frames of the same pair; that is why it is commonly mentioned that price is fractal in nature, meaning a setup occurring in a higher time frame can be easily traced and tracked to the lower time frame for validation and execution. As well, if a pattern or setup only occurs in one time frame, probably it is not ideal or accurate.
It can be used to track trade setups from HTF to LTF and also reduce risk exposure on trades as one goes more into the lower time frame.
5.OTE
This is referred to as the optimal trade entry, which essentially means executing trades at optimal entry points in price. The thing is, OTE is just PD arrays on steroids in that it allows one to execute trades at discount or premium points, which are optimal trade entry points depending on where price is at the moment. This is a very effective tool that can be used in both the higher timeframe and the lower timeframe. It can offer trade entry points for immediately short-term trades, especially after an expansion and market structure shift, and it can help one determine if price is discounted or premium in a long trend or after a price swing in the higher timeframe.
The sweet spot for optimal trade entries is usually at 62% to around 70% on the Fibonacci scale levels. Basically, optimal trade entry can be used in the short term and in lower time frames. A lower time setup is used to offer premium or discount prices immediately before a price move.

Introspection of How PD Arrays and Imbalances Can Be Used Effectively
One of the most important first steps to effectively use this concept is determining trend direction and narrative, which this article aims to address. This is a very major step for the success of this concept, as it gives us a basis and beginning point for how to navigate and determine the narrative in play. In short, this whole concept cannot work without determining the trend or narrative in play, as this gives us a clear view of what price is trying to achieve.
With this article and EA, it will help align the trades executed in the correct PD arrays relative to the trend, hence avoiding short-term trades against the trend or buying at a premium and selling at a discount. This will help developing traders to be more confident and discerning when executing trades, as they will eventually learn and grasp how to only execute trades at the optimal trade entry where probability of success is high and relative to the trend and narrative in play. And once this challenge of determining trend and narrative direction is solved, all that is left now is finding the correct setup in the correct PD array presented.
The need for a trader to make profitable and excellent decisions in trading, especially intraday and long-term trades, is largely dependent on how one positions oneself relative to the trend direction, strength, and PD array. Statistically, it is often proven time and again that trading against the trend often offers short-term price movements, which are mostly retracements just before a big move in the direction of the trend, and if one is not careful, he might find himself with very heavy losses, and if one does not cut his/her losses early, they may end up blowing the account since trending markets may push price for days if not weeks.
Yet executions relative to trend strength and direction often prove more forgiving even if one has poor trade entry positions and at times can result in extra hundreds of dollars, if not thousands, made in profits if the trader is patient enough to wait for the overall trend to continue from reversals, liquidity grabs, and discounted prices.
Also, trades analyzed, executed, traded, and tracked regarding the trend direction and PD arrays have proven not only to be more accurate and faster but also to have very little drawdown as price moves quickly towards its target points with more speed and less drawdown. Besides, price swings are more powerful, meaning even if one is in drawdown, price will soon trade according to the trend's direction and strength narrative in play and will come out of drawdown.
And the best way the narrative, trend, and PD arrays are determined is by using the higher timeframes, mainly W1 and D1, and inspecting them clearly. The first step the EA takes, which can also be done manually, is by using simple and exponential moving averages to at least help give a clear picture if market is trending or consolidated. Trending markets offer far safer and better quality trading opportunities. Trending markets are identified when the 9-period simple moving average is either below or above the 21-period moving average and is in a clear rising or falling pattern and stacking. The second important thing is to investigate the price action on this two higher timeframes and determine where it is heading. With these steps, this is how the trend is easily determined as either bullish or bearish.
Now after a trend has been identified and it has also been determined that the price is not in consolidation, the next step is to identify the narrative in play or simply what the price is trying to reach for or achieve. Price is always reaching for three points: either liquidity, PD arrays, or imbalances, and it also trades mostly one liquidity point to another. Here on the higher timeframes, the EA quickly identifies large price swings and expansion moves that are visible and quickly divides this price legs into a discount and premium level, the higher side being the premium level, and the lower side being the discount, and that is how easily PD arrays are identified and created. And now trading decisions are made with the premise that we sell at the premiums and buy at the discounts. This helps determine the long-term state of the price in a higher timeframe, whether it's discounted or premium. The same method and premise can be used to execute in the lower time frames.
That is how this EA traces, anticipates, and trades from the respective PD arrays, and now, for the imbalances found in the PD arrays, it is common knowledge and, according to the ICT model, how one can leverage and utilize imbalances to enter and execute trades. Once we have found our expansion or price leg and divided it into PD arrays, now the second part of the equation is to look for an imbalance from the PD array we expect to trade from. As long as it supports trend and narrative, it can be a compelling tool for trade setups. This imbalance can be further broken down into lower time frames for a more accurate, detailed, and reduced risk exposure than the higher time frame. This is made possible by the fractal nature of price.
So, in short the EA will identify the whole scenario as it occurs, evaluate and determine PD arrays according to trend and narrative, and look out for the imbalances in the respective PD array and try to execute trades of imbalances found there. Once it determines the PD array, it helps reduce the possibility of oversold or overbought situations.
Automating trading decisions with the PD Arrays expert advisor in MQL5
To automate, illustrate, and implement this strategy, I have created:
- A PD arrays expert advisor to analyze trends, PD arrays, and execute possible trade entry points only in the direction of the trend and narrative in the correct PD array presented, incorporating trailing stop loss and moving averages to aid in trend detection.
Decision-making process
This expert advisor’s decisions (trend detection, PD arrays detection, imbalance detection, price action detection, and trade execution) are driven by the following logic:
Source code of the PD array expert advisor:
This expert advisor detects potential trade signals that align with the overall trend direction and narrative and waits for trade setups occurring only from imbalances in respective PD arrays depending on where price is currently relative to past expansions and movements, avoiding positions opposite to the trend or without a correct PD array in use. It also utilizes exponential and simple moving averages to get the general trend direction to make trade entries and applies a trailing stop-loss logic to determine stop-loss levels and protect capital when price moves in its favor. It includes risk management (1% risk per trade).
Input Parameters: Configurable Trading Settings
These 'input' declarations expose tunable variables in MetaTrader's EA properties dialog, empowering users to adapt the strategy to gold's evolving dynamics without recoding. 'LotSize = 0.01' defaults to a micro-lot, equating to ~$0.10 per point on XM standard accounts, ideal for risk-averse scalping in gold's amplified moves; edge cases include account types with different contract sizes (e.g., micro accounts where 0.01=1 micro-lot), requiring users to verify via SymbolInfoDouble() externally to avoid under/over-sizing.
'RR = 1.3' sets a modest risk-reward, psychologically favoring frequent small wins to build trader confidence, countering gold's drawdown-prone nature where over-ambitious RRs (e.g., 3:1) often hit SLs amid whipsaws. 'MaxTradesPerDay = 3' enforces discipline, preventing revenge trading post-losses—a common psychological trap in gold's emotional volatility. Directional toggles like 'TradeLong=true' and 'TradeShort=false' reflect backtested biases; gold's safe-haven psychology often sees stronger reversals from swept lows (bullish traps on the downside), disabling shorts by default to avoid counter-trend fights against upward drifts.
'MinBodyPercent=0.6' demands directional conviction (body >= 60% range), filtering psychological fakes like pinbars without follow-through; edge cases: weekend gaps creating oversized candles, potentially triggering if not session-filtered. 'MinRangePoints=0.0' (disabled) allows ignoring tiny ranges in quiet hours, but when enabled (e.g., 10), it skips nano-moves in Asia, psychologically focusing on "strong displacement" candles that signal institutional intent over retail noise.
Session inputs hardcode GMT+2 timings: Asia (0-7) for range-building amid low-volume consolidation (psychological accumulation phase), London (9-12) for Euro-open liquidity surges, and NY (15-18) for US-driven momentum. Psychologically, this exploits session transitions where Asia ranges trap overnight positions, swept by fresh capital inflows—classic smart-money manipulation. Edge cases: DST shifts altering hours (users must adjust) or broker time mismatches causing off-session trades. This configurability psychologically empowers traders, turning the EA into a personalized tool against market manipulation.
//+-----------------------------------------------------------------------------------------+ //| PD Arrays Detector EA.mq5 – XM GMT+2 | //| Expert Advisor for MetaTrader 5 | //| Description: Trades based on PD Arrays and imbalances utilizing | //| premium and discount arrays. | //+-----------------------------------------------------------------------------------------+ #property copyright "EUGENE MMENE" #property link "HTTPS://WWW.EMCAPITAL.COM" #property version "7.11" #include <Trade/Trade.mqh> CTrade trade; //+--------------------------------------------------------------------------------+ //| Inputs | //+--------------------------------------------------------------------------------+ input double LotSize = 0.01; input double RR = 1.3; input int MaxTradesPerDay = 3; input bool TradeLong = true; //--- Enable long trades (SweepLow) input bool TradeShort = false; //--- Enable short trades (SweepHigh) - disabled by default for better performance input double MinBodyPercent = 0.6; //--- Minimum body percent for strong displacement input double MinRangePoints = 0.0; //--- Minimum candle range in points to filter small ranges (0 to disable) //--- XM GMT+2 sessions input int AsiaStart = 0; input int AsiaEnd = 7; input int LondonStart = 9; input int LondonEnd = 12; input int NYStart = 15; input int NYEnd = 18;
Persistent Global State Variables
These globals sustain the EA's memory across ticks, crucial for tracking gold's session psychology without database overhead. 'asiaHigh=0' and 'asiaLow=0' initialize to unset, updating to Asia's extrema—representing psychological support/resistance where retail stops cluster during quiet hours, ripe for institutional sweeps. Edge cases: flat Asia sessions (high=low), potentially disabling trades if not handled (here, the ready flag requires >0, skipping invalid ranges).
'asiaRangeReady=false' gates trading until post-Asia, psychologically ensuring sweeps are contextualized against established liquidity pools. 'tradesToday=0' and 'currentDay=0' manage daily resets; psychology: limits curb overconfidence after wins, preventing blowups in gold's streak-prone runs. Edge cases: server time jumps (e.g., VPS restarts) missing day changes, though TimeCurrent() reliability mitigates.
The 'Price[]' array holds recent MqlRates (OHLC, time, volume), set as a series for intuitive indexing. Psychologically, this enables precise sweep detection, capturing "engineered" moves where wicks probe ranges to induce FOMO, then reverse—exploiting herd mentality. Minimal globals promote speed, vital in gold's tick floods; edge cases: array overflows on long histories (here, limited to 5 bars) or data holes from disconnections, handled by CopyRates checks.
double asiaHigh =0.0; double asiaLow =0.0; bool asiaRangeReady =false; int tradesToday =0; int currentDay =0; MqlRates Price[];
OnInit—One-time EA Startup Routine
Triggered on EA attachment or recompilation, this initializes basics for gold scalping. 'ArraySetAsSeries(Price,true);' orients the array chronologically (0=current), standard for MQL4 to ease bar analysis—psychologically aligning code with trader intuition (recent data first). Edge cases: failure on non-array variables or MQL5 migration needing ArraySetAsSeries false for ascending.
Returning 'INIT_SUCCEEDED' signals readiness; psychology: quick startup builds trust, avoiding delays in volatile gold. Minimal here to focus resources on runtime, but edge: no input validation means users must ensure symbol= XAUUSD timeframe suits (e.g., M5-M15 for scalps).
//+-------------------------------------------------------------------------------+ //| Expert Initialization function | //+-------------------------------------------------------------------------------+ int OnInit() { ArraySetAsSeries(Price,true); return(INIT_SUCCEEDED); }
OnTick—Main Logic Loop (runs on every price tick)
OnTick fires per tick but gates via 'if(!IsNewBar()) return;', converting to bar-based for efficiency in gold's 1000s-ticks/minute. Psychologically, this mirrors discretionary trading: act on closed candles to avoid intra-bar illusions. Steps: fetch time struct for .day/.hour access; reset daily if needed; copy 5 bars (edge: <5 on new charts skips, self-correcting).
Build range, then guards: no ready range (psych: no liquidity context); wrong session (psych: avoid low-vol traps); open position (psych: one idea at a time, risk control); max trades (psych: prevent tilt). If pass, check entry. Edge cases: tick floods overwhelming CPU (guards minimize); time desyncs (e.g., broker maintenance) via TimeCurrent(). Layered logic psychologically enforces patience, capturing only high-conviction sweeps amid gold's manipulative psychology.
//+----------------------------------------------------------------------------------------+ //| OnTick | //+----------------------------------------------------------------------------------------+ void OnTick() { if(!IsNewBar()) return; MqlDateTime t; TimeToStruct(TimeCurrent(),t); ResetDaily(t); if(CopyRates(_Symbol,_Period,0,5,Price)<5) return; BuildAsiaRange(t); if(!asiaRangeReady) return; if(!InTradingSession(t)) return; if(PositionSelect(_Symbol)) return; if(tradesToday >= MaxTradesPerDay) return; CheckForSweepEntry(); }
ResetDaily—New Trading Day Initialization
Compares 't.day' to stored; if new, resets all. Psychologically, it treats each day as isolated, countering recency bias in gold's trendless overnights. Edge cases: month/year rollovers (handled by .day); VPS time drifts (rely on broker server). Ensures fresh psychology: new Asia range for daily liquidity narrative.
//+----------------------------------------------------------------------------------+ //| Reset daily values when the day changes | //+----------------------------------------------------------------------------------+ void ResetDaily(MqlDateTime &t) { if(t.day != currentDay) { currentDay = t.day; tradesToday = 0.0; asiaHigh = 0.0; asiaLow = 0.0; asiaRangeReady = false; } }
BuildAsiaRange—Constructing the Reference Liquidity Zone
In Asia hours, updates extrema from closed bar (Price[1]), accumulating session highs/lows—psych: quiet period where ranges form "traps" for later sweeps. Post-Asia, flags ready if set. Edge cases: no updates (flat market, ready=false); gaps skipping bars (uses available). Psychologically, it captures consolidation psychology for exploitation in active sessions.
void BuildAsiaRange(MqlDateTime & t)
{
if(t.hour >= AsiaStart && t.hour <= AsiaEnd)
{
if(asiaHigh == 0 || Price[1].high > asiaHigh)
asiaHigh = Price[1].high;
if(asiaLow == 0 || Price[1].low < asiaLow)
asiaLow = Price[1].low;
}
if(t.hour > AsiaEnd && asiaHigh > 0 && asiaLow > 0)
asiaRangeReady = true;
} InTradingSession—Time Window Filter
Checks for London/NY hours, enforcing high liquidity only. Psych: Sweeps thrive on volume; Asia avoids ranging boredom. Edge cases: hour=8 (transitional, false); DST (manual adjust). Aligns with institutional psychology: capital flows trigger reversals.
bool InTradingSession(MqlDateTime & t) { if((t.hour >= LondonStart && t.hour <= LondonEnd) || (t.hour >= NYStart && t.hour <= NYEnd)) return (true); return (false); }
CheckForSweepEntry—Core Signal Detection & Order Execution
Filters prior candle: body/range calc, skip zero range (edge: flat tick), small ranges (psych: ignore noise). Body percent ensures conviction (psych: strong close signals commitment over wicks).
Short: wick over Asia, high but close under—psych: fake breakout traps bulls, institutions reverse. Entry midpoint (psych: 50% retrace catches fade), SL high (beyond liquidity), TP via RR. Edge: close=high (no wick, skips); disabled TradeShort avoids bias.
Long: mirror, psych: downside trap for bears, bullish recovery. Return after short prevents rare dual signals. Overall, exploits sweep psychology: liquidity engineering, where extrema probe induces wrong-sided entries, then reverse—deep in gold's manipulation lore. Edge: gaps (e.g., news) creating invalid closes, but bar-based mitigates; RR scaling ensures asymmetric reward in mean reversion.
//+-----------------------------------------------------------------------------------------------+ //| Checks conditions for liquidity sweep entries | //+-----------------------------------------------------------------------------------------------+ void CheckForSweepEntry() { double body = MathAbs(Price[1].close - Price[1].open); double range = Price[1].high - Price[1].low; if(range == 0 || (MinRangePoints > 0 && range < MinRangePoints * _Point)) return; double bodyPercent = body / range; if(bodyPercent < MinBodyPercent) return; //---Bearish Liquidity Sweep (Short Setup) | if(Price[1].high > asiaHigh && Price[1].close < asiaHigh && TradeShort) { double entry = (Price[1].high + Price[1].low)/2.0; double sl = Price[1].high; double risk = sl - entry; double tp = entry - (risk * RR); if(trade.Sell(LotSize,_Symbol,entry,sl,tp,"SweepShort")) { tradesToday++; return; //--- avoid checking long on same bar } } //--- Bullish Liquidity Sweep (Long Setup) | if(Price[1].low < asiaLow && Price[1].close > asiaLow && TradeLong) { double entry = (Price[1].high + Price[1].low)/2.0; double sl = Price[1].low; double risk = entry - sl; double tp = entry + (risk * RR); if(trade.Buy(LotSize,_Symbol,entry,sl,tp,"SweepLong")) tradesToday++; } }
IsNewBar—New Candle Detector
Static lastBar persists; copies current bar, compares time. Psych: ensures completed data, avoiding mid-bar psychology traps. Edge: data lags (false negative, next tick corrects); weekend opens (large time jump, detects). Standard for volatility like gold.
bool IsNewBar() { static datetime lastBar=0; MqlRates tmp[]; ArraySetAsSeries(tmp,true); if(CopyRates(_Symbol,_Period,0,1,tmp)!= 1) return (false); if(tmp[0].time != lastBar) { lastBar = tmp[0].time; return (true); } return (false); }
Strategy testing
Strategy testing on the PD Arrays EA:
The strategy works best on gold mostly, because of its core logic, quick adaptability to gold's fast movements, rapid swings, trend trading, and narrative following. It uses an imbalance and PD array concept for trade setups and high volatility, which are beneficial and essential for most trading strategies. We will test this strategy by trading GOLD from January 1, 2025, to February 15, 2026, on the 60-minute (H1) timeframe. Here are the parameters I have chosen for this strategy.
GOLD


Strategy tester results
Upon testing on the strategy tester, here are the results of how it works, analyzes, and Performs.
Strategy tester results on PD Arrays EA:
Balance/Equity graph:
GOLD

Backtest results:
GOLD 
Summary
I wrote this article to try to explain a MetaTrader 5 Expert Advisor that is specifically tailored for trend following, finding, determining and evaluating PD arrays, and imbalances before utilizing and optimizing whichever trading set ups it finds, and also incorporates trade and risk management techniques to systematically reduce risk, exposure, and human errors while identifying and executing high-probability trading setups on GOLD and also possible exit points using the same trade and risk management protocol.
This Expert Advisor is one of the most simple and yet powerful trading Expert Advisors, utilizing trends, imbalance concepts, and PD arrays used to capture possible trade price entries and trend shifts. The robust and well-adaptive risk and trade management logic helps the Expert Advisor perform at an optimum level and minimize drawdown and trading losses.
I tested the Expert Advisor on GOLD, and it revealed its ability to detect possible trade entries efficiently and aptly on any time frame, but the trade entry point detection is only part of the equation because it has an optimum entry validation strategy built into the core logic that allows execution only if certain criteria are met. As soon as the trades are validated and executed, then the trade and risk management logic is quickly implemented to ensure proper execution until the trade is closed.
To implement this Expert Advisor strategy, configure the input parameters on the Expert Advisor as shown below to get desirable results. The Expert Advisor is designed to scan for PD arrays, imbalances, and possible trade entries on the set timeframe a trader selects to view, from M15 to D1, ensuring the possible trade entry points align with the trend and moving averages and the average true range for trailing stop-loss. Interested traders should back-test this Expert Advisor on their demo accounts with GOLD; it works optimally well and is designed for GOLD but may also be applied to GBPUSD, EURUSD, and GBPJPY.
The main agenda and goal for this Expert Advisor were to optimize it for strictly trading using imbalances found on respective PD arrays and narrative-following trading with advanced trade logic and for high-probability setups that occur in any time frame, for depending on a trader's choice, and also incorporate risk management with the implemented trailing stops.
I would also advise traders to regularly review performance logs and metrics to refine settings and input parameters depending on one's goals, asset class or risk appetite. Disclaimer: Anybody using this Expert Advisor should first test and start trading on his demo account to master this imbalances and PD arrays concept and trading idea approach for consistent profits before risking live funds.
Conclusion
The article highlights the main challenges traders face in correctly determining narratives in play, PD arrays, imbalances, and trade entry; risk management; trade management; and avoiding drawdowns—and explains how to design an Expert Advisor that simplifies and integrates this process and increases the chances of being profitable by executing only high-probability trades. The article further elaborates how trading using the correct PD arrays in price imbalances and following the narrative in play and ignoring countertrend trade ideas and setups greatly aids in this.
Many traders lack a clear understanding of how to use imbalances and PD array concepts effectively in trading, which can really have a major positive impact on their performance, especially when combined with proper risk and trade management; it becomes a very major game changer that separates the average from the very best. The proposed Expert Advisor helps enforce discipline and allows traders to validate their trade ideas, position sizing, and setups even if they don’t use its entries directly.
The automated MQL5 Expert Advisor provides:
- high probability trades from the set ups arising from imbalances found in current PD arrays of the asset being traded;
- protection from news volatility by blocking trades around news releases;
- trade entries only on confirmed signals and validated entry logic with dynamic SL/TP;
- adaptive risk management (reducing lot size during losing streaks, increasing during winning streaks);
- logging of results for record keeping and ongoing strategy optimization;
- strict adherence to first identifying narrative in play and also determine where price is in the current PD array before hunting for imbalances ;
- removal of emotional decision-making, impulsive trading, risky trading practices ;
- automated trade management (SL, TP, partial closes).
Together, these features deliver consistent execution of high-probability trades and optimal risk management, increasing the chance of profitable trading and improving performance for traders.
All code referenced in the article is attached below. The following table describes all the source code files that accompany the article.
| File Name | Description: |
|---|---|
| PD Arrays EA.mq5 | File containing the full source code for the PD array EA |
Warning: All rights to these materials are reserved by MetaQuotes Ltd. Copying or reprinting of these materials in whole or in part is prohibited.
This article was written by a user of the site and reflects their personal views. MetaQuotes Ltd is not responsible for the accuracy of the information presented, nor for any consequences resulting from the use of the solutions, strategies or recommendations described.
Features of Custom Indicators Creation
Package-based approach with KnitPkg for MQL5 development
Features of Experts Advisors
MQL5 Trading Tools (Part 22): Graphing the Histogram and Probability Mass Function (PMF) of the Binomial Distribution
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use