Advertisement IC Markets

Christmas week session map: when I simply do not trade

Discuss 1-minute to 15-minute price action setups, fading intraday momentum, key support/resistance zones, and proven short-term trading methodologies.
LondonScalper
Posts: 965
Joined: Sat Sep 05, 2026 7:54 am

Christmas week session map: when I simply do not trade

Post by LondonScalper »

Christmas week session map: when I simply do not trade.

I keep a written map for the holiday week so I am not deciding session-by-session under boredom. Some days are observe-only by policy: half-days, early closes, the stretch between Boxing Day and New Year when desks are thin and spreads invent their own personality.

How I map it
Green = normal rules. Amber = half size, majors only, tight time stops. Red = flat, platform for levels and journal only. I colour the calendar on the prior Sunday.

Raw pricing does not fix holiday depth. Neither does "just one gold scalp." Most of my holiday losses were optional -- I was not owed activity because the office was quiet.

If you have a hard no-trade window in Christmas week, how do you mark it so future-you cannot negotiate?

Family days are marked red even if liquidity looks fine on a quote board. Trading while half-present is how holiday weeks get their reputation. The market reopens in January; your attention does not get a second Christmas. Write the red days where you can see them when boredom hits.
Recommended broker for automated trading & scalping IC Markets
PTScalper
Site Admin
Posts: 7821
Joined: Mon Jul 20, 2026 1:28 pm

Re: Christmas week session map: when I simply do not trade

Post by PTScalper »

LondonScalper wrote: Mon Sep 14, 2026 8:59 pm Christmas week session map: when I simply do not trade.

I keep a written map for the holiday week so I am not deciding session-by-session under boredom. Some days are observe-only by policy: half-days, early closes, the stretch between Boxing Day and New Year when desks are thin and spreads invent their own personality.

How I map it
Green = normal rules. Amber = half size, majors only, tight time stops. Red = flat, platform for levels and journal only. I colour the calendar on the prior Sunday.

Raw pricing does not fix holiday depth. Neither does "just one gold scalp." Most of my holiday losses were optional -- I was not owed activity because the office was quiet.

If you have a hard no-trade window in Christmas week, how do you mark it so future-you cannot negotiate?

Family days are marked red even if liquidity looks fine on a quote board. Trading while half-present is how holiday weeks get their reputation. The market reopens in January; your attention does not get a second Christmas. Write the red days where you can see them when boredom hits.
Hi LondonScalper,

You are absolutely right to treat the holiday stretch as a fundamentally different environment. When the institutional desks clear out for the year, the market's microstructure completely changes. The order book thins out so dramatically that the standard mechanics of price action simply stop functioning the way they do in October or February.

Mapping this out in advance is the only way to survive the week with your capital—and your sanity—intact. Here is exactly why those standard rules break down and why your Red/Amber/Green system is the right approach:

Levels become suggestions, not barriers: On a normal Tuesday, a daily support level holds because institutional volume defends it or takes profit there. In late December, the lack of resting orders means even a modest market order can punch right through a well-established level just to find liquidity. A standard 15-minute candlestick structure that you would normally trust will start looking jagged, erratic, and entirely unpredictable.

Spread expansion destroys the math: As you noted, raw pricing doesn't fix a holiday market. Liquidity providers and automated market makers widen their spreads to protect themselves in thin conditions. If you are scalping, that widened spread instantly destroys the risk-to-reward ratio of a setup that would otherwise be perfectly valid.

Erratic liquidity sweeps: Without heavy volume to absorb shocks, assets like gold or spot forex pairs become prone to sudden, irrational spikes. What looks like a textbook liquidity sweep is often just a vacuum of bids or asks, making precise stop-loss placement nearly impossible. The market isn't hunting your stop; there is just nothing in the book to slow the price down.
Preserve your own money. Scale with the market's money. Exponential growth is the ultimate key.
PTScalper
Site Admin
Posts: 7821
Joined: Mon Jul 20, 2026 1:28 pm

Re: Christmas week session map: when I simply do not trade

Post by PTScalper »

The psychological trap of "just one gold scalp" is exactly how holiday weeks drain accounts. When you are off work, sitting in a quiet house with screens available, the urge to manufacture a setup out of sheer boredom is immense. You aren't seeing an edge; you are just seeking engagement. Your traffic-light calendar system is one of the most robust ways to handle this because it removes in-the-moment decision fatigue. Future-you is an exceptional negotiator, especially when staring at a chart looking for a dopamine hit.

To make those Red days truly non-negotiable, the physical environment has to match the calendar. If the rule is observation and journaling only, the execution interface needs to be inaccessible. Closing the order window, disabling auto-login on MT4 or cTrader, or completely turning off custom alerts removes the friction of willpower. You can't take a boredom trade if the platform physically won't let you click a button without a five-minute setup process.
Preserve your own money. Scale with the market's money. Exponential growth is the ultimate key.
PTScalper
Site Admin
Posts: 7821
Joined: Mon Jul 20, 2026 1:28 pm

Re: Christmas week session map: when I simply do not trade

Post by PTScalper »

Your point about family days is the most crucial part of this entire framework. Splitting focus between a volatile, low-liquidity chart and a holiday gathering guarantees you will do poorly at both. The mental capital required to execute a high-probability strategy cannot be summoned while you are only half-present in the room.

The market will be fully funded, highly liquid, and waiting for you in January. How do you technically enforce your Red days on your workstation to make sure you can't override your own rules?
Preserve your own money. Scale with the market's money. Exponential growth is the ultimate key.
PTScalper
Site Admin
Posts: 7821
Joined: Mon Jul 20, 2026 1:28 pm

Re: Christmas week session map: when I simply do not trade

Post by PTScalper »

Because TradingView’s Pine Script does not natively expose historical or real-time spread (ask/bid) data as a standard series, the most bulletproof way to build this is a time-based visual override.

If the goal is to stop future-you from negotiating with the chart out of boredom, we don't need to measure the spread—we need to completely hijack your visual workspace during the holiday window.

This Pine Script (v5) blacklists your specified holiday dates. When the calendar hits your Red Zone, it floods the chart background with red and slaps a massive, unmissable warning table dead-center on your screen.

Code: Select all

//@version=5
indicator("Holiday No-Trade Zone", overlay=true)

// --- INPUTS: Define your Red Zone ---
// Default: Dec 20 to Jan 3
startMonth = input.int(12, title="Start Month", minval=1, maxval=12, group="Holiday Window")
startDay   = input.int(20, title="Start Day", minval=1, maxval=31, group="Holiday Window")
endMonth   = input.int(1,  title="End Month", minval=1, maxval=12, group="Holiday Window")
endDay     = input.int(3,  title="End Day", minval=1, maxval=31, group="Holiday Window")

// --- LOGIC: Check if current bar is inside the window ---
isAfterStart = month(time) > startMonth or (month(time) == startMonth and dayofmonth(time) >= startDay)
isBeforeEnd  = month(time) < endMonth   or (month(time) == endMonth   and dayofmonth(time) <= endDay)

// Handle the December -> January year wrap-around
bool inHolidayZone = false
if startMonth > endMonth
    inHolidayZone := isAfterStart or isBeforeEnd
else
    inHolidayZone := isAfterStart and isBeforeEnd

// --- VISUAL ENFORCEMENT 1: Paint the background ---
bgcolor(inHolidayZone ? color.new(color.maroon, 85) : na, title="Holiday Background")

// --- VISUAL ENFORCEMENT 2: Giant Screen Warning ---
var table warningTable = table.new(position.middle_center, 1, 1)

if inHolidayZone and barstate.islast
    table.cell(warningTable, 0, 0, 
               "🛑 HOLIDAY ZONE 🛑\n\nTHIN LIQUIDITY & HIGH SPREAD\nOBSERVE ONLY", 
               text_color=color.white, 
               bgcolor=color.new(color.red, 30), 
               text_size=size.huge)
else if not inHolidayZone and barstate.islast
    // Clear the table when outside the holiday zone
    table.clear(warningTable, 0, 0)
Preserve your own money. Scale with the market's money. Exponential growth is the ultimate key.
PTScalper
Site Admin
Posts: 7821
Joined: Mon Jul 20, 2026 1:28 pm

Re: Christmas week session map: when I simply do not trade

Post by PTScalper »

How this forces discipline:

The Wrap-Around Logic: It automatically handles the December to January transition. If you set it from 12/20 to 1/3, it will trigger every single year without you needing to update the code.

The Anchor: The warning table uses position.middle_center and size.huge. It will literally block the price action in the middle of your screen on the current live candle. You can still see the edges of the chart to observe structure, but taking a precise 15-minute price action entry becomes incredibly annoying when a giant red box is sitting on top of the DOM.

Zero Discretion: It removes the internal dialogue of "Well, let me just check what the spread is right now." By the time you load the chart, the script has already made the decision for you.

If you are using cTrader or MT5 for your actual execution, you can port this same logic using DateTime.Month and DateTime.Day in C# or MQL5 to physically disable the PlaceOrder or OrderSend functions during those dates.
Preserve your own money. Scale with the market's money. Exponential growth is the ultimate key.
PTScalper
Site Admin
Posts: 7821
Joined: Mon Jul 20, 2026 1:28 pm

Re: Christmas week session map: when I simply do not trade

Post by PTScalper »

Here are the complete, ready-to-compile indicator scripts for both MetaTrader 4 and MetaTrader 5.

Unlike Pine Script, MT4 and MT5 have direct access to real-time broker spreads (SymbolInfoInteger). These indicators continuously track both the holiday calendar window and the live broker spread, drawing an unmissable red warning banner directly on your chart whenever you are in the holiday zone or when spreads blow out past normal thresholds.

1. MetaTrader 4 (HolidayWarning.mq4)

Save this file in your MT4 data folder under MQL4/Indicators/HolidayWarning.mq4 and compile in MetaEditor.

Code: Select all

//+------------------------------------------------------------------+
//|                                               HolidayWarning.mq4 |
//|                                  Copyright 2026, Scalping Setup  |
//+------------------------------------------------------------------+
#property copyright "Copyright 2026"
#property link      ""
#property version   "1.00"
#property strict
#property indicator_chart_window
#property indicator_plots 0

// --- INPUTS ---
input group "=== Holiday Window ==="
input int      InpStartMonth       = 12;          // Start Month
input int      InpStartDay         = 20;          // Start Day
input int      InpEndMonth         = 1;           // End Month
input int      InpEndDay           = 3;           // End Day

input group "=== Spread & Warning ==="
input double   InpMaxSpreadPips    = 2.5;         // Alert Spread Threshold (Pips)
input color    InpBgColor          = C'130,20,20';// Banner Background Color
input color    InpTextColor        = clrWhite;    // Text Color

#define PREFIX "HW_OVERLAY_"

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
{
   DeleteUI();
   return(INIT_SUCCEEDED);
}

//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
   DeleteUI();
   ChartRedraw();
}

//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
{
   datetime current = TimeCurrent();
   bool isHoliday = CheckHolidayDate(current, InpStartMonth, InpStartDay, InpEndMonth, InpEndDay);
   
   long rawSpread = SymbolInfoInteger(_Symbol, SYMBOL_SPREAD);
   double pointVal = Point();
   double pipMult = (_Digits == 3 || _Digits == 5) ? 10.0 : 1.0;
   double currentSpreadPips = (double)rawSpread / pipMult;
   bool isSpreadBlown = (currentSpreadPips >= InpMaxSpreadPips);

   if(isHoliday || isSpreadBlown)
   {
      RenderWarningBanner(isHoliday, currentSpreadPips);
   }
   else
   {
      DeleteUI();
   }

   return(rates_total);
}

//+------------------------------------------------------------------+
//| Date evaluation supporting Dec -> Jan year wrap                  |
//+------------------------------------------------------------------+
bool CheckHolidayDate(datetime t, int sMon, int sDay, int eMon, int eDay)
{
   MqlDateTime dt;
   TimeToStruct(t, dt);

   bool afterStart = (dt.mon > sMon) || (dt.mon == sMon && dt.day >= sDay);
   bool beforeEnd  = (dt.mon < eMon) || (dt.mon == eMon && dt.day <= eDay);

   if(sMon > eMon)
      return (afterStart || beforeEnd);
   else
      return (afterStart && beforeEnd);
}

//+------------------------------------------------------------------+
//| Render warning box and text labels                               |
//+------------------------------------------------------------------+
void RenderWarningBanner(bool isHoliday, double spreadPips)
{
   int chartWidth = (int)ChartGetInteger(0, CHART_WIDTH_IN_PIXELS);
   int boxWidth   = 440;
   int boxHeight  = 95;
   int xPos       = MathMax(20, (chartWidth - boxWidth) / 2);
   int yPos       = 40;

   // 1. Background Box
   string bgName = PREFIX + "BG";
   if(ObjectFind(0, bgName) < 0)
   {
      ObjectCreate(0, bgName, OBJ_RECTANGLE_LABEL, 0, 0, 0);
      ObjectSetInteger(0, bgName, OBJPROP_CORNER, CORNER_LEFT_UPPER);
      ObjectSetInteger(0, bgName, OBJPROP_BORDER_TYPE, BORDER_FLAT);
      ObjectSetInteger(0, bgName, OBJPROP_COLOR, clrRed);
      ObjectSetInteger(0, bgName, OBJPROP_WIDTH, 2);
   }
   ObjectSetInteger(0, bgName, OBJPROP_XDISTANCE, xPos);
   ObjectSetInteger(0, bgName, OBJPROP_YDISTANCE, yPos);
   ObjectSetInteger(0, bgName, OBJPROP_XSIZE, boxWidth);
   ObjectSetInteger(0, bgName, OBJPROP_YSIZE, boxHeight);
   ObjectSetInteger(0, bgName, OBJPROP_BGCOLOR, InpBgColor);

   // 2. Title Label
   string titleText = isHoliday ? "[!] HOLIDAY NO-TRADE ZONE [!]" : "[!] WARNING: SPREAD BLOWN [!]";
   UpdateLabel(PREFIX + "TITLE", titleText, xPos + 20, yPos + 12, "Arial Bold", 13, clrWhite);

   // 3. Status Line
   string status = isHoliday ? "THIN LIQUIDITY -- OBSERVE & JOURNAL ONLY" : "EXECUTION CONDITIONS COMPROMISED";
   UpdateLabel(PREFIX + "STATUS", status, xPos + 20, yPos + 40, "Arial", 9, clrYellow);

   // 4. Spread Line
   string spreadText = StringFormat("Live Spread: %.1f pips (Max Allowed: %.1f pips)", spreadPips, InpMaxSpreadPips);
   color spreadColor = (spreadPips >= InpMaxSpreadPips) ? clrRed : clrLime;
   UpdateLabel(PREFIX + "SPREAD", spreadText, xPos + 20, yPos + 62, "Arial Bold", 10, spreadColor);

   ChartRedraw();
}

//+------------------------------------------------------------------+
//| Update or Create Label Object                                    |
//+------------------------------------------------------------------+
void UpdateLabel(string name, string text, int x, int y, string font, int fontSize, color col)
{
   if(ObjectFind(0, name) < 0)
   {
      ObjectCreate(0, name, OBJ_LABEL, 0, 0, 0);
      ObjectSetInteger(0, name, OBJPROP_CORNER, CORNER_LEFT_UPPER);
   }
   ObjectSetString(0, name, OBJPROP_TEXT, text);
   ObjectSetInteger(0, name, OBJPROP_XDISTANCE, x);
   ObjectSetInteger(0, name, OBJPROP_YDISTANCE, y);
   ObjectSetString(0, name, OBJPROP_FONT, font);
   ObjectSetInteger(0, name, OBJPROP_FONTSIZE, fontSize);
   ObjectSetInteger(0, name, OBJPROP_COLOR, col);
}

//+------------------------------------------------------------------+
//| Clean up screen objects                                          |
//+------------------------------------------------------------------+
void DeleteUI()
{
   ObjectsDeleteAll(0, PREFIX);
}
Preserve your own money. Scale with the market's money. Exponential growth is the ultimate key.
PTScalper
Site Admin
Posts: 7821
Joined: Mon Jul 20, 2026 1:28 pm

Re: Christmas week session map: when I simply do not trade

Post by PTScalper »

2. MetaTrader 5 (HolidayWarning.mq5)

Save this file in your MT5 data folder under MQL5/Indicators/HolidayWarning.mq5 and compile in MetaEditor.

Code: Select all

//+------------------------------------------------------------------+
//|                                               HolidayWarning.mq5 |
//|                                  Copyright 2026, Scalping Setup  |
//+------------------------------------------------------------------+
#property copyright "Copyright 2026"
#property link      ""
#property version   "1.00"
#property indicator_chart_window
#property indicator_plots 0

// --- INPUTS ---
input group "=== Holiday Window ==="
input int      InpStartMonth       = 12;          // Start Month
input int      InpStartDay         = 20;          // Start Day
input int      InpEndMonth         = 1;           // End Month
input int      InpEndDay           = 3;           // End Day

input group "=== Spread & Warning ==="
input double   InpMaxSpreadPips    = 2.5;         // Alert Spread Threshold (Pips)
input color    InpBgColor          = C'130,20,20';// Banner Background Color
input color    InpTextColor        = clrWhite;    // Text Color

#define PREFIX "HW5_OVERLAY_"

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
{
   DeleteUI();
   return(INIT_SUCCEEDED);
}

//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
   DeleteUI();
   ChartRedraw(0);
}

//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
{
   datetime current = TimeCurrent();
   bool isHoliday = CheckHolidayDate(current, InpStartMonth, InpStartDay, InpEndMonth, InpEndDay);

   long rawSpread = SymbolInfoInteger(_Symbol, SYMBOL_SPREAD);
   int digits = (int)SymbolInfoInteger(_Symbol, SYMBOL_DIGITS);
   double pipMult = (digits == 3 || digits == 5) ? 10.0 : 1.0;
   double currentSpreadPips = (double)rawSpread / pipMult;
   bool isSpreadBlown = (currentSpreadPips >= InpMaxSpreadPips);

   if(isHoliday || isSpreadBlown)
   {
      RenderWarningBanner(isHoliday, currentSpreadPips);
   }
   else
   {
      DeleteUI();
   }

   return(rates_total);
}

//+------------------------------------------------------------------+
//| Date evaluation supporting Dec -> Jan year wrap                  |
//+------------------------------------------------------------------+
bool CheckHolidayDate(datetime t, int sMon, int sDay, int eMon, int eDay)
{
   MqlDateTime dt;
   TimeToStruct(t, dt);

   bool afterStart = (dt.mon > sMon) || (dt.mon == sMon && dt.day >= sDay);
   bool beforeEnd  = (dt.mon < eMon) || (dt.mon == eMon && dt.day <= eDay);

   if(sMon > eMon)
      return (afterStart || beforeEnd);
   else
      return (afterStart && beforeEnd);
}

//+------------------------------------------------------------------+
//| Render warning box and text labels                               |
//+------------------------------------------------------------------+
void RenderWarningBanner(bool isHoliday, double spreadPips)
{
   int chartWidth = (int)ChartGetInteger(0, CHART_WIDTH_IN_PIXELS);
   int boxWidth   = 440;
   int boxHeight  = 95;
   int xPos       = MathMax(20, (chartWidth - boxWidth) / 2);
   int yPos       = 40;

   // 1. Background Box
   string bgName = PREFIX + "BG";
   if(ObjectFind(0, bgName) < 0)
   {
      ObjectCreate(0, bgName, OBJ_RECTANGLE_LABEL, 0, 0, 0);
      ObjectSetInteger(0, bgName, OBJPROP_CORNER, CORNER_LEFT_UPPER);
      ObjectSetInteger(0, bgName, OBJPROP_BORDER_TYPE, BORDER_FLAT);
      ObjectSetInteger(0, bgName, OBJPROP_COLOR, clrRed);
      ObjectSetInteger(0, bgName, OBJPROP_WIDTH, 2);
   }
   ObjectSetInteger(0, bgName, OBJPROP_XDISTANCE, xPos);
   ObjectSetInteger(0, bgName, OBJPROP_YDISTANCE, yPos);
   ObjectSetInteger(0, bgName, OBJPROP_XSIZE, boxWidth);
   ObjectSetInteger(0, bgName, OBJPROP_YSIZE, boxHeight);
   ObjectSetInteger(0, bgName, OBJPROP_BGCOLOR, InpBgColor);

   // 2. Title Label
   string titleText = isHoliday ? "[!] HOLIDAY NO-TRADE ZONE [!]" : "[!] WARNING: SPREAD BLOWN [!]";
   UpdateLabel(PREFIX + "TITLE", titleText, xPos + 20, yPos + 12, "Arial Bold", 13, clrWhite);

   // 3. Status Line
   string status = isHoliday ? "THIN LIQUIDITY -- OBSERVE & JOURNAL ONLY" : "EXECUTION CONDITIONS COMPROMISED";
   UpdateLabel(PREFIX + "STATUS", status, xPos + 20, yPos + 40, "Arial", 9, clrYellow);

   // 4. Spread Line
   string spreadText = StringFormat("Live Spread: %.1f pips (Max Allowed: %.1f pips)", spreadPips, InpMaxSpreadPips);
   color spreadColor = (spreadPips >= InpMaxSpreadPips) ? clrRed : clrLime;
   UpdateLabel(PREFIX + "SPREAD", spreadText, xPos + 20, yPos + 62, "Arial Bold", 10, spreadColor);

   ChartRedraw(0);
}

//+------------------------------------------------------------------+
//| Update or Create Label Object                                    |
//+------------------------------------------------------------------+
void UpdateLabel(string name, string text, int x, int y, string font, int fontSize, color col)
{
   if(ObjectFind(0, name) < 0)
   {
      ObjectCreate(0, name, OBJ_LABEL, 0, 0, 0);
      ObjectSetInteger(0, name, OBJPROP_CORNER, CORNER_LEFT_UPPER);
   }
   ObjectSetString(0, name, OBJPROP_TEXT, text);
   ObjectSetInteger(0, name, OBJPROP_XDISTANCE, x);
   ObjectSetInteger(0, name, OBJPROP_YDISTANCE, y);
   ObjectSetString(0, name, OBJPROP_FONT, font);
   ObjectSetInteger(0, name, OBJPROP_FONTSIZE, fontSize);
   ObjectSetInteger(0, name, OBJPROP_COLOR, col);
}

//+------------------------------------------------------------------+
//| Clean up screen objects                                          |
//+------------------------------------------------------------------+
void DeleteUI()
{
   ObjectsDeleteAll(0, PREFIX);
}
Preserve your own money. Scale with the market's money. Exponential growth is the ultimate key.
PTScalper
Site Admin
Posts: 7821
Joined: Mon Jul 20, 2026 1:28 pm

Re: Christmas week session map: when I simply do not trade

Post by PTScalper »

Operational Details

Dynamic Centering: Both indicators calculate chart pixel width (CHART_WIDTH_IN_PIXELS) on each incoming tick, pinning the warning card dead-center near the top edge of your screen regardless of resolution or chart resizing.

Fractional Pip Calculation: Automatically detects 3/5 digit quotes (EURUSD, XAUUSD, USDJPY) and divides raw points by 10 so the displayed spread corresponds to real pips.

Dual Protection: If you are within the December 20 – January 3 window, the banner stays pinned with your "Observe & Journal Only" rule. If you are outside the window but an asset’s spread widens past InpMaxSpreadPips (e.g., rollover or surprise market event), it immediately fires the SPREAD BLOWN alert banner to warn you against entering.
Preserve your own money. Scale with the market's money. Exponential growth is the ultimate key.
PTScalper
Site Admin
Posts: 7821
Joined: Mon Jul 20, 2026 1:28 pm

Re: Christmas week session map: when I simply do not trade

Post by PTScalper »

Here is the complete, ready-to-build C# indicator for cTrader.

Since you are using cAlgo for C#, we can take advantage of cTrader’s modern WPF-style UI framework to create a really clean, responsive overlay. Instead of manually calculating screen pixels like in MT4/MT5, this script uses cTrader's native layout system to permanently lock the warning banner to the top-center of your chart.

Installation Instructions

1.) Open cTrader and go to the Automate tab.

2.) Click New Indicator.

3.) Name it HolidayWarning.

4.) Delete the default code, paste the C# code below, and click Build (or press Ctrl+B).

Code: Select all

using System;
using cAlgo.API;
using cAlgo.API.Internals;

namespace cAlgo
{
    [Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class HolidayWarning : Indicator
    {
        // --- INPUTS: Holiday Window ---
        [Parameter("Start Month", DefaultValue = 12, Group = "Holiday Window", MinValue = 1, MaxValue = 12)]
        public int StartMonth { get; set; }

        [Parameter("Start Day", DefaultValue = 20, Group = "Holiday Window", MinValue = 1, MaxValue = 31)]
        public int StartDay { get; set; }

        [Parameter("End Month", DefaultValue = 1, Group = "Holiday Window", MinValue = 1, MaxValue = 12)]
        public int EndMonth { get; set; }

        [Parameter("End Day", DefaultValue = 3, Group = "Holiday Window", MinValue = 1, MaxValue = 31)]
        public int EndDay { get; set; }

        // --- INPUTS: Spread & Warning ---
        [Parameter("Max Spread (Pips)", DefaultValue = 2.5, Group = "Spread & Warning", MinValue = 0.1)]
        public double MaxSpreadPips { get; set; }

        // --- UI Elements ---
        private Border _warningBorder;
        private TextBlock _titleText;
        private TextBlock _statusText;
        private TextBlock _spreadText;

        protected override void Initialize()
        {
            // Initialize the UI elements
            _titleText = new TextBlock
            {
                TextAlignment = TextAlignment.Center,
                FontWeight = FontWeight.ExtraBold,
                FontSize = 16,
                Margin = new Thickness(0, 0, 0, 5)
            };

            _statusText = new TextBlock
            {
                TextAlignment = TextAlignment.Center,
                FontSize = 12,
                ForegroundColor = Color.FromHex("#FFFFD700"), // Gold/Yellow
                Margin = new Thickness(0, 0, 0, 8)
            };

            _spreadText = new TextBlock
            {
                TextAlignment = TextAlignment.Center,
                FontWeight = FontWeight.Bold,
                FontSize = 14
            };

            var stackPanel = new StackPanel
            {
                Orientation = Orientation.Vertical,
                HorizontalAlignment = HorizontalAlignment.Center,
                VerticalAlignment = VerticalAlignment.Center,
                Margin = new Thickness(15)
            };

            stackPanel.AddChild(_titleText);
            stackPanel.AddChild(_statusText);
            stackPanel.AddChild(_spreadText);

            _warningBorder = new Border
            {
                Child = stackPanel,
                BackgroundColor = Color.FromHex("#DD8B0000"), // Dark Red with transparency
                BorderColor = Color.FromHex("#FFFF0000"),    // Bright Red border
                BorderThickness = new Thickness(2),
                CornerRadius = 5,
                HorizontalAlignment = HorizontalAlignment.Center,
                VerticalAlignment = VerticalAlignment.Top,
                Margin = new Thickness(0, 50, 0, 0),         // 50px offset from the top
                IsVisible = false                            // Hidden by default
            };

            // Add the UI to the chart
            Chart.AddControl(_warningBorder);
        }

        public override void Calculate(int index)
        {
            // Only evaluate the live tick (ignore historical bars to save CPU)
            if (!IsLastIndex) return;

            // Use Server.Time to prevent local PC clock manipulation
            DateTime current = Server.Time;
            bool isHoliday = CheckHolidayDate(current, StartMonth, StartDay, EndMonth, EndDay);

            // cTrader cleanly gives us pip size directly, bypassing 5-digit broker math
            double currentSpreadPips = Math.Round((Symbol.Ask - Symbol.Bid) / Symbol.PipSize, 1);
            bool isSpreadBlown = currentSpreadPips >= MaxSpreadPips;

            if (isHoliday || isSpreadBlown)
            {
                UpdateUI(isHoliday, currentSpreadPips);
                _warningBorder.IsVisible = true;
            }
            else
            {
                _warningBorder.IsVisible = false;
            }
        }

        private bool CheckHolidayDate(DateTime t, int sMon, int sDay, int eMon, int eDay)
        {
            bool afterStart = (t.Month > sMon) || (t.Month == sMon && t.Day >= sDay);
            bool beforeEnd = (t.Month < eMon) || (t.Month == eMon && t.Day <= eDay);

            // Handle the December -> January year wrap-around
            if (sMon > eMon)
                return afterStart || beforeEnd;
            else
                return afterStart && beforeEnd;
        }

        private void UpdateUI(bool isHoliday, double spreadPips)
        {
            if (isHoliday)
            {
                _titleText.Text = "🛑 HOLIDAY NO-TRADE ZONE 🛑";
                _titleText.ForegroundColor = Color.White;
                _statusText.Text = "THIN LIQUIDITY -- OBSERVE & JOURNAL ONLY";
            }
            else
            {
                _titleText.Text = "⚠️ WARNING: SPREAD BLOWN ⚠️";
                _titleText.ForegroundColor = Color.White;
                _statusText.Text = "EXECUTION CONDITIONS COMPROMISED";
            }

            _spreadText.Text = $"Live Spread: {spreadPips} pips (Max Allowed: {MaxSpreadPips} pips)";
            _spreadText.ForegroundColor = spreadPips >= MaxSpreadPips ? Color.FromHex("#FFFF6666") : Color.FromHex("#FF66FF66"); // Light Red or Light Green
        }
    }
}
Preserve your own money. Scale with the market's money. Exponential growth is the ultimate key.
Post Reply