Chart.DrawText problems, need some help

Created at 23 Aug 2023, 12:14
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!
JXTA's avatar

JXTA

Joined 23.08.2023

Chart.DrawText problems, need some help
23 Aug 2023, 12:14


I have searched through the whole internet about how to align Chart.DrawText like the picture1 below and yet I got zero answer,

 

 

this is my code

…..

 

//Initialize
        protected override void Initialize()
        {

            isFB = false;

        }

 

//Calculating
        public override void Calculate(int index)
        {

            // Calculate FB

            bool isFBCondition = *all of the calculation………*

            isFB = isFBCondition;

 

            //FB Signal

               if ( isFB )
                           {
                               string textFB = "▲";
                               double yFB = Bars.LowPrices[index] - Symbol.PipSize * 30; 
                               Color colorFB = Color.Yellow
                               Chart.DrawText("FB_Signal" + index, textFB, index, yFB, colorFB);
                           }

        }

…..

as you can see my arrow is not aligned to the center of the bar where it should be, could anyone help me to fix this?


 


@JXTA
Replies

PanagiotisChar
24 Aug 2023, 05:24 ( Updated at: 24 Aug 2023, 05:25 )

Hi there,

Better share the complete indicator code so if there is a bug, Spotware can fix it.

Aieden Technologies

Need help? Join us on Telegram


 


@PanagiotisChar

firemyst
27 Aug 2023, 15:26

You need to do something like this:

                    ChartText ct = Chart.DrawText("FB_Signal" + index, textFB, index, yFB, colorFB);
                    ct.VerticalAlignment = VerticalAlignment.Center;
                    ct.HorizontalAlignment = HorizontalAlignment.Left;

Play wit the Vertical and Horizontal alignments.


@firemyst