How to read object value

Cromo
393
Cromo  

Hi,

I want to read Trend line value (price)

Below Trend line Name has some time value(time stamp).

But I want to ignore the time stamp and just want to read the 2nd value.

How can I read the Object price2?


  double price2 = ObjectGet( "LINE12", OBJPROP_PRICE2 );


Paul Anscombe
6053
Paul Anscombe  
Cromo:

Hi,

I want to read Trend line value (price)

Below Trend line Name has some time value(time stamp).

But I want to ignore the time stamp and just want to read the 2nd value.

How can I read the Object price2?



Use ObjectGetDouble  to read the anchor points 

https://docs.mql4.com/objects/objectgetdouble

ObjectGetDouble - Object Functions - MQL4 Reference
ObjectGetDouble - Object Functions - MQL4 Reference
  • docs.mql4.com
ObjectGetDouble - Object Functions - MQL4 Reference
Mehmet Bastem
2427
Mehmet Bastem  
Cromo:

Hi,

I want to read Trend line value (price)

Below Trend line Name has some time value(time stamp).

But I want to ignore the time stamp and just want to read the 2nd value.

How can I read the Object price2?




@ Cromo

dasd

void OnReadObj()
  {
//---
   int     total; 
  string obj_name; 
  double obj_PriceStart=0;
  double obj_PriceEnd=0;
  
  
     total=ObjectsTotal();
     for(int i=0;i<total;i++)
       {
       obj_name=ObjectName(i);
        if(ObjectType( obj_name)==OBJ_TREND)
        {
         
        obj_PriceStart=NormalizeDouble(ObjectGet(obj_name, OBJPROP_PRICE1),Digits);
        obj_PriceEnd=NormalizeDouble(ObjectGet(obj_name, OBJPROP_PRICE2),Digits);
        
        Print("Obj Name ",obj_name," Start Price=",obj_PriceStart," End Price=",obj_PriceEnd);
        
         
        }
        
       
      
       } 
 }    
Cromo
Cromo
  • 2021.03.15
  • www.mql5.com
Trader's profile
Cromo
393
Cromo  
Paul Anscombe:

Use ObjectGetDouble  to read the anchor points 

https://docs.mql4.com/objects/objectgetdouble

     double price = ObjectSetDouble(ChartID(), "LINE12-***", OBJPROP_PRICE, 0);

 Can I use ****  after LINE12- ?

Cromo
393
Cromo  
Mehmet Bastem:


@ Cromo


Bastem, thanks.

But if I scan all object, how can I get the newest object price?

because there are many same kind of objects on the chart.

Mehmet Bastem
2427
Mehmet Bastem  
Cromo:

 Can I use ****  after LINE12- ?

oid OnReadObj()
  {
//---
   int     total; 
  string obj_name; 
  double obj_PriceStart=0;
  double obj_PriceEnd=0;
  string SearchStringName="LINE12-";
  
  
     total=ObjectsTotal();
     for(int i=0;i<total;i++)
       {
       obj_name=ObjectName(i);
        if(ObjectType( obj_name)==OBJ_TREND &&  (StringFind(obj_name,SearchStringName,0)!=-1))
        {
         
        obj_PriceStart=NormalizeDouble(ObjectGet(obj_name, OBJPROP_PRICE1),Digits);
        obj_PriceEnd=NormalizeDouble(ObjectGet(obj_name, OBJPROP_PRICE2),Digits);
        
        Print("Obj Name ",obj_name," Start Price=",obj_PriceStart," End Price=",obj_PriceEnd);
        
         
        }
        
       
      
       } 
 }      
Cromo
393
Cromo  
Mehmet Bastem:

Bastem

Thank you very much.

I will try this.