OBJPROP_ARROWCODE problem

 
Hello All, first post :)

I have an indicator that writes new arrows to a csv:
if(id==CHARTEVENT_OBJECT_CREATE)
{

Print("object created");
string fname="WRITE2CSV_"+Symbol()+".csv";
int handle=FileOpen(fname,FILE_CSV|FILE_WRITE|FILE_READ|FILE_SHARE_WRITE|FILE_SHARE_READ,";");
Print(sparam);

int arrow_code=ObjectGetInteger(ChartID(),sparam,OBJPROP_ARROWCODE);
Print(arrow_code);
FileWrite(handle,arrow_code);
FileClose(handle);
With manually drawn arrows it prints perfectly,

but when I use this script to draw:
void OnStart()
  {
  
  datetime time=TimeCurrent();
  string name="arrow"+TimeToString(time);
  double value = Ask;
  
   ObjectCreate(ChartID(),name,OBJ_ARROW,0,time,value);
   ObjectSetInteger(NULL,name,OBJPROP_ARROWCODE,233);
   Print(GetLastError());
   
   }
   
  }
the indicator prints a correct name(sparam) but an incorrect arrow_code(from previous manual arrow) :(



I don't know what causes this, can you see my mistake?
 
void OnStart()
  {
  
  datetime time=TimeCurrent();
  string name="arrow"+TimeToString(time);
  double value = Ask;
  
   int arrow_code=233;
   ObjectCreate(ChartID(),name,OBJ_ARROW,0,time,value);
   ObjectSetInteger(NULL,name,OBJPROP_ARROWCODE,arrow_code);
   Print(GetLastError());
   
   }
   
  }
 
Thank you for your good will!  The code is correct (the arrow created is with a correct code on chart), but the print is wrong, so I guess the problem is with the indicator.
 
noblista:
  but the print is wrong

Not sure what you mean by "the print is wrong," but you may need to add this if you are getting an error code you aren't expecting.

https://docs.mql4.com/common/resetlasterror

 
Thank you, will look into it :) I mean that while the print output is good for manual arrows, it works strange (outputs last manual arrow code) for arrows made with a script, even though they have correct codes on chart.
 
noblista:
Hello All, first post :)

I have an indicator that writes new arrows to a csv:
With manually drawn arrows it prints perfectly,

but when I use this script to draw:
the indicator prints a correct name(sparam) but an incorrect arrow_code(from previous manual arrow) :(



I don't know what causes this, can you see my mistake?

hi really i didn't understood what you need correctly but as i understood you want to print your arrow values... you should use this to call arrow price like this code:

double arr_price=ObjectGetDouble(0,"arrow",OBJPROP_PRICE,0);
Print(arr_price);
 
Abdullah Alrai:

hi really i didn't understood what you need correctly but as i understood you want to print your arrow values... you should use this to call arrow price like this code:

Hello Abdullah, thank you for your answear :) the problem is that the objectgetinteger works only for the arrows I draw manually - when I use a script to draw, it does not get the arrowcode from the chart (instead it gives arrowcode for the last arrow drew manually)
 
noblista:
Hello Abdullah, thank you for your answear :) the problem is that the objectgetinteger works only for the arrows I draw manually - when I use a script to draw, it does not get the arrowcode from the chart (instead it gives arrowcode for the last arrow drew manually)

ah ok then try this counter to use it inside your code...


   int obj_total=ObjectsTotal(0,-1,-1);
   string name;
   for(int i=obj_total; i>=0; i--)
     {
      name=ObjectName(0,i,-1,-1);
      if(ObjectGetInteger(0,name,OBJPROP_TYPE)==OBJ_ARROW)
        {
         //here you can put array and fill it with arrows codes...
        }
     }
 
Abdullah Alrai:

ah ok then try this counter to use it inside your code...


or u can do that without array if you just want to print :

   int obj_total=ObjectsTotal(0,-1,-1);
   string name;
   for(int i=obj_total; i>=0; i--)
     {
      name=ObjectName(0,i,-1,-1);
      if(ObjectGetInteger(0,name,OBJPROP_TYPE)==OBJ_ARROW)
        {
         int arrow_code=ObjectGetInteger(ChartID(),name,OBJPROP_ARROWCODE);
         Print(arrow_code);
        }
     }
 
Abdullah Alrai:

or u can do that without array if you just want to print :

Your code has really helped a lot :) I see now where was the problem - the indi performed objectgetinteger before the script performed objectsetinteger :p thats why on the chart the arrow was correct, but not for the indi. I have to slow the indi a little then. Thank you very much!
 
noblista:
Your code has really helped a lot :) I see now where was the problem - the indi performed objectgetinteger before the script performed objectsetinteger :p thats why on the chart the arrow was correct, but not for the indi. I have to slow the indi a little then. Thank you very much!

you welcome >>>>

Reason: