Problem with the display of the button in the indicator area

Created at 03 Apr 2024, 20:17
How’s your experience with the cTrader Platform?
Your feedback is crucial to cTrader's development. Please take a few seconds to share your opinion and help us improve your trading experience. Thanks!
M2

m261.acosta

Joined 19.01.2024

Problem with the display of the button in the indicator area
03 Apr 2024, 20:17


Hello friends
I'm having trouble displaying a button in the indicator area and it doesn't work properly.
If so, no error is seen in the code and if I use it to display in the chart, it will be displayed correctly.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using cAlgo.API;
using cAlgo.API.Collections;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;

namespace cAlgo
{
    [Indicator(AccessRights = AccessRights.None,IsOverlay =false)]
    public class NewIndicator8 : Indicator
    {
        [Parameter(DefaultValue = "Hello world!")]
        public string Message { get; set; }

        [Output("Main")]
        public IndicatorDataSeries Result { get; set; }

        protected override void Initialize()
        {
            var stackPanel = new StackPanel
            {
                HorizontalAlignment = HorizontalAlignment.Center,
                VerticalAlignment = VerticalAlignment.Center,
                BackgroundColor = Color.Gold,
                Opacity = 0.7
            };
            var button = new Button
            {
                Text = "Button #",
                Margin = 2,
                HorizontalAlignment = HorizontalAlignment.Center,
                VerticalAlignment = VerticalAlignment.Center
            };
            button.Click += Button_Click;
            stackPanel.AddChild(button);
            IndicatorArea.AddControl(stackPanel);
        }
        private void Button_Click(ButtonClickEventArgs obj)
        {
            Print("Click");
        }

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

@m261.acosta
Replies

PanagiotisCharalampous
04 Apr 2024, 06:04

Hi there,

I tried this and seems to work fine

Best regards,

Panagiotis


@PanagiotisCharalampous

m261.acosta
05 Apr 2024, 10:02 ( Updated at: 07 Apr 2024, 05:23 )

RE: Problem with the display of the button in the indicator area

PanagiotisCharalampous said: 

Hi there,

I tried this and seems to work fine

Best regards,

Panagiotis

If you are in the automate section, the indicator will work correctly for the first time, but if you press the build button once, the button will no longer be shown.
If you add this indicator to a chart in the trade section, it won't show the button even for the first time!
Please try it


@m261.acosta

m261.acosta
13 Apr 2024, 14:10

Has anyone found a solution to this problem?


@m261.acosta

PanagiotisCharalampous
15 Apr 2024, 06:05

Hi all,

We managed to reproduce the problem and it will be fixed in an upcoming release of cTrader.

Best regards,

Panagiotis


@PanagiotisCharalampous