I have a OBJ_FIBO on chart which is drawn
If i get its price value using ObjGetInteger, it returns price but when i delete the object, it does not show any value such as 0
if i use ObjectFind its also not returning any thing
so how can i know if the OBJ_FIBO is deleted from chart?
ObjectDelete() returns true if the object is deleted so you could check for that at the time of deletion.
ObjectFind() - the documentation says "If the object is not found, the function returns a negative number." - is that what you are getting?
If you want to do another check, your could try to read a property, for example ObjectGetString() - have a look at https://www.mql5.com/en/docs/objects/objectgetstring
- www.mql5.com
I have a OBJ_FIBO on chart which is drawn
If i get its price value using ObjGetInteger, it returns price but when i delete the object, it does not show any value such as 0
if i use ObjectFind its also not returning any thing
so how can i know if the OBJ_FIBO is deleted from chart?
Check documentation. ObjectFind returns the index of the subwindow where it is found, if the return is less than 0 then there is no object with such name.
- www.mql5.com
ObjectDelete() returns true if the object is deleted so you could check for that at the time of deletion.
ObjectFind() - the documentation says "If the object is not found, the function returns a negative number." - is that what you are getting?
If you want to do another check, your could try to read a property, for example ObjectGetString() - have a look at https://www.mql5.com/en/docs/objects/objectgetstring
the problem is when object is deleted it does not return anything, such as negative number.
#property copyright "Copyright 2022" #property indicator_chart_window //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- indicator buffers mapping //--- return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ 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[]) { //--- for(int j=0; j<ObjectsTotal(0,-1,-1); j++) { string n = ObjectName(0,j); if( ObjectGetInteger(0, n, OBJPROP_TYPE) == OBJ_FIBO ) { Print(n); if(ObjectFind(0,n)==-1) Print("deleted",n); } } //--- return value of prev_calculated for next call return(rates_total); }
the problem is when object is deleted it does not return anything, such as negative number.
Looking at this code, if your first if condition evaluates to be true [ObjectGetInteger...] it suggests the object exists, so the 2nd if statement [ObjectFind...] can never return -1.
As there is no else clause, one can never know the other outcome, so I suggest you put one in.
Also I note there is no ObjectDelete() - is that intentional, or is it called elsewhere?
the problem is when object is deleted it does not return anything, such as negative number.
Why you need know if the object is deleted? Do you need know that immediately after it is deleted? Why do you need check all of the objects? If the object has a proper name you don't need check all of the objects.
Looking at this code, if your first if condition evaluates to be true [ObjectGetInteger...] it suggests the object exists, so the 2nd if statement [ObjectFind...] can never return -1.
As there is no else clause, one can never know the other outcome, so I suggest you put one in.
Also I note there is no ObjectDelete() - is that intentional, or is it called elsewhere?
i am adding and deleting OBJ_FIBO Manually
Why you need know if the object is deleted? Do you need know that immediately after it is deleted? Why do you need check all of the objects? If the object has a proper name you don't need check all of the objects.
Yes i need to know immediately when i delete OBJ_FIBO from chart manually. Since i am using it for manually drawn fibonacci retracement it may have default name so need to check
any example of CHART_EVENT_OBJECT_DELETE will really help if possible, Thanks
- www.mql5.com
- www.metatrader5.com
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I have a OBJ_FIBO on chart which is drawn
If i get its price value using ObjGetInteger, it returns price but when i delete the object, it does not show any value such as 0
if i use ObjectFind its also not returning any thing
so how can i know if the OBJ_FIBO is deleted from chart?