Trading Software
    Menu Close

    Stochastic Oscillator cBot

    Product Support Available

    This basic starter kit for algo developers uses an open-source cTrader Stochastic Oscillator indicator which is a popular technical analysis indicator used in financial markets to assess the momentum and potential reversal points of an asset's price. This cBot will automatically open, close and manage trades based on the values of the SO indicator.

    *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 Stochastic Oscillator indicator also known as "Lane's stochastic" is a Momentum indicator developed by George C. Lane in the late 1950s who taught investors and financial professionals basic and advanced technical analysis methods. The indicator compares a security's closing price to its price range over a specific period, typically 14 periods, and generates values ranging from 0 to 100.

    The stochastic oscillator compares the closing price of an asset to a range of its prices over a specific time frame and by adjusting the time period and applying this to a moving average, the oscillator's sensitivity to market fluctuations can be controlled. Its main purpose is to generate trading signals for overbought and oversold conditions, utilizing a bounded range of values from 0 to 100. This allows the cTrader cBot to automatically open buy and sell trades.


    Here's how the Stochastic indicator is calculated:

    The formula for calculating the Stochastic Oscillator Indicator is simple and shown below.

    • %K = [(Current Close - Lowest Low in %K Periods) / (Highest High in %K Periods - Lowest Low in %K Periods)] * 100
    • The %K represents the current value of the stochastic oscillator, which changes between 0 and 100, this is interpreted as the current position of the asset's closing price relative to its price range over the given period.

    • %K can be further smoothed to create a second line called %D, which is typically a 3-day simple moving average of %K.

    • The %D line acts as a signal line to tell the cBot to open trades.


    Word of Warning

    Like any technical indicator, the Stochastic Oscillator Indicator is not perfect and may produce false signals, therefore, it's often used together with other indicators and analysis methods to confirm trading decisions.


    How Does the cBot Open & Close Trades?

    This cBot opens and closes trades when the indicator %K crosses above or below the %D and when the %K is above or below 20 or 80. 

    Buy Trade Signal

    1. When the SO %K has crossed above the %D AND %K <= 20
    2. Buy trade opens, sell trade closes


    SellTrade Signal

    1. When the SO %K has crossed below the %D AND %K >= 80
    2. Selltrade opens, buy trade closes


    Hard Coded Values

    The indicator values & trade signal values are hard coded but can be easily adapted to a cBot parameter. We recommend that you add user settings for the indicator values as well as the trade signal 20, and 80 values, so they are not hard coded.


    Trading Tip

    The stochastic oscillator is used by traders to recognize potential overbought or oversold conditions and to provide insights into possible future reversals in the price trend, this allows traders to utilize divergences between the price and the stochastic oscillator to identify possible trend reversals.


    Stop Loss & Take Profit Calculation

    A standard stop loss and take profit as well as position size can be set from the cBots parameter settings. 

    You can add additional risk management and other trade rules yourself or by contacting our development team.


    Stochastic Oscillator cBot is provided with full source code by

    cTrader Stochastic Oscillator cBot


    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.


    How to Attach Indicator to Chart

    You do not need to attach the Supertrend indicator to your chart when you run the cBot, but it is a good idea to visually see the indicator to check your trade rules for opening and closing trades and any risk management.


    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 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.