Idea for better price line indicator MT5 help

 
Instead of using the Horisontal Line standard in MT5.

I'd love to have a, "object" price label right following BID, 

But I don't have any experience at all with this.

Thanks guys for the help. I believe this would be a huge improvement in MT5


 
Jim Nyberg:
This should be easy enough to code? But I don't have any experience at all with this.

How do you know it would be easy enough, if you don't know how to do it?

 
Mohamad Zulhairi Baba:

How do you know it would be easy enough, if you don't know how to do it?

I don't....
 

Yeah, it's pretty easy...


#property indicator_chart_window

#include <charts/chart.mqh>
#include <chartobjects/chartobjectsarrows.mqh>

CChart g_chart;
CChartObjectArrowRightPrice g_bid;

int OnInit()
{
   g_chart.Attach();
   g_chart.ShowLineAsk(false);
   g_chart.ShowLineBid(false);
   g_bid.Create(0, "__bid", 0, 0, 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[])
{
   static double last_price = 0.0;
   int i = rates_total - 1;
   double bid = close[i];
   g_bid.Time(0, time[i]);
   g_bid.Price(0, bid);  
   if(bid > last_price) 
      g_bid.Color(clrDodgerBlue);
   else if(bid < last_price)
      g_bid.Color(clrRed);
   last_price = bid;
   return(rates_total);
}
 
nicholi shen:

Yeah, it's pretty easy...


MUCH LOVE FOR THIS!!!!!!!!!!!!!!!!!!!!!


Thank you

 
nicholi shen:

Yeah, it's pretty easy...


Any idea why when switching timeframes it closes the chart?

 
Jim Nyberg:

Any idea why when switching timeframes it closes the chart?

Yes, CChart closes the chart when destroyed. If you don't want it to close then you should use the Detach method. 

 
nicholi shen:

Yes, CChart closes the chart when destroyed. If you don't want it to close then you should use the Detach method. 

Oh..  thanks.  I'll have to figure that out then 🤣