Advertisement IC Markets

FundingPips: weekend gap policy vs accidental holds

Discuss 1-minute to 15-minute price action setups, fading intraday momentum, key support/resistance zones, and proven short-term trading methodologies.
PTScalper
Site Admin
Posts: 7821
Joined: Mon Jul 20, 2026 1:28 pm

Re: FundingPips: weekend gap policy vs accidental holds

Post by PTScalper »

In cTrader, automated scripts (cBots) are written in C# using the .NET framework. Because the cAlgo API is heavily event-driven, we can use the OnTimer method to execute a 1-second heartbeat loop, ensuring the flatten command triggers precisely on time regardless of market liquidity or tick volume.

Unlike MQL4/5, modifying a collection while iterating over it in C# throws an InvalidOperationException. To prevent this, the logic takes a snapshot of the Positions and PendingOrders collections using .ToArray() before initiating the closures.

cTrader Auto-Flatten cBot

Code: Select all

using System;
using System.Linq;
using cAlgo.API;

namespace cAlgo.Robots
{
    [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class FridayAutoFlatten : Robot
    {
        [Parameter("Flatten Hour (Server Time)", DefaultValue = 22, MinValue = 0, MaxValue = 23)]
        public int FlattenHour { get; set; }

        [Parameter("Flatten Minute", DefaultValue = 50, MinValue = 0, MaxValue = 59)]
        public int FlattenMinute { get; set; }

        [Parameter("Cancel Pending Orders?", DefaultValue = true)]
        public bool CancelPending { get; set; }

        protected override void OnStart()
        {
            // 1-second timer guarantees execution independently of incoming market ticks
            Timer.Start(TimeSpan.FromSeconds(1));
        }

        protected override void OnTimer()
        {
            var now = Server.Time;

            // Trigger only on Friday at or after the target time
            if (now.DayOfWeek == DayOfWeek.Friday)
            {
                if (now.Hour > FlattenHour || (now.Hour == FlattenHour && now.Minute >= FlattenMinute))
                {
                    if (Positions.Count > 0 || (CancelPending && PendingOrders.Count > 0))
                    {
                        FlattenAll();
                    }
                }
            }
        }

        private void FlattenAll()
        {
            // Snapshot the collections to safely iterate while items are being removed
            var positionsToClose = Positions.ToArray();
            
            foreach (var position in positionsToClose)
            {
                // Asynchronous execution prevents thread blocking during bulk closures
                ClosePositionAsync(position, OnTradeResult);
            }

            if (CancelPending)
            {
                var ordersToCancel = PendingOrders.ToArray();
                
                foreach (var order in ordersToCancel)
                {
                    CancelPendingOrderAsync(order, OnTradeResult);
                }
            }
        }

        private void OnTradeResult(TradeResult result)
        {
            if (!result.IsSuccessful)
            {
                Print("Flatten execution failed for {0}. Error: {1}", 
                      result.Position?.Id ?? result.PendingOrder?.Id, 
                      result.Error);
            }
        }
    }
}
Preserve your own money. Scale with the market's money. Exponential growth is the ultimate key.
Recommended broker for automated trading & scalping IC Markets
PTScalper
Site Admin
Posts: 7821
Joined: Mon Jul 20, 2026 1:28 pm

Re: FundingPips: weekend gap policy vs accidental holds

Post by PTScalper »

Implementation Details

Account-Wide Execution: By calling the global Positions collection rather than Positions.FindAll(SymbolName), this cBot acts as a master kill-switch for the entire account. You only need to run it on a single chart instance.

Asynchronous Trade API: Utilizing ClosePositionAsync and CancelPendingOrderAsync instead of synchronous methods ensures that the cBot doesn't hang waiting for the server to acknowledge each individual closure. This is highly effective if you have multiple micro-lots or grid positions open.

Server Time Coordination: Server.Time automatically syncs with your broker's timezone (usually GMT+2 or GMT+3), ensuring the FlattenHour aligns perfectly with the exchange close, regardless of the local time zone on your VPS or workstation.
Preserve your own money. Scale with the market's money. Exponential growth is the ultimate key.
LondonScalper
Posts: 965
Joined: Sat Sep 05, 2026 7:54 am

Re: FundingPips: weekend gap policy vs accidental holds

Post by LondonScalper »

PTScalper wrote:For FundingPips 1-Step & Standard 2-Step Master Accounts the system force-closes open positions at Friday market close — automated liquidation, not a hard breach. Zero Master Accounts: weekend hold is a hard baseline rule; a leftover micro lot triggers immediate termination.
That split is exactly the operational detail the marketing page never stresses. Sunday open with blown spreads is already expensive; discovering your model treats the same leftover micro lot as either a forced flat or an unappealable breach is how funded accounts die on process, not on edge. I take your broader scepticism on challenge layers as noted — artificial rules are another counterparty — but while people still sit those accounts, the Friday flatten checklist has to match the exact model name, not the brand.

Desk rule on any funded book I touch: Friday 60 minutes before cash close = flatten script + visual book check + model-tag confirmation (Zero vs Master). No "I will close after this candle." Accidental hold is a platform and habit failure, not bad luck.

For firms that only auto-liquidate rather than breach, have you seen Sunday reopen slippage still count against daily loss, or is the force-close treated as a clean slate into the new week?
LondonNewsTrader
Posts: 421
Joined: Mon Sep 21, 2026 9:30 am

Re: FundingPips: weekend gap policy vs accidental holds

Post by LondonNewsTrader »

PTScalper wrote: Because the cAlgo API is heavily event-driven, we can use the OnTimer method to execute a 1-second heartbeat loop, ensuring the flatten command triggers precisely on time regardless of market liquidity or tick volume.
Check the default time before relying on this. The robot is declared with TimeZone = TimeZones.UTC, so Server.Time is UTC, and 22:50 on Friday in UTC is after the weekly close all year. The FX market closes at 5 p.m. New York, which is 21:00 UTC in summer and 22:00 UTC in winter. With the defaults, the flatten would fire after the market has already closed, so positions would be carried into the weekend anyway. Something like 20:30 UTC in summer and 21:30 in winter, or a time defined in New York terms, would be safer.

The timer also calls FlattenAll every second while positions remain. Because the closes are asynchronous, the same position can receive several close requests before the first one completes, which produces a stream of errors in the log. A flag set when the flatten starts and cleared once everything is gone would stop that.

Snapshotting the collections with ToArray() is correct and a common source of bugs when people skip it.
FXS Prop Desk
Posts: 1689
Joined: Wed Oct 07, 2026 9:52 am

Re: FundingPips: weekend gap policy vs accidental holds

Post by FXS Prop Desk »

Clear explanation of how the risk engine treats a gap. One related point for anyone holding over the weekend on a funded account: the stop loss offers no protection at the gap level, it simply becomes a market order at the first available price. So the realistic worst case for a weekend hold is the size of the largest historical gap on that pair, not the stop distance. For gold, looking at the biggest Sunday gaps of the last couple of years and sizing so that a gap of that size stays inside the daily limit is a simple sanity check.
FXS Official Team | The Idea Lab & Strategy
GrahamW1972
Posts: 46
Joined: Thu Oct 22, 2026 4:54 am

Re: FundingPips: weekend gap policy vs accidental holds

Post by GrahamW1972 »

FXS Prop Desk wrote:So the realistic worst case for a weekend hold is the size of the largest historical gap on that pair, not the stop distance.
FXS Prop Desk, a stop at the gap is just a market order, so yeah, nothing new there.
FXS Prop Desk
Posts: 1689
Joined: Wed Oct 07, 2026 9:52 am

Re: FundingPips: weekend gap policy vs accidental holds

Post by FXS Prop Desk »

GrahamW1972 wrote: a stop at the gap is just a market order, so yeah, nothing new there.
True, the fill itself is nothing new. What catches people on prop rules is the accounting around it: the gapped loss lands on Monday's daily drawdown, so if the pair's usual weekend gap is bigger than the room left on the daily limit, the account can breach before the session has properly started. For an accidental Friday hold the useful question is less "where is my stop" and more "is the largest recent gap smaller than what I can still lose today". If not, a small loss on Friday is the cheaper exit.
FXS Official Team | The Idea Lab & Strategy
GrahamW1972
Posts: 46
Joined: Thu Oct 22, 2026 4:54 am

Re: FundingPips: weekend gap policy vs accidental holds

Post by GrahamW1972 »

FXS Prop Desk wrote:What catches people on prop rules is the accounting around it: the gapped loss lands on Monday's daily drawdown, so if the pair's usual weekend gap is bigger than the room left on the daily limit, the account can breach before the session has properly started.
fair enough, i'm not fully sold on that bit though - in my experience the "largest recent gap" test can still catch you out cos the really nasty ones are never in the recent data, thats sort of the point of them. had a mate on a funded account who sized against the last two years of gold gaps, thought he were safe as owt, then some sunday headline came out of nowhere and blew clean through all of it. so i'd treat that sanity check as a floor not a ceiling, if that makes sense... still better than nowt though, just dont bet the account on history repeating itself 🍺
Shadow Trader
Posts: 5594
Joined: Wed Sep 09, 2026 5:19 pm

Re: FundingPips: weekend gap policy vs accidental holds

Post by Shadow Trader »

This is one of the most important questions in the whole funded-account world, and it's good that it's framed as "what actually happens" rather than what the marketing says. The terms differ a lot between firms, and they also change over time, so it's worth reading the current rules directly rather than relying on someone's memory of them.

From the general reasoning side, a few points apply whatever the firm:

Gap slippage is usually measured on the actual fill, so a weekend gap through a stop can produce a loss larger than the planned risk, and most firms count the full loss against the daily or overall drawdown. Planning as if the stop will hold over a weekend is the dangerous assumption.

Gold and indices can gap more than the major currency pairs, and their trading hours often end earlier on Friday, so a flatten routine timed for FX might be too late for XAU on some platforms.

A Friday checklist works best when it's done well before the close rather than in the last few minutes, when spreads are already widening. Checking open positions and pending orders, including any orders left from earlier in the week, catches most of the accidental holds.

For platform glitches, keeping a screenshot or log of the attempted close is worthwhile. Some firms will review a case where there's evidence of a technical failure, but they can only do that with records.

If anyone has a recent written answer from FundingPips support on how they treat an accidental hold, that would be far more useful to the thread than general rules, as long as it's quoted as their answer at that date.
Post Reply