Trading Software
    Menu Close

    Market Close cBot

    Product Support Available

    This basic starter kit for algo developers is a good start at adding risk management to your automated trading strategy, the cBot will close all open trades at a set time in the day. This can be used to close trades just before the market stops trading for a particular symbol. The source code is included to help you add this feature to your existing trading robot.

    *This product is for educational purposes only *
    (OS) Type: Windows & Mac OS Compatible
    Current version: 1.0
    Updated: Friday, 28 July 2023
    Author: ClickAlgo Team

    Need a broker?  Open a demo account

    Educational content: Read our disclaimer

    £0.00 Incl. VAT.
    cTrader Software

    The stock market trading hours can vary depending on the specific exchange and the country in which it operates, here is some general information about the trading hours of major stock markets:

    • New York Stock Exchange (NYSE) and NASDAQ: The regular trading hours for these exchanges in the United States are from 9:30 a.m. to 4:00 p.m. Eastern Time, Monday through Friday. Pre-market and after-hours trading sessions also take place outside of these regular hours.
    • London Stock Exchange (LSE): The LSE operates from 8:00 a.m. to 4:30 p.m. Greenwich Mean Time (GMT), Monday through Friday.

    • Tokyo Stock Exchange (TSE): The TSE is open from 9:00 a.m. to 3:00 p.m. Japan Standard Time (JST), Monday through Friday.

    • Shanghai Stock Exchange (SSE): The SSE operates from 9:30 a.m. to 3:00 p.m. China Standard Time (CST), Monday through Friday.

    • Hong Kong Stock Exchange (HKEX): The HKEX is open from 9:30 a.m. to 4:00 p.m. Hong Kong Time (HKT), Monday through Friday.

    Please note that these hours may be subject to changes for holidays, early closures, or other special circumstances. Additionally, different exchanges may have pre-market or after-hours trading sessions that allow trading outside of regular hours, although liquidity during these periods is often lower.

    The symbol you will be trading will be affected when the markets that trade that symbol are open or closed, one reason for not wanting to keep a symbol (trade) open when the markets close is the low liquidity and the widening of the spread which could take out your stop losses.

    Low liquidity refers to a situation in a market where there is a limited volume of trading activity and a scarcity of buyers and sellers and it typically occurs when there is a lack of participants willing to buy or sell a particular asset, such as stocks, bonds, or commodities.


    How Does the cBot Work?

    This is a very simple example of a cTrader cBot closing trades at a set time in the day, the example allows you to set the closing time as hour:minute:second, so 00:05:00, which is 5 minutes past midnight and at that time it will close all open trades for all symbols.


    Ideas to Improve the cBot

    You can make some minor modifications to add the following features to improve the risk management system.

    1. Close trades for a particular symbol and not all open trades.
    2. Add a date parameter to specify what date to close the trades.
    3. Add a feature to also cancel pending orders.
    4. Only close winners or buyers.


    Market Close cBot is provided with full source code by

    cTrader Breakout Box Indicator


    How To View The Source Code

    To view the source code for this cBot, you will first need to make sure you have downloaded and installed cTrader Desktop, you can also scroll to the bottom of this page for instructions on how to install the cBot. Once installed you will have the cTrader application open, next you need to navigate to the Automate application and click on the name of the cBot, the source should show in the right-hand window.

    If you need more help watch a video tutorial on how to use cTrader Automate.


    Learn Algorithmic Trading

    In this instructional guide, we aim to assist you in acquiring the necessary skills to engage in market trading through automated trading strategies (cBots) using the cTrader Desktop trading platform. By the conclusion of this tutorial, you will gain the confidence to employ a cTrader cBot alongside the Algo application of cTrader, enabling you to automatically execute and handle your market orders. This course is designed to familiarize novice traders with the fundamental principles of algorithmic trading utilizing the cTrader platform.


    Learn Microsoft C# for Algo Trading

    If you are new to coding your own cTrader cBot for automated trading the following Microsoft C# course will help you modify the starter kit cBot in this download to add new features for your own personal trading strategy.


    Algorithmic Trading Facts

    A significant number of traders venture into algorithmic trading with the misconception that they have discovered a foolproof strategy that guarantees effortless wealth. However, this notion is far from reality. It is crucial to read this article, as it can save you valuable time and money. 


    How To Install & Remove

    First, make sure you have the cTrader trading platform installed and then simply unzip the file and double-click on it to automatically install it onto the platform.

    cBot Starter Kit Training

    Any Questions?

    If you have any questions, please first search our coding help forum for the answer, if you cannot find it, post a new question.


    Need Coding Help?

    We can help you modify this cBot for your own personal trading strategy, contact our team for a quote.


    Need a Broker

    If you are still looking for a broker you can trust, take a look at our best cTrader broker site.