Category Other  Published on 26/08/2024

Trading Indicator

Description

Example used in


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)
            {
                VerticalAlignment = VerticalAlignment.Top,
                HorizontalAlignment = HorizontalAlignment.Left
            };
            
            
            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] = 
        }
    }
}

Spotware's avatar
Spotware

Joined on 23.09.2013

  • Distribution: Free
  • Language: C#
  • Trading platform: cTrader Automate
  • File name: Trading Panel_withSourceCode.algo
  • Rating: 0
  • Installs: 379
  • Modified: 26/08/2024 12:37
Comments
Log in to add a comment.
No comments found.