Solution way:
- Create an indicator that draws a vertical line on the last bar
- Put this indicator on the chart and save it as a chart template (for example, set the name 'VLine.tpl')
- Create a chart in a loop (ChartOpen) and add a template (ChartApplyTemplate) to the chart
Or the second option - create a custom indicator 'Vertical Line Last Bar' (it is located in my [data folder]\MQL5\Indicators\MyInd\OBJ_VLINE\Vertical Line Last Bar.mq5 folder). And in the indicator we very carefully create new charts: we MUST get and use the RECEIVED chart ID:
//+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ 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[]) { //--- we work only at the time of the birth of new bar datetime time_0=time[rates_total-1]; if(time_0==m_prev_bars) return(rates_total); m_prev_bars=time_0; //--- long chart_ID=ChartID(); string charts_symbol=ChartSymbol(chart_ID); Print("ChartID: ",chart_ID,", ChartSymbol: ",charts_symbol); if(ObjectFind(chart_ID,InpName)<0) if(!VLineCreate(chart_ID,InpName)) { m_prev_bars=0; return(rates_total); } VLineMove(chart_ID,InpName,time[rates_total-1]); //--- return value of prev_calculated for next call return(rates_total); }

Step on New Rails: Custom Indicators in MQL5
- www.mql5.com
Finally we've got an opportunity to try the new trade terminal - MetaTrader 5 . No doubt, it is noteworthy and has many new features as compared to its predecessor. The important advantages of this platform among others are: Essentially modified language allowing now to use the object-oriented programming, still allowing to use the rich...
Files:
TEST11.mq5
6 kb
Vladimir Karputov:
Or the second option - create a custom indicator 'Vertical Line Last Bar' (it is located in my [data folder]\MQL5\Indicators\MyInd\OBJ_VLINE\Vertical Line Last Bar.mq5 folder). And in the indicator we very carefully create new charts: we MUST get and use the RECEIVED chart ID:
thank you for help.
i used the 1st solution. create a template and add it to the chart. it worked .

You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hi every one. please help me with this surprising indicator.
this is a simple indicator with one input parameter.
if you add it to chart it draw a vertical line on last bar and set name equal to symbol name.
there is a Boolean parameter that when i set to true i want it open all symbols in market watch and by using iCustom() tries to add new example of itself as indicator to new opened chart.
it open all charts in market watch and even add indicator to them( you can see it in indicator list) BUT the problem is that new opened chart dont show any thing. there is noting in objectlist of new opened chart.
Now, lets talk about surprising point
whisper magic words for 3 times.... boo0000000om
All objects draw on main chart
could any body explain how is this possible????
am i wrong or its a bug?