Idea for better price line indicator MT5 help
- [WARNING CLOSED!] Any newbie question, so as not to clutter up the forum. Professionals, don't go by. Can't go anywhere without you.
- Coding help
- need help adding a label to indicator
How do you know it would be easy enough, if you don't know how to do it?
How do you know it would be easy enough, if you don't know how to do it?
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); }
Yeah, it's pretty easy...
MUCH LOVE FOR THIS!!!!!!!!!!!!!!!!!!!!!
Thank you
Yeah, it's pretty easy...
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.