Smart Grid V3

by jumpycalm in category Other at 17/04/2019

At time of publishing this code, the code was only tested on cTrader 3.5 beta. There’s no plan to make the code work on older cTrader version. does not currently support version 3.5 cBot, therefore, the code was uploaded to github, download your code from github.

Very special thanks to SaifBD for posting the very original code on to, that made the version 1 of the code

Special thanks to Candeias for re-writing the decompiled code to more human readable code which made the version 2 of the code.

Also, very thanks to Panagiotis Charalampous, every time I encountered cBot programing issue and try to search online, I will always find your useful code and suggestions posted on cTrader forum!

Many thanks to the folks’ comments on to made improvements on this code.

I re-wrote the code and shortend the code by more than half thanks to the use of System.Linq Namespaces.

This cBot works best with 15 minutes chart. Default parameters are optimized for EURUSD and GBPUSD.


Change logs:

20190416 (Version 3.0) This is the first version, code is based on the code written by Candeias (Version 2). Some changes below:

1. Code was cleaned up and code was modified to work on cTrader 3.5. The code is not backwards compatible with older version of cTrader;

2. Open buy and open sell Boolean was replaced with maximum open buy and sell number. For example, if you predict future is bullish market, set Maximum open sell position to 0;

3. The long-awaited stop loss was added. However, setting up stop loss is not recommended. If you don't need to enable stop loss, set stop loss to a very large number;

4. Setup parameters were grouped, new feature for cTrader 3.5

5. Added close all trade on stop flag to easy back test and forward test cBot. Currently, cTrader backtester does not show equity with open position when cBot stopped. So, this feature is crucial for accurate back test.

6. cTrader does not handle order take profit well, so, instead of setting a take profit value, this version will check open position on each tick and will execute close order then condition met.

7. I only back tested with this cBot, so, the chart drawing function was not tested. Chart drawing code was the original code from version 2.

Please leave comments below or post a pool on github. If you have coding background, feel free add your suggestions on github.

I hope the whole community here makes a best grid cBot in the market.

I am a software developer, I work for myself, there's no middleman involved. If you have a strategy and would like me to write the code for you. I can offer you the best price in the market. I only write cBot and cTrader indicators. I do not write MT4 and MT5 code.

For business contact, email me at

How to install
Warning! Executing the following cBot may result in loss of funds. Use it at your own risk.
Notification Publishing copyrighted material is strictly prohibited. If you believe there is copyrighted material in this section you may use the Copyright Infringement Notification form to submit a claim.
Formula / Source Code
Language: C#
Trading Platform: cAlgo
using cAlgo.API;
using cAlgo.API.Internals;
namespace cAlgo.Robots
    [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class SmartGridV3 : Robot

        protected override void OnStart()
            // Crrently, website does not support uploading cTrader 3.5 code,
            // The code is on github, download your cBot at github


tgjobscv - April 22, 2019 @ 05:11

65 Errors ?