Indicator area textblock

Created at 11 Mar 2020, 18:59
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!
CA

calgodemo

Joined 28.05.2019

Indicator area textblock
11 Mar 2020, 18:59


Hey all,

I've got a simple ADX indicator, where I click on it I'd like to see a textbox appear and write out the values where the mouse is.

I got the mouse_down event and I can call that to draw an icon in the indicatorArea where I clicked but I am struggling to find out how to do that with the textblock.

Many thanks!

CaD

protected override void Initialize()
        {
            lastindex = 0;

            IndicatorArea.MouseDown += IndicatorArea_Click;

            H4Bars = MarketData.GetBars(customTimeframe);
            while (H4Bars.OpenTimes[0] > Bars.OpenTimes[0])
            {
                var loadedCount = H4Bars.LoadMoreHistory();
                Print("Loaded {0} bars", loadedCount);
                if (loadedCount == 0)
                    break;
            }
            _ADX = Indicators.DirectionalMovementSystem(H4Bars, 14);
        }

        private void IndicatorArea_Click(ChartMouseEventArgs obj)
        {
            var index_trigger = H4Bars.OpenTimes.GetIndexByTime(obj.TimeValue);
            if (index_trigger != -1)
            {
                var convertIndex_current = Bars.OpenTimes.GetIndexByExactTime(H4Bars.OpenTimes[index_trigger]);

                
            }

            IndicatorArea.DrawIcon("test", ChartIconType.Circle, obj.TimeValue, obj.YValue, "yellow");
        }

 


@calgodemo
Replies

calgodemo
11 Mar 2020, 23:48

Essentially I'd like to replicate what happens in ctrader normally when I hover over an indicator value, with the box and everything nice and neatly. Just with my own values.


@calgodemo

PanagiotisCharalampous
12 Mar 2020, 09:21

Hi calgodemo,

Here is a starting point

        private void IndicatorArea_Click(ChartMouseEventArgs obj)
        {
            var text1 = new TextBlock
            {
                BackgroundColor = Color.Red,
                Text = "Test",
                Width = 30,
                Height = 10,
                HorizontalAlignment = HorizontalAlignment.Left,
                VerticalAlignment = VerticalAlignment.Top
            };

            text1.Margin = new Thickness(obj.MouseX, obj.MouseY, 0, 0);
            IndicatorArea.AddControl(text1);
        }

Best Regards,

Panagiotis 

Join us on Telegram

 


@PanagiotisCharalampous

calgodemo
12 Mar 2020, 17:53

RE:

PanagiotisCharalampous said:

Hi calgodemo,

Here is a starting point

        private void IndicatorArea_Click(ChartMouseEventArgs obj)
        {
            var text1 = new TextBlock
            {
                BackgroundColor = Color.Red,
                Text = "Test",
                Width = 30,
                Height = 10,
                HorizontalAlignment = HorizontalAlignment.Left,
                VerticalAlignment = VerticalAlignment.Top
            };

            text1.Margin = new Thickness(obj.MouseX, obj.MouseY, 0, 0);
            IndicatorArea.AddControl(text1);
        }

Best Regards,

Panagiotis 

Join us on Telegram

 

Thank you! That did for a start!

CaD


@calgodemo