Chart text that updates automatically as price changes?

 

Hi

Forgive me but I'm new to MQL4 and need to know how you can place a text label on a chart that automatically updates as the price changes.

For example, if you had a low time frame price channel on a chart that was changing pretty much constantly, how do you associate a text label with it?

A brief example would be helpful.

I assume the only way to do it is using an object but will this update automatically? https://docs.mql4.com/objects/objectsettext

Thanks

Rob

Graphical Objects - Standard Functions - MQL4 Tutorial
Graphical Objects - Standard Functions - MQL4 Tutorial
  • book.mql4.com
Graphical object is an image in the symbol window; it can be selected, moved, modified or deleted. Graphical objects include, for example, horizontal and vertical lines, linear regression channel, Fibonacci levels, rectangle, text mark, etc. Such images as indicator lines, indicator levels, candlesticks, comments written by the Comment...
 
robdav: d need to know how you can place a text label on a chart that automatically updates as the price changes.
  1. Don't use words you don't understand. There is no such thing as a "text label." There are text objects, label objects, and Comment. All different.
  2. None of them "automatically updates." If you want it changing, you must update them.
 
robdav:

Hi

Forgive me but I'm new to MQL4 and need to know how you can place a text label on a chart that automatically updates as the price changes.

For example, if you had a low time frame price channel on a chart that was changing pretty much constantly, how do you associate a text label with it?

A brief example would be helpful.

I assume the only way to do it is using an object but will this update automatically? https://docs.mql4.com/objects/objectsettext

Thanks

Rob


Hope this helps...

//+------------------------------------------------------------------+
//|                                            UpdatingTextLabel.mq4 |
//|                                      Copyright 2017, nicholishen |
//|                         https://www.forexfactory.com/nicholishen |
//+------------------------------------------------------------------+
#property copyright "Copyright 2017, nicholishen"
#property link      "https://www.forexfactory.com/nicholishen"
#property version   "1.00"
#property strict
#property indicator_chart_window
#include <ChartObjects\ChartObjectsTxtControls.mqh>

CChartObjectText text_label;
//+------------------------------------------------------------------+
int OnInit()
{
   text_label.Create(0,"text_label",0,0,0.0);
   text_label.Anchor(ANCHOR_RIGHT_LOWER);
   text_label.Color(clrLime);
   text_label.FontSize(20);
   return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
int start()
{
   text_label.Time(0,TimeCurrent());
   text_label.Price(0,Bid);
   text_label.Description(DoubleToString(Bid,_Digits));
   return 0;
}
//+------------------------------------------------------------------+
 

for price only, you can use the arrow object with code 6.
The price will be displayed automatically.

ObjectCreate(0,name,OBJ_ARROW,0,time,price);
ObjectSetInteger(0,name,OBJPROP_ARROWCODE, 6);
Reason: