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: 3027
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: 3027
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: 701
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?
Post Reply