Draw Text on Chart

Created at 29 Jun 2020, 12:37
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!
CT

ctid1412177

Joined 02.03.2020

Draw Text on Chart
29 Jun 2020, 12:37


Hi All,

I am trying to use the Chart.Drawtext code to update the charts with signal information.  I am using:

 

 private void drawSignalPricesHighToChart(bool onStart)
        {
            if (onStart == false){
                var openTime = Bars.Last(0).OpenTime;
                var textHigh = Chart.DrawText("textSignalHigh", signalHigh.ToString(), openTime, signalHigh, Color.White);
                textHigh.VerticalAlignment = VerticalAlignment.Top;
                textHigh.HorizontalAlignment = HorizontalAlignment.Center;
            }else{
                var openTime = Bars.Last(0).OpenTime;                
                var textHigh = Chart.DrawText("textSignalHigh", signalHigh.ToString(), openTime, Bars.Last(1).High, Color.White);

                textHigh.VerticalAlignment = VerticalAlignment.Top;
                textHigh.HorizontalAlignment = HorizontalAlignment.Center;
            }
        }

        private void drawSignalPricesLowToChart(bool onStart)
        {
            if (onStart == false){
                var openTime = Bars.Last(0).OpenTime;
                var textLow = Chart.DrawText("textSignalLow", signalLow.ToString(), openTime, signalLow, Color.Orange);
                textLow.VerticalAlignment = VerticalAlignment.Bottom;
                textLow.HorizontalAlignment = HorizontalAlignment.Center;
            }else{
                var openTime = Bars.Last(0).OpenTime;
                var textLow = Chart.DrawText("textSignalLow", signalLow.ToString(), openTime, Bars.Last(1).Low, Color.Orange);                
                textLow.VerticalAlignment = VerticalAlignment.Bottom;
                textLow.HorizontalAlignment = HorizontalAlignment.Center;
            }
        }

I can get the text to appear in both backtest and the automate window of the chart, but not in the actual trading window,

 

Snip from a trading chart showing no text drawn.

Snip from the chart in automating which shows the text on the chart.

 

Can anyone explain why the text does not appear on the trading chart?  The code is in cAlgo, not cIndicator.

Thanks


@ctid1412177
Replies

PanagiotisCharalampous
29 Jun 2020, 12:46

Hi ctid1412177,

Can you please post the complete indicator code?

Best Regards,

Panagiotis 

Join us on Telegram

 


@PanagiotisCharalampous

ctid1412177
29 Jun 2020, 13:02

RE:

PanagiotisCharalampous said:

Hi ctid1412177,

Can you please post the complete indicator code?

Best Regards,

Panagiotis 

Join us on Telegram

 

Hi - This isn't an indicator, I am adding text to a chart which is being run on cAlgo.


@ctid1412177

PanagiotisCharalampous
29 Jun 2020, 14:38

Hi ctid1412177,

Then the compete cBot code :) ? We need something that is plug and play so that we can reproduce this behavior.

Best Regards,

Panagiotis 

Join us on Telegram


@PanagiotisCharalampous