Hello
Assume an arrow (draw type) buffer in an indicator.
The arrow is drawn by placing the center of the character at the specified time at the price in the buffer.
The PLOT_ARROW_SHIFT value that shifts arrows up or down in a plot is specified in pixels while the size of the arrow in the arrow buffer is specified as width (1,2,3) etc which
does not seem to be a font size.
Is it possible to calculate the size of the characters given the width of the arrow code so that the shift applied can move the arrow to have its top on the buffer price or its bottom.
Thank you
Image for reference
In the image : the enumerated arrows have their center at the line of the buffer ,
need to find their pixel size as the PLOT_ARROW_SHIFT is specified in pixels and not the width units used to
determine the size of a character.
Thanks.
I'm thinking that ObjectGetInteger() used with OBJPROP_WIDTH holds the answer... or half of it anyway.

- www.mql5.com
This is not about Graphical Objects. It is about an indicator plot of the "arrow" type, not a Graphical Object. Please don't confuse the two.
I'm thinking that ObjectGetInteger() used with OBJPROP_WIDTH holds the answer... or half of it anyway.
This is not about Graphical Objects. It is about an indicator plot of the "arrow" type, not a Graphical Object. Please don't confuse the two.
Yeah exactly.
And we cant query the font size either from what i gather
I have a feeling you're asking because of the fact that the arrow shift on one timeframe tends to be moot when toggling to another timeframe. You could try a dynamic offset for PLOT_ARROW_SHIFT instead of a static number. I did this in a few codes, for example have a look:
Conor Mcnamara, 2024.08.11 01:31
A customized bid and ask line which is labelled and clear to help visualize the bid and ask prices
in this code the "Ask" text is always made to be above the line regardless of the timeframe because it scales the range from chart price max to chart price min
Regarding the question, I don't think drawing type sizes and neither font sizes can be translated to help with offsets
Post edited by moderator. Instead of links to CodeBase and Articles, consider using the "pocket" feature instead.
I have a feeling you're asking because of the fact that the arrow shift on one timeframe tends to be moot when toggling to another timeframe. You could try a dynamic offset for PLOT_ARROW_SHIFT instead of a static number. I did this in a few codes, for example have a look:
in this code the "Ask" text is always made to be above the line regardless of the timeframe because it scales the range from chart price max to chart price min
Regarding the question, I don't think drawing type sizes and neither font sizes can be translated to help with offsets
Post edited by moderator. Instead of links to CodeBase and Articles, consider using the "pocket" feature instead.
So the 8 size font is 0.036 of the y axis in size ?
In indicator arrow buffers we don't specify a font size but a "width"
I'll try the 3.6% assuming 8 is the default size.
(so the offset tested will be (((MaxPrice-MinPrice)*0.036)*width_of_arrow_buffer)/2.0 ) division by 2 because the arrows are centeredIt works for width 1 but not when you scale up.
#property indicator_chart_window #define factor 0.036 input int arrow_width=1; double ANCHOR_OFFSET_PRICE=0.0; void calculate_offset(int width){ ResetLastError(); int errors=0; double max=(double)ChartGetDouble(0,CHART_PRICE_MAX,0);errors+=GetLastError();ResetLastError(); double min=(double)ChartGetDouble(0,CHART_FIXED_MIN,0);errors+=GetLastError();ResetLastError(); if(errors==0){ ANCHOR_OFFSET_PRICE=NormalizeDouble((((max-min)*factor)*((double)width))/2.0,_Digits); }} double test_buffer[]; int OnInit() { calculate_offset(arrow_width); SetIndexBuffer(0,test_buffer,INDICATOR_DATA); PlotIndexSetInteger(0,PLOT_DRAW_TYPE,DRAW_ARROW); PlotIndexSetInteger(0,PLOT_ARROW,140); PlotIndexSetInteger(0,PLOT_LINE_COLOR,clrYellow); PlotIndexSetInteger(0,PLOT_LINE_WIDTH,arrow_width); PlotIndexSetDouble(0,PLOT_EMPTY_VALUE,0.0); return(INIT_SUCCEEDED); } int OnCalculate(const int rates_total, const int prev_calculated, const datetime &time[], const double &open[], const double &high[], const double &low[], const double &close[], const long &tick_volume[], const long &volume[], const int &spread[]) { if(ANCHOR_OFFSET_PRICE==0.0){calculate_offset(arrow_width);} for(int i=prev_calculated;i<rates_total;i++){ test_buffer[i]=high[i]+ANCHOR_OFFSET_PRICE; } return(rates_total); }
So the 8 size font is 0.036 of the y axis in size ?
In indicator arrow buffers we don't specify a font size but a "width"
I'll try the 3.6% assuming 8 is the default size.
(so the offset tested will be (((MaxPrice-MinPrice)*0.036)*width_of_arrow_buffer)/2.0 ) division by 2 because the arrows are centeredthe 3.6% was actually just chosen that time through trial and error, because it basically looked good, so you anything under 5% for the factor seems to work for very small offsets I found
but instead of using the result for arrow width, I meant that you can use it for the arrow shift in this kind of way:
PlotIndexSetInteger(0, PLOT_ARROW, 236); PlotIndexSetInteger(0, PLOT_ARROW_SHIFT, -(10 + dynamic_offset)); // shift with dynamic offset over the candle highs PlotIndexSetInteger(1, PLOT_ARROW, 238); PlotIndexSetInteger(1, PLOT_ARROW_SHIFT, (10 + dynamic_offset)); //shift with dynamic offset under the candle lowsmy point is to disregard the arrow width property entirely and focus on trial and error for what simply looks right for the arrow shift

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello
Assume an arrow (draw type) buffer in an indicator.
The arrow is drawn by placing the center of the character at the specified time at the price in the buffer.
The PLOT_ARROW_SHIFT value that shifts arrows up or down in a plot is specified in pixels while the size of the arrow in the arrow buffer is specified as width (1,2,3) etc which
does not seem to be a font size.
Is it possible to calculate the size of the characters given the width of the arrow code so that the shift applied can move the arrow to have its top on the buffer price or its bottom.
Thank you
Image for reference
In the image : the enumerated arrows have their center at the line of the buffer ,
need to find their pixel size as the PLOT_ARROW_SHIFT is specified in pixels and not the width units used to
determine the size of a character.
Thanks.