CLabel moves when rescaling or resizing window chart

Pedro Sanchez
39

I am using some CLabel insrtances in my EA and, while they work fine, I have not been able to make them stay in the desired time/price position when I re scale the chart o resize the chart window.

I have been checking the CORNER and ANCHOR attributes but not sure if this is what I am looking for.

Any help will be appreciated.

Keith Watford
Moderator
35509
Pedro Sanchez:

I am using some CLabel insrtances in my EA and, while they work fine, I have not been able to make them stay in the desired time/price position when I re scale the chart o resize the chart window.

I have been checking the CORNER and ANCHOR attributes but not sure if this is what I am looking for.

Any help will be appreciated.

I don't use CLabel but a label is anchored by pixels, not time and price so you should probably use a text object.

Pedro Sanchez
39
Pedro Sanchez  
Keith Watford #:

I don't use CLabel but a label is anchored by pixels, not time and price so you should probably use a text object.

Yes but to correctly place a label where you need, sometimes you can reference price, time, is not something unusual. You can easily get x y from desired price time

See here: ChartTimePriceToXY

So, now that I have the label where I need to, I want it to stay.

Pedro Sanchez
39
Pedro Sanchez  
OK solved by listening to CHARTEVENT_CHANGE and redrawing labels accordingly.
Keith Watford
Moderator
35509
Pedro Sanchez #:

Yes but to correctly place a label where you need, sometimes you can reference price, time, is not something unusual. You can easily get x y from desired price time

See here: ChartTimePriceToXY

So, now that I have the label where I need to, I want it to stay.

Why are you lecturing me?

Yes, I know about  ChartTimePriceToXY, I have used it often enough.

Still it makes no sense to me to use a label if you want to anchor it to price and time. A text object will stay anchored to the price and time no matter how the chart scale is changed.

ChartTimePriceToXY - Chart Operations - MQL4 Reference
ChartTimePriceToXY - Chart Operations - MQL4 Reference
  • docs.mql4.com
ChartTimePriceToXY - Chart Operations - MQL4 Reference