Skip to content
← Back to the research library
MQL5 SOURCE COLLECTION / Session & Calendar

Reversal Tuesday

A calendar-based long setup entered below a daily moving average, with a next-day timed exit.

MT5 / MQL5Original sourceSource issue noted

Monday-to-Tuesday / D1 SMA · Published 28 October 2026

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

How the source is structured

  1. After Monday 22:55 server time, check whether bid is below the daily SMA.
  2. Calculate a volume from account balance, symbol price and tick properties, then attempt a long with a percentage stop.
  3. Attempt to close the stored ticket after Tuesday 22:55.

Default inputs

As supplied; these are not optimized or recommended settings.
Open / closeMonday 22:55 / Tuesday 22:55
MA filterD1 / SMA 20
RiskPercent input100 (see sizing note)
Stop5%
Evaluation periodM1
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 84–92

The sizing formula divides by the full entry-price value, not the stop distance. RiskPercent=100 is not a conventional 100%-at-stop risk calculation; sizing needs explicit review.

SOURCE LINES 17, 78–79

IsMafilter is declared but not used to switch the filter off. The price-versus-MA condition is always applied.

SOURCE LINES 27, 69–74, 94–95

The ticket used for the timed close exists only in memory and is not recovered after a restart.

Dependencies

Built-in moving average; MetaTrader 5 standard Trade library.

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: Reversal Tuesday.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 · 101 lines
#include <Trade/Trade.mqh>//input variables that can be changed by the userinput int DigitsAfterDecimalPoint = 1;input ENUM_TIMEFRAMES Timeframe = PERIOD_M1;input double RiskPercent = 100;input double SlPercent = 5;input int DayOpen = 1;input int TimeOpenHour = 22;input int TimeOpenMin = 55;input int DayClose = 2;input int TimeCloseHour = 22;input int TimeCloseMin = 55;input bool IsMafilter = true;input ENUM_TIMEFRAMES MaTimeframe = PERIOD_D1;input int MaPeriods = 20;input ENUM_MA_METHOD MaMethod = MODE_SMA;input ENUM_APPLIED_PRICE MaAppPrice = PRICE_CLOSE;//global variables that can be used in every functionint barsTotal;int lastDay;int handleMa;ulong posTicket;CTrade trade;int OnInit(){   //create a handle for the moving average indicator   //a handle is a description for a specific indicator   handleMa = iMA(_Symbol,MaTimeframe,MaPeriods,0,MaMethod,MaAppPrice);      return(INIT_SUCCEEDED);}void OnDeinit(const int reason){}void OnTick(){//check for a new bar   int bars = iBars(_Symbol,Timeframe);   if(barsTotal !=bars){      barsTotal = bars;            //get the moving average indicator value for the currend bar and store it in the ma array      double ma[];      CopyBuffer(handleMa,MAIN_LINE,0,1,ma);      //create a dt structure    MqlDateTime dt;   TimeCurrent(dt);   dt.sec = 0;      //update the dt structure variables so it will indicate the opening time for the current day   dt.hour = TimeOpenHour;   dt.min = TimeOpenMin;   //convert the dt structure to a simple datetime variable to make time comparisons easy   datetime timeOpen = StructToTime(dt);      //update the dt structure variable so it will indicate the closing time for the current day   dt.hour = TimeCloseHour;   dt.min = TimeCloseMin;   //convert the dt structure to a simple datetime variable to make time coparisons easy   datetime timeClose = StructToTime(dt);      if(TimeCurrent() >= timeClose && dt.day_of_week == DayClose){      if(posTicket > 0){         if(trade.PositionClose(posTicket)){            posTicket = 0;         }      }   }      //check if we reached the opening time on a the opening day   if(lastDay != dt.day_of_year && TimeCurrent() >= timeOpen && dt.day_of_week == DayOpen){      if(SymbolInfoDouble(_Symbol,SYMBOL_BID) < ma[0]){      //send buy order      double ask = SymbolInfoDouble(_Symbol,SYMBOL_ASK);      double sl = ask - ask * SlPercent / 100;            double ticksize = SymbolInfoDouble(_Symbol,SYMBOL_TRADE_TICK_SIZE);      double tickvalue = SymbolInfoDouble(_Symbol,SYMBOL_TRADE_TICK_VALUE);      double lotstep = SymbolInfoDouble(_Symbol,SYMBOL_VOLUME_STEP);            int ticks = (int)(ask / ticksize);      double riskPerLotstep = ticks * tickvalue *lotstep;      double risk = AccountInfoDouble(ACCOUNT_BALANCE) * RiskPercent / 100;      double lots = risk / riskPerLotstep * lotstep;      lots = NormalizeDouble(lots,DigitsAfterDecimalPoint);            if(trade.Buy(lots,_Symbol,ask,sl,0,"tt")){           posTicket = trade.ResultOrder();           }         lastDay = dt.day_of_year;      }    }    }}

SHA-256: 1e56a248793ed4d91c0807a3e20d43e85a1b61d64dbb98c9a731a86e4f5ca3e2

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