How to get time and price coordinate on a chart?

 

I am using the following methods to get current time and price coordinate of a chart.


datetime time1 = (datetime)ObjectGetInteger(0, "angle", OBJPROP_TIME);

double price1 = ObjectGetDouble(0, "angle", OBJPROP_PRICE);
Print(time1);
Print(price1);

But I am always getting

time is  1970.01.01 00:00:00

price is 0.0

Documentation on MQL5: Date and Time / TimeCurrent
Documentation on MQL5: Date and Time / TimeCurrent
  • www.mql5.com
TimeCurrent - Date and Time - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 
nyanmt4:

I am using the following methods to get current time and price coordinate of a chart.


But I am always getting

time is  1970.01.01 00:00:00

price is 0.0

if its mt5 you need a modifier after the OBJPROP_TIME and OBJPROP_PRICE , like 1, 2 etc

ObjectGetInteger(0,"angle",OBJPROP_TIME,1);
Also you can edit a post instead of re posting it :)
 
Lorentzos Roussos #:

if its mt5 you need a modifier after the OBJPROP_TIME and OBJPROP_PRICE , like 1, 2 etc

But it is still getting the same values.

 
Lorentzos Roussos #:

if its mt5 you need a modifier after the OBJPROP_TIME and OBJPROP_PRICE , like 1, 2 etc

Also you can edit a post instead of re posting it :)

Yeah thanks. I am new to this site so still trying to familiar with tools.

 
nyanmt4 #:

But it is still getting the same values.

hmmm, its a trendline object ?

 

I am implementing this in OnTick().


void OnTick()

{

    if(angleCounter == 0)

    {

      time1 = (datetime)ObjectGetInteger(0, "angle", OBJPROP_TIME,1);

      price1 = ObjectGetDouble(0, "angle", OBJPROP_PRICE,1);

      Print("time1");

      Print(time1);

      Print(price1);

   }

   if(angleCounter >= 10){

      time2 = (datetime)ObjectGetInteger(0, "angle", OBJPROP_TIME,2);

      price2 = ObjectGetDouble(0, "angle", OBJPROP_PRICE,2);

      //angle = GetAngle();

      Print("time2");

      Print(time2);

      Print(price2);

      angleCounter = -1;

   }
   angleCounter++;   

}
 
nyanmt4 #:

I am implementing this in OnTick().


What type of an object is the "angle" ? 

 
angle is double
 
nyanmt4 #:
angle is double

okay and how are you determining the angle counter 

You want to create an animation ?
 

anglecounter starts from 0 and get time1 and price1.

Once reach to 10, get one more time2 and price2. then reset anglecounter to 0.

No I am going to compute trend angle.

 
nyanmt4 #:

anglecounter starts from 0 and get time1 and price1.

Once reach to 10, get one more time2 and price2. then reset anglecounter to 0.

No I am going to compute trend angle.

And there is a trendline drawn on the chart or you want to create one ?

Reason: