This is the function I am using and it appears as in the attached image.
//+------------------------------------------------------------------+ void Disp_Symbol(string objname, int index, string symb, color col, double value) { int TxtSize = 8; string font = "Arial Black"; string dText = ""; if (ObjectFind(objname) < 0) { dText = " " + symb + " " + DoubleToString(value, 4); ObjectCreate(objname, OBJ_TEXT, index, Time[0], value + 0.001); ObjectSetText(objname, dText, TxtSize, font, col); } else { dText = " " + symb + " " + DoubleToString(value, 4); ObjectSet(objname, OBJPROP_TIME1, Time[0]); ObjectSet(objname, OBJPROP_PRICE1, value + 0.001); ObjectSetText(objname, dText, TxtSize, font, col); } } //+------------------------------------------------------------------+
Hi, using your hack of " " the text get correctly shifted to the right but it cuts out informations I have to display. Such as, instead of "Some text 1", it display "Some te".
Any other solutions?
Edit: for example:
ObjectCreate(name,OBJ_TEXT,index,iTime(0,0,-100),array[index]); ObjectSetText(name,text,12,"Arial",m_col);
Does not works because MT4 consider any time in the future as "-1"... Is really no other way to move text object on a x value in the future?
My other indicator shows longer text with no problem.
Can you display it in the following way?
dText = " " + "Some" + " " + "text" + " " + "1";
Hello , for bars that go <0 use Time[0]+(Bar*(-1))*PeriodSeconds() otherwise just Time[bar]
void place_text(double price, int bar, string name,string text, int fontsize, color text_color, ENUM_ANCHOR_POINT anchor, bool selectable, bool back){ datetime time=0; if(bar<0){time=Time[0]+PeriodSeconds()*(-1*bar);}else{ time=Time[bar]; } ObjectCreate(ChartID(),name,OBJ_TEXT,0,time,price); ObjectSetInteger(ChartID(),name,OBJPROP_FONTSIZE,fontsize); ObjectSetInteger(ChartID(),name,OBJPROP_COLOR,text_color); ObjectSetInteger(ChartID(),name,OBJPROP_ANCHOR,anchor); ObjectSetInteger(ChartID(),name,OBJPROP_SELECTABLE,selectable); ObjectSetInteger(ChartID(),name,OBJPROP_BACK,back); ObjectSetString(ChartID(),name,OBJPROP_TEXT,text); }
Hello , for bars that go <0 use Time[0]+(Bar*(-1))*PeriodSeconds() otherwise just Time[bar]
Hello, thank's.
Am I doing something wring? Nothing get plotted
for(int iBar = Bars-1-MathMax(lookback, prev_calculated); iBar >= 0; --iBar) { string str = StringConcatenate("1"," - ",DoubleToString(buff_dc_hh[iBar]-buff_dc_ll[iBar],5)); place_text(buff_dc_hh[iBar],iBar,"hh",str,10,clrWhite,ANCHOR_RIGHT_UPPER,false,false); } return rates_total-1; // Recalculate current bar next tick. // Return value of prev_calculated for next call }; void place_text(double price, int bar, string name,string text, int fontsize, color text_color, ENUM_ANCHOR_POINT anchor, bool selectable, bool back){ datetime time=0; time=Time[0]+(bar*(-1))*PeriodSeconds(); ObjectCreate(ChartID(),name,OBJ_TEXT,0,time,price); ObjectSetInteger(ChartID(),name,OBJPROP_FONTSIZE,fontsize); ObjectSetInteger(ChartID(),name,OBJPROP_COLOR,text_color); ObjectSetInteger(ChartID(),name,OBJPROP_ANCHOR,anchor); ObjectSetInteger(ChartID(),name,OBJPROP_SELECTABLE,selectable); ObjectSetInteger(ChartID(),name,OBJPROP_BACK,back); ObjectSetString(ChartID(),name,OBJPROP_TEXT,text); }
To get the effect like in the screenshot you shared you will need to have your text at a fixed distance from the latest bar [0] so don't send iBar in the bar but -5 (for a distance of -5 bars to the right) and also don't update it on every bar of the past which is redundant.
if(iBar==0){ place_text(buff_dc_hh[iBar],-5,"hh",str,10,clrWhite,ANCHOR_RIGHT_UPPER,false,false); }
To get the effect like in the screenshot you shared you will need to have your text at a fixed distance from the latest bar [0] so don't send iBar in the bar but -5 (for a distance of -5 bars to the right) and also don't update it on every bar of the past which is redundant.
Hello, thank's so much for your help!!!

- 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 everyone, currently I'm using a lable but I would like to achieve the same result with a text object because label keeps refreshing when I move the chart.
Here's desired outcome:
The text basically have the same price coordinates of the white lines, here's the code:
When I try to convert this into a text object I do:
But it does not works. Could someone point me out what I0m doing wrong? Thank's.