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] =
}
}
}
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
PanagiotisCharalampous
04 Apr 2024, 06:04
Hi there,
I tried this and seems to work fine
Best regards,
Panagiotis
@PanagiotisCharalampous