Skip to content

How to Trade with cTrader Indicators

Traders who use indicators can quickly react to market changes, adapt their strategies in real time and make immediate risk adjustments.

In this article and its corresponding video, we will show you how to trade using indicators.

Create an Indicator with a Trading Panel

We intend to create a simple trading panel using an indicator.

Go to the 'Algo' app, navigate to the 'Indicators' tab and then click the 'New' button.

Tick the 'Blank' option, enter a name for your indicator, such as 'Trading Panel', and then click the 'Create' button.

We can start modifying the indicator code in the code editor. To prevent the indicator from creating a separate chart, we set isOverlay to true.

1
[Indicator(AccessRights = AccessRights.None, IsOverlay = true)]

Then we initialise two buttons that open buy and sell positions when clicked.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
var tradeButtonBuy = new Button
{
    Text = "Buy",
    ForegroundColor = Color.White,
    BackgroundColor = Color.Green,
    Height = 25,
    Width = 75,
    Margin = 2
};

tradeButtonBuy.Click += args => ExecuteMarketOrderAsync(TradeType.Buy, SymbolName, 1000);

var tradeButtonSell = new Button
{
    Text = "Sell",
    ForegroundColor = Color.White,
    BackgroundColor = Color.Red,
    Height = 25,
    Width = 75,
    Margin = 2
};

tradeButtonSell.Click += args => ExecuteMarketOrderAsync(TradeType.Sell, SymbolName, 1000);

Add the new buttons to a new grid.

1
2
3
var grid = new Grid(1, 2);
grid.AddChild(tradeButtonBuy, 0,0);
grid.AddChild(tradeButtonSell, 0, 1);

Add the grid to our chart.

1
Chart.AddControl(grid);

You can copy the full code below:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
using System;
using cAlgo.API;
using cAlgo.API.Collections;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;

namespace cAlgo
{
    [Indicator(AccessRights = AccessRights.None, IsOverlay = true)]
    public class TradingPanel : Indicator
    {
        protected override void Initialize()
        {
            var tradeButtonBuy = new Button
            {
                Text = "Buy",
                ForegroundColor = Color.White,
                BackgroundColor = Color.Green,
                Height = 25,
                Width = 75,
                Margin = 2
            };

            tradeButtonBuy.Click += args => ExecuteMarketOrderAsync(TradeType.Buy, SymbolName, 1000);

            var tradeButtonSell = new Button
            {
                Text = "Sell",
                ForegroundColor = Color.White,
                BackgroundColor = Color.Red,
                Height = 25,
                Width = 75,
                Margin = 2
            };
            tradeButtonSell.Click += args => ExecuteMarketOrderAsync(TradeType.Sell, SymbolName, 1000);

            var grid = new Grid(1, 2);
            grid.AddChild(tradeButtonBuy, 0,0);
            grid.AddChild(tradeButtonSell, 0, 1);
            Chart.AddControl(grid);
        }

        public override void Calculate(int index)
        {
            // Calculate value at specified index
            // Result[index] = 
        }
    }
}

Click the 'Build' button or use the Ctrl+B shortcut to build the indicator.

Use the Trading Panel

Let's head to the 'Trade' app to use the indicator. You can add the Trading Panel indicator to a chart.

Click the indicator icon, search for 'Trading Panel' and click the result.

We added the indicator to a 'EURUSD' chart.

Click the 'Buy' and 'Sell' buttons to open positions. When the 'Permission Request' window appears, click the 'Allow' button.

You can manage the panel visibility through its 'Hide/Show' icon.

cTrader now allows you to change the chart period without removing indicators on that chart. Simply select a new period and watch how the panel behaves.

This article taught you the basics of trading with indicators in cTrader. To learn more, review our documentation or post a question on our forum.

Subscribe to our YouTube channel