Skip to content
← Back to the research library
MQL5 SOURCE COLLECTION / Mean Reversion

Asian Session Drop

A long-only dip-buying experiment that enters after a percentage decline from the previous daily close.

MT5 / MQL5Original sourceSource issue noted

Previous daily close / tick entries · Published 28 October 2026

Source inspectionLimited static review
MetaEditor compilationNot performed
Backtest / live recordNot supplied

How the source is structured

  1. Read the previous daily close and calculate a buy threshold below it.
  2. Buy when the bid reaches that threshold, subject to an in-memory daily trade limit.
  3. Set point-based stop and target levels; the source also contains a trailing-stop routine.

Default inputs

As supplied; these are not optimized or recommended settings.
Drop from previous close2%
Fixed volume0.1 lot
Stop / target100 / 200 points
Daily entry limit1
Trailing activation / distance100 / 50 points
BEFORE YOU TEST

Source-review notes

These observations come from reading this uploaded version. They are not compiler output or a complete code audit. The download retains the source as supplied.

SOURCE LINES 127–129, 178–179

The daily-limit early return occurs before trailing-stop management. With the default one-trade limit, later ticks skip that routine after an entry.

SOURCE LINES 84–112, 117–181

Despite the filename, there is no Asian-session time filter. Position management has no magic-number isolation; the position loop repeatedly selects the chart symbol.

SOURCE LINES 22–23, 120–123

The daily counter is memory-only and resets when the EA is restarted.

Dependencies

MetaTrader 5 standard Trade library. No custom indicator referenced.

Source & attribution

No author or license declaration appears in the supplied source.

Included in the Edge Quant source collection with existing notices preserved. Free download does not imply a new license grant.

Original filename: Assian Session Drop.mq5
Encoding: UTF-8

Inspect the original source

The browser preview is decoded for reading; the download keeps the original file bytes.

Direct .mq5 file ↓
Expand full MQL5 source · 189 lines
#include <Trade\Trade.mqh>   // Include CTrade classCTrade trade;  // Create an instance of the CTrade class//+------------------------------------------------------------------+//| Input Variables                                                  |//+------------------------------------------------------------------+enum LotMode { LOT_FIXED, LOT_MONEY }; // Lot size modesinput LotMode InpLotMode = LOT_FIXED;  // Mode for calculating lot sizeinput double InpLots = 0.1;            // Fixed lot size or risk percentageinput double DropPercent = 2.0;        // Percentage drop from the previous day's closeinput int    StopLossPoints = 100;     // Stop loss in pointsinput int    TakeProfitPoints = 200;   // Take profit in pointsinput int    MaxTradesPerDay = 1;      // Maximum trades per dayinput bool   EnableTrailingStop = true; // Enable or disable trailing stop lossinput int    TrailingStopPoints = 50;  // Trailing stop distance in pointsinput int    TrailingStopActivationPoints = 100; // Profit threshold for trailing stop activation//+------------------------------------------------------------------+//| Global Variables                                                 |//+------------------------------------------------------------------+datetime lastTradeDay = 0;             // Tracks the last day a trade was madeint dailyTradeCount = 0;               // Tracks the number of trades made today//+------------------------------------------------------------------+//| Get Previous Day's Close Price                                   |//+------------------------------------------------------------------+double GetPreviousDayClose(){    return iClose(_Symbol, PERIOD_D1, 1); // Close price of the previous day (index 1)}//+------------------------------------------------------------------+//| Calculate Lot Size Based on Mode and Risk Parameters             |//+------------------------------------------------------------------+bool CalculateLots(double slDistance, double &lots) {    lots = 0.0;    if (InpLotMode == LOT_FIXED) {        // Use fixed lot size        lots = InpLots;    } else {        // Use dynamic lot size based on risk        double tickSize = SymbolInfoDouble(_Symbol, SYMBOL_TRADE_TICK_SIZE);        double tickValue = SymbolInfoDouble(_Symbol, SYMBOL_TRADE_TICK_VALUE);        double volumeStep = SymbolInfoDouble(_Symbol, SYMBOL_VOLUME_STEP);        double riskMoney = InpLotMode == LOT_MONEY                          ? InpLots                          : AccountInfoDouble(ACCOUNT_EQUITY) * InpLots * 0.01;        double moneyVolumeStep = (slDistance / tickSize) * tickValue * volumeStep;        lots = MathFloor(riskMoney / moneyVolumeStep) * volumeStep;    }    // Validate the calculated lots    return CheckLots(lots);}//+------------------------------------------------------------------+//| Validate Lot Size for Min, Max, and Step                         |//+------------------------------------------------------------------+bool CheckLots(double &lots) {    double min = SymbolInfoDouble(_Symbol, SYMBOL_VOLUME_MIN);    double max = SymbolInfoDouble(_Symbol, SYMBOL_VOLUME_MAX);    double step = SymbolInfoDouble(_Symbol, SYMBOL_VOLUME_STEP);    if (lots < min) {        Print("Lot size is below the minimum allowable volume. Adjusting to minimum.");        lots = min;        return true;    }    if (lots > max) {        Print("Lot size exceeds maximum allowable volume. Lots: ", lots, ", Max: ", max);        return false;    }    lots = MathFloor(lots / step) * step; // Adjust to nearest valid step    return true;}//+------------------------------------------------------------------+//| Trailing Stop Logic                                              |//+------------------------------------------------------------------+void UpdateTrailingStop(){    int totalPositions = PositionsTotal();    for (int i = 0; i < totalPositions; i++) {        if (PositionSelect(_Symbol)) {            // Check if the position is a BUY            if (PositionGetInteger(POSITION_TYPE) == POSITION_TYPE_BUY) {                double openPrice = PositionGetDouble(POSITION_PRICE_OPEN);                double currentPrice = SymbolInfoDouble(_Symbol, SYMBOL_BID);                double profitPoints = (currentPrice - openPrice) / _Point;                // Only activate trailing stop after the profit threshold is reached                if (EnableTrailingStop && profitPoints >= TrailingStopActivationPoints) {                    double currentSL = PositionGetDouble(POSITION_SL);                    double newSL = currentPrice - TrailingStopPoints * _Point;                    // Update SL if the new SL is higher than the current SL                    if (newSL > currentSL) {                        if (!trade.PositionModify(_Symbol, newSL, PositionGetDouble(POSITION_TP))) {                            Print("Error updating trailing stop: ", GetLastError());                        } else {                            PrintFormat("Trailing Stop Updated: %.5f (Profit Points: %.2f)", newSL, profitPoints);                        }                    }                }            }        }    }}//+------------------------------------------------------------------+//| Expert Tick Function                                             |//+------------------------------------------------------------------+void OnTick(){    // Reset trade count if a new day has started    datetime currentDay = iTime(_Symbol, PERIOD_D1, 0);    if (currentDay != lastTradeDay) {        lastTradeDay = currentDay;        dailyTradeCount = 0;    }    // Check if the daily trade limit has been reached    if (dailyTradeCount >= MaxTradesPerDay) {        Print("Daily trade limit reached: ", dailyTradeCount, " trades.");        return;    }    // Get the previous day's close price    double previousClose = GetPreviousDayClose();    if (previousClose <= 0) {        Print("Error: Invalid previous day's close.");        return;    }    // Calculate the buy level    double buyLevel = previousClose * (1.0 - DropPercent / 100.0);    // Get the current bid price    double currentPrice = SymbolInfoDouble(_Symbol, SYMBOL_BID);    if (currentPrice <= 0) {        Print("Error: Invalid current price.");        return;    }    // Check if the current price is below the buy level    if (currentPrice <= buyLevel) {        double slDistance = StopLossPoints * _Point; // Stop loss distance in points        double lots = 0.0;        // Calculate lot size        if (!CalculateLots(slDistance, lots) || lots <= 0) {            Print("Error: Lot size calculation failed.");            return;        }        double sl = currentPrice - slDistance;       // Stop loss price        double tp = currentPrice + TakeProfitPoints * _Point; // Take profit price        // Debugging: Print trade details        PrintFormat("Placing Buy Order - Buy Level: %.5f, Current Price: %.5f, SL: %.5f, TP: %.5f, Lots: %.2f",                    buyLevel, currentPrice, sl, tp, lots);        // Place the trade        if (trade.Buy(lots, _Symbol, currentPrice, sl, tp)) {            dailyTradeCount++; // Increment trade count            Print("Buy order placed successfully. Total trades today: ", dailyTradeCount);        } else {            int error = GetLastError();            PrintFormat("Failed to place buy order. Error: %d", error);        }    }    // Update trailing stop if enabled    if (EnableTrailingStop) {        UpdateTrailingStop();    }}//+------------------------------------------------------------------+//| Expert Deinitialization Function                                 |//+------------------------------------------------------------------+void OnDeinit(const int reason){    Print("EA deinitialized.");}

SHA-256: 264f1199df55b14c2184c3b4a3ee6c71483ab7f7301f4e228b1053435e2aadb4

Educational source material, not investment advice. No profitability, execution quality or live-readiness claim is made for this upload.