if (ObjectFind(...)...) //first ObjectDelete(...); //& then ObjectCreate(...);
Can you attach your histogramtrend Indicator as a file and I'll test . .
I modified your Functions . . . if the object exists and you try to create it again you will get an error . . . check your Experts tab . . . if you get an error the ObjectSet doesn't happen so nothing changes . . .
int CreerObjet(string label_name,double value_name,int distance_X,int distance_Y,color name_textcolor) { int obj_total = ObjectsTotal(); if (ObjectFind(label_name) < 0) // <---- added, only create the object if it doesn't exist if(!ObjectCreate(label_name,OBJ_LABEL,0,0,0)) { Print("error: can't create label_object! code #",GetLastError()); return(0); } // else // { // I create label // ObjectCreate (label_name,OBJ_LABEL,0,Time[0],0); // I change the value ObjectSetText(label_name,DoubleToStr(value_name,5),16,"Arial"); // it's position ObjectSet(label_name,OBJPROP_CORNER,0); ObjectSet(label_name,OBJPROP_XDISTANCE,distance_X); ObjectSet(label_name,OBJPROP_YDISTANCE,distance_Y); if(value_name<0) name_textcolor=Red; else if (value_name>0) name_textcolor=Lime; else if (value_name==0) name_textcolor=Gold; ObjectSet(label_name, OBJPROP_COLOR, name_textcolor ); WindowRedraw(); return (1); // } } // int CreerLabel (string label_name,string vrai_nom ,int distance_X,int distance_Y,color name_textcolor) { int obj_total = ObjectsTotal(); if (ObjectFind(label_name) < 0) // <---- added, only create the object if it doesn't exist if(!ObjectCreate(label_name,OBJ_LABEL,0,0,0)) { Print("error: can't create label_object! code #",GetLastError()); return(0); } // else // { ObjectSetText(label_name,vrai_nom,16,"Arial",name_textcolor); ObjectSet(label_name,OBJPROP_CORNER,0); ObjectSet(label_name,OBJPROP_XDISTANCE,distance_X); ObjectSet(label_name,OBJPROP_YDISTANCE,distance_Y); WindowRedraw(); return(1); // } }
qjol:
Or my pattern: if(!ObjectMove(...) ObjectCreate(...)if (ObjectFind(...)...) //first ObjectDelete(...); //& then ObjectCreate(...);
void TLine( string name, datetime T0, double P0, datetime T1, double P1 , color clr, bool ray=false ){ #define WINDOW_MAIN 0 if (!Show.Objects) return; if (ObjectMove( name, 0, T0, P0 )) ObjectMove(name, 1, T1, P1); else if (!ObjectCreate( name, OBJ_TREND, WINDOW_MAIN, T0, P0, T1, P1 )) Alert("ObjectCreate(",name,",TREND) failed: ", GetLastError() ); else if (!ObjectSet( name, OBJPROP_RAY, ray )) Alert("ObjectSet(", name, ",Ray) failed: ", GetLastError()); if (!ObjectSet(name, OBJPROP_COLOR, clr )) // Allow color change Alert("ObjectSet(", name, ",Color) [2] failed: ", GetLastError()); string P0t = PriceToStr(P0); if (MathAbs(P0 - P1) >= Point) P0t = StringConcatenate(P0t, " to ", PriceToStr(P1)); if (!ObjectSetText(name, P0t, 10)) Alert("ObjectSetText(",name,") [2] failed: ", GetLastError()); }
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hello ;
the indicator that I create is to indicate if line 1 > line 2 or line 2 > line 1 for all time frame : as you can see on the picture I would like to know if black line crosses over the red one (the indicator on down ) or not : and I calculate the difference :
so I must call this indicator that I call histogramtrend on my new indicator (left on the top )
so the problem is when the value of black and red line changes the indicator on the top with Label doesn't do the same I write the code just for one period in order to show you what 's the problem
so probably the problem is on the function CreerObjet () because he can't to update the value when the the red and black line change
so my last remark is when I delete the indicator and when I insert it again, the value change .
thanks for your answer