How to line up multiple controls on a chart?

Created at 27 Jan 2022, 12:38
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!
FI

firemyst

Joined 26.03.2019

How to line up multiple controls on a chart?
27 Jan 2022, 12:38


Hi everyone:

How can I lay out controls on a chart so that they automatically show and stack nicely regardless of how many controls I add from different indicators?

For example, I have the following indicator "abc" :

protected override void Initialize()
        {
            var checkBox = new CheckBox()
            {
                Text = "ABC",
                VerticalAlignment = VerticalAlignment.Top,
                HorizontalAlignment = HorizontalAlignment.Left,
                Margin = 5,
                IsChecked = true
            };
            checkBox.Checked += CheckBox_Checked;
            checkBox.Unchecked += CheckBox_Unchecked;
            Chart.AddControl(checkBox);
        }

If I add it, great! The checkbox shows on the top left of the chart:

Now if I add a second instance of the "abc" indicator onto the same chart, the checkbox from the second indicator "abc2" is directly overlaid on top of the checkbox for "abc".

I want the checkbox for "abc2" to line up underneath the checkbox for "abc".

Subsequently, if I add a third instance of the indicator onto the chart "abc3", I want that checkbox to line up under the checkboxes for "abc" and "abc2":

How can this be done in the indicator without knowing how many times the indicator is going to be added to a chart?

Thank you.

 

 


@firemyst
Replies

amusleh
28 Jan 2022, 08:42

Hi,

Your cBot/indicator doesn't know about other indicator/cBots controls, so you can't align your controls based on other indicators/cBots controls that are present on the chart.

The only option is to allow user change the location of controls by using indicator/cBot parameters, so he will be able to set the location somewhere that is free from other controls.


@amusleh

firemyst
28 Jan 2022, 08:53

RE:

amusleh said:

Hi,

Your cBot/indicator doesn't know about other indicator/cBots controls, so you can't align your controls based on other indicators/cBots controls that are present on the chart.

The only option is to allow user change the location of controls by using indicator/cBot parameters, so he will be able to set the location somewhere that is free from other controls.

Thanks amusleh ,

1) but that means we have what -- a total of 9 locations we can put controls on using the Horizontal/Vertical align parameters? Eg, Halign left valign top; halign right valign middle; etc etc.

2) Otherwise, when you say, "allow user change the location of controls by using indicator/cBot parameters", how do you mean? What parameters would you suggest? The Horizonal/Vertical align as in #1 above? Or something else?

3) And I noticed there appears to be no way to query the chart to see what controls are on the chart like we can query to find what "chart objects" are on the chart?

 

 


@firemyst

amusleh
28 Jan 2022, 12:05

RE: RE:

firemyst said:

Thanks amusleh ,

1) but that means we have what -- a total of 9 locations we can put controls on using the Horizontal/Vertical align parameters? Eg, Halign left valign top; halign right valign middle; etc etc.

2) Otherwise, when you say, "allow user change the location of controls by using indicator/cBot parameters", how do you mean? What parameters would you suggest? The Horizonal/Vertical align as in #1 above? Or something else?

3) And I noticed there appears to be no way to query the chart to see what controls are on the chart like we can query to find what "chart objects" are on the chart?

 

 

Hi,

1. No, you can use grids or any other panels, like canvas.

2. Yes, I mean the alignment properties.

3. For now there is no way to query chart controls, you can only add or remove them.

 You can open a thread under suggestions section for your point #3 if you want to.


@amusleh

firemyst
28 Jan 2022, 17:23

RE: RE: RE:

amusleh said:

firemyst said:

Thanks amusleh ,

1) but that means we have what -- a total of 9 locations we can put controls on using the Horizontal/Vertical align parameters? Eg, Halign left valign top; halign right valign middle; etc etc.

2) Otherwise, when you say, "allow user change the location of controls by using indicator/cBot parameters", how do you mean? What parameters would you suggest? The Horizonal/Vertical align as in #1 above? Or something else?

3) And I noticed there appears to be no way to query the chart to see what controls are on the chart like we can query to find what "chart objects" are on the chart?

 

 

Hi,

1. No, you can use grids or any other panels, like canvas.

2. Yes, I mean the alignment properties.

3. For now there is no way to query chart controls, you can only add or remove them.

 You can open a thread under suggestions section for your point #3 if you want to.

Thank you amusleh ,

That helps immensely.


@firemyst