i draw OBJ_VLINE by :
and then :
to delete it,
----------------------------------
my question is :
if i used below code , Instead of above : is this have problem ?
i check it & there is seems no problem, but Can I be sure this is correct and no error in future with growing the indicator? ( may be i used 2 index , i & j )
thank you.
What is held in the string variable label_name ?
for example :
string label_name="AO_Price_Divergence";
thank to reply.
for example :
string label_name="AO_Price_Divergence";
thank to reply.
So that is the only Object that will be deleted OnDeinit
yes;
and then :
void OnDeinit(const int reason) { for(int j=0;j<rates_total;j++) { if(ObjectFind(0,"label_name"+IntegerToString(j))>=0) ObjectDelete(0,"label_name"+IntegerToString(j)); } }can use below Instead of above ?
void OnDeinit(const int reason) { ObjectDelete(0,label_name); }
i check it & there is seems no problem, but Can I be sure this is correct and no error in future with growing the indicator? ( may be i used 2 index , i & j )
thank you.
yes;
and then :
i check it & there is seems no problem, but Can I be sure this is correct and no error in future with growing the indicator? ( may be i used 2 index , i & j )
thank you.
Of course not. Why are you thinking that 1 call to ObjectDelete will do the same that rates_total calls to it ?
What problem are you trying to solve by doing that ?
Of course not. Why are you thinking that 1 call to ObjectDelete will do the same that rates_total calls to it ?
What problem are you trying to solve by doing that ?
just for simple that . if any object has same equal part in name, then delete it .( is it possible ? )
thank you.
-----------------------------------------------------------------------
i used :
.
.
TOTAL_BAR=rates_total;
.
.
//+------------------------------------------------------------------+
//| Function for drawing a trend line in the indicator window |
//+------------------------------------------------------------------+
void DrawIndicatorTrendLine(int bar,datetime x1,datetime x2,double y1,double y2,color lineColor,int style)
{
int indicatorWindow=ChartWindowFind(0,short_name); // short_name indicatorName
if(indicatorWindow<0) return;
string label="AO_Indicator_Divergence"+IntegerToString(bar)+TimeToString(x2);
if(ObjectFind(0,label)==-1)
{
ObjectCreate(0,label,OBJ_TREND,indicatorWindow,x1,y1,x2,y2);
ObjectSetInteger(0,label,OBJPROP_COLOR,lineColor);
ObjectSetInteger(0,label,OBJPROP_STYLE,style);
ObjectSetInteger(0,label,OBJPROP_WIDTH,0);
ObjectSetInteger(0,label,OBJPROP_RAY,0);
ObjectSetInteger(0,label,OBJPROP_BACK,false);
}
else
{
ObjectMove(0,label,0,x1,y1);
ObjectMove(0,label,1,x2,y2);
}
}
//----------------------------------------------------------------------------------------------------------//
//+------------------------------------------------------------------+
//| Function for drawing a trend line in a price chart window |
//+------------------------------------------------------------------+
void DrawPriceTrendLine(int bar,datetime x1,datetime x2,double y1,double y2,color lineColor,int style)
{
string label="AO_Price_Divergence"+IntegerToString(bar)+TimeToString(x2);
if(ObjectFind(0,label)==-1)
{
ObjectCreate(0,label,OBJ_TREND,0,x1,y1,x2,y2);
ObjectSetInteger(0,label,OBJPROP_COLOR,lineColor);
ObjectSetInteger(0,label,OBJPROP_STYLE,style);
ObjectSetInteger(0,label,OBJPROP_WIDTH,0);
ObjectSetInteger(0,label,OBJPROP_RAY,0);
ObjectSetInteger(0,label,OBJPROP_BACK,false);
}
else
{
ObjectMove(0,label,0,x1,y1);
ObjectMove(0,label,1,x2,y2);
}
}
//----------------------------------------------------------------------------------------------------------//
&
void OnDeinit(const int reason)
{
Comment("");
//ObjectsDeleteAll(0,0,OBJ_ARROW);
//ObjectsDeleteAll(0,-1,OBJ_ARROW);
//ObjectsDeleteAll(0,0,OBJ_TREND);
//ObjectsDeleteAll(0,-1,OBJ_TREND);
//ObjectsDeleteAll(0);
//ObjectsDeleteAll(0,0,OBJ_VLINE);
//ObjectsDeleteAll(0,0,OBJ_RECTANGLE);
for(int j=1;j<=TOTAL_BAR;j++)
{
for(int jj=1;jj<TOTAL_BAR;jj++)
{
if(ObjectFind(0,"AO_Indicator_Divergence"+IntegerToString(j)+TimeToString(jj))>=0)
ObjectDelete(0,"AO_Indicator_Divergence"+IntegerToString(j)+TimeToString(jj));
if(ObjectFind(0,"AO_Price_Divergence"+IntegerToString(j)+TimeToString(jj))>=0)
ObjectDelete(0,"AO_Price_Divergence"+IntegerToString(j)+TimeToString(jj));
}
}
ChartRedraw();
ChartSetInteger(0,CHART_FOREGROUND,foreground);
}
there is no error or warning but on chart there is problem.
what is wrong ?
thank you.
just for simple that . if any object has same equal part in name, then delete it .( is it possible ? )
You can implement this by yourself:
1. Call ObjectsTotal to get the number of total objects on the chart.
2. Enumerate the objects and call ObjectName function to get the name of each object.
3. Compare the name of object and call ObjectDelete if its name meets your criteria.
How ever, the "equal part in name" should be more specific, otherwise you may delete objects that were created by the terminal or other programs.
- www.mql5.com
You can implement this by yourself:
1. Call ObjectsTotal to get the number of total objects on the chart.
2. Enumerate the objects and call ObjectName function to get the name of each object.
3. Compare the name of object and call ObjectDelete if its name meets your criteria.
How ever, the "equal part in name" should be more specific, otherwise you may delete objects that were created by the terminal or other programs.
What problem are you trying to solve by doing that ?
i used :
.
.
TOTAL_BAR=rates_total;
.
.
//+------------------------------------------------------------------+
//| Function for drawing a trend line in the indicator window |
//+------------------------------------------------------------------+
void DrawIndicatorTrendLine(int bar,datetime x1,datetime x2,double y1,double y2,color lineColor,int style)
{
int indicatorWindow=ChartWindowFind(0,short_name); // short_name indicatorName
if(indicatorWindow<0) return;
string label="AO_Indicator_Divergence"+IntegerToString(bar)+TimeToString(x2);
if(ObjectFind(0,label)==-1)
{
ObjectCreate(0,label,OBJ_TREND,indicatorWindow,x1,y1,x2,y2);
ObjectSetInteger(0,label,OBJPROP_COLOR,lineColor);
ObjectSetInteger(0,label,OBJPROP_STYLE,style);
ObjectSetInteger(0,label,OBJPROP_WIDTH,0);
ObjectSetInteger(0,label,OBJPROP_RAY,0);
ObjectSetInteger(0,label,OBJPROP_BACK,false);
}
else
{
ObjectMove(0,label,0,x1,y1);
ObjectMove(0,label,1,x2,y2);
}
}
//----------------------------------------------------------------------------------------------------------//
//+------------------------------------------------------------------+
//| Function for drawing a trend line in a price chart window |
//+------------------------------------------------------------------+
void DrawPriceTrendLine(int bar,datetime x1,datetime x2,double y1,double y2,color lineColor,int style)
{
string label="AO_Price_Divergence"+IntegerToString(bar)+TimeToString(x2);
if(ObjectFind(0,label)==-1)
{
ObjectCreate(0,label,OBJ_TREND,0,x1,y1,x2,y2);
ObjectSetInteger(0,label,OBJPROP_COLOR,lineColor);
ObjectSetInteger(0,label,OBJPROP_STYLE,style);
ObjectSetInteger(0,label,OBJPROP_WIDTH,0);
ObjectSetInteger(0,label,OBJPROP_RAY,0);
ObjectSetInteger(0,label,OBJPROP_BACK,false);
}
else
{
ObjectMove(0,label,0,x1,y1);
ObjectMove(0,label,1,x2,y2);
}
}
//----------------------------------------------------------------------------------------------------------//
&
void OnDeinit(const int reason)
{
Comment("");
//ObjectsDeleteAll(0,0,OBJ_ARROW);
//ObjectsDeleteAll(0,-1,OBJ_ARROW);
//ObjectsDeleteAll(0,0,OBJ_TREND);
//ObjectsDeleteAll(0,-1,OBJ_TREND);
//ObjectsDeleteAll(0);
//ObjectsDeleteAll(0,0,OBJ_VLINE);
//ObjectsDeleteAll(0,0,OBJ_RECTANGLE);
for(int j=1;j<=TOTAL_BAR;j++)
{
for(int jj=1;jj<TOTAL_BAR;jj++)
{
if(ObjectFind(0,"AO_Indicator_Divergence"+IntegerToString(j)+TimeToString(jj))>=0)
ObjectDelete(0,"AO_Indicator_Divergence"+IntegerToString(j)+TimeToString(jj));
if(ObjectFind(0,"AO_Price_Divergence"+IntegerToString(j)+TimeToString(jj))>=0)
ObjectDelete(0,"AO_Price_Divergence"+IntegerToString(j)+TimeToString(jj));
}
}
ChartRedraw();
ChartSetInteger(0,CHART_FOREGROUND,foreground);
}
there is no error or warning but on chart there is problem.
what is wrong ?
thank you.- 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 draw OBJ_VLINE by :
and then :
to delete it,
----------------------------------
my question is :
if i used below code , Instead of above : is this have problem ?
i check it & there is seems no problem, but Can I be sure this is correct and no error in future with growing the indicator? ( may be i used 2 index , i & j )
thank you.