
Code a fair value gap/imbalance strategy in MQL5, trading a three-candlestick gap pattern on the 15-minute chart with a 15-pip minimum, and exit via partial take profits and break-even averaging.
Configure an mql5 expert advisor template with on initialization and on tick routines, set trading symbol and period, define magic and slippage, and adjust chart appearance.
Refine onTick logic to run code only on new bars, using an old number of paths and a new bar check to boost speed and memory efficiency.
Extract price values from closed candlesticks (high, low, open, close) and bid/ask, initialize symbol point and digits, and reverse data arrays for on-tick updates.
Create a function to draw two lines representing the high and low of a fair value gap, using previous candlesticks to visualize the imbalance on the chart.
Detect bullish and bearish fair value gaps by computing a minimum imbalance size and gap sizes, then draw indicators when gaps qualify and return a boolean imbalance signal.
Test the imbalance code by running a strategy tester on the fair value gap. Validate bullish imbalances of the right size and adjust the detection threshold.
Count the number of trades per signal using the trade class, then initialize trade objects, set maximum slippage in points and the magic number, and compute total trades by type.
Calculate trade risk by deriving loss size from a balance-based volume increase, then initialize lot max, min, and step from symbol info to bound and round the lot size.
Declare and initialize trading variables for an MQL5 fair value gap strategy, including trade distance, price calculations, next buy/sell prices and lots, tp multipliers, and modification flags.
In this lesson, code the pi function to execute a buy order at the ask price, using fair value gap size and four take profit levels with dynamic lot sizing.
Learn to code the cell function within the pi function, validating a sell signal, sizing the sell lot with normalization and rounding, and setting four take-profit levels.
Develop a modify positions function that iterates open positions, filters by symbol and position type, applies a new stop loss, partially closes by a volume decrease, and preserves take profit.
Develop a manage trades function in MQL5 to adjust stop losses and modify buy and sell positions as prices reach take-profit levels, including handling cost averaging trades.
Calculate the average buy and sell entry prices to determine break-even levels, using a counted loop over positions, summing opening prices, and returning a normalized average for cost averaging decisions.
Code a cost averaging module in mql5 that enters buy or sell on bullish or bearish imbalances and fair value gaps, then auto-adjusts positions and take profits.
Test the MQL5 imbalance strategy by running the EA through two years of data, confirm profit growth, manage drawdown under 22%, and evaluate metrics like profit factor, Sharpe, and recovery.
wraps up the course by highlighting the value of fair value gaps and trade management techniques, and emphasizes that algorithmic tools require a capable, informed trader to succeed.
Price and Candlestick Patterns are the building blocks of quality technical analysis and price action. They are relatively easy to remember which makes them ideal for trade planning and system development.
In this course, we shall delve into one of the most popular trend continuation price action patterns, the Fair Value Gap pattern. We shall explore what this pattern entails and how effectively we can trade it.
Fair value gaps are price jumps caused by imbalanced buying and selling pressures. These gaps are sometimes called imbalance. These Imbalance patterns indicate a market situation were the supply of buyers is significantly higher than the demand of sellers. This can cause the price of an instrument to move quickly towards higher supply or lower demand. The fair value gap then shows the point on the chart where this rapid price movement occurred. FVGs can be seen on charts as large candles that are not completely covered by wicks of adjacent candles. The FVG formation consists of three candles and there are bullish and bearish FVGs.
In this course, we shall code a strategy that uses Fair Value Gaps or Imbalance as its entry logic. We shall use ingenious trade management methods that maximizes profits by using partial close trade management and we shall cost average losing trades without using martingale to exit losing trades at Breakeven, allowing the trading account to grow without giving away gained profits. We shall code our expert advisor from scratch by programming it using the MQL5 language.
For those that are still finding their way with MQL5, as long as you understand the basics of MQL5, this course is well tailored for you. We will patiently guide you through the process of strategy development and walk you through every line of code we shall craft. Hopefully by the end of this course, you will have gained the necessary skills to code similar trading strategies and be able to appreciate the effectiveness of the traded pattern and the trade management protocols the strategy uses.
So hit hard on that enroll button now and join me in this incredible journey of coding a fair value gap trading strategy.