If they are drawn by indicator code, modify the indicator.
If they are Objects:
string newestArrow = ""; string name; for(j = 0; j < Bars-1 ; j++){ for(i = ObjectsTotal()-1; i >= 0; i--){ name = ObjectName(i); if(ObjectType(name) == OBJ_ARROW && ObjectGet(name, OBJPROP_TIME1) >= Time[i]){ newestArrow = name; break; } } if(newestArrow != "") break; } for(i = ObjectsTotal()-1; i >= 0; i--){ name = ObjectName(i); if(name == newestArrow) continue; if(ObjectType(name) == OBJ_ARROW) Objectelete(name); }
Hi
Another approach if it is your code creating the arrows. Instead of creating a new arrow each time, create the first one then move it to the next/new position when required. That way you only have the arrows you want.
Cheers
Jellybean
Hi
Another approach if it is your code creating the arrows. Instead of creating a new arrow each time, create the first one then move it to the next/new position when required. That way you only have the arrows you want.
Cheers
Jellybean
int start()
{
//+-----------------------------------------------------------------+
if( Bars != OldBars ) { Trigger1 = True ; Trigger2 = True ; Trigger3 = True ;}
if (Period1>0) CountZZ(FP_BuferUp,FP_BuferDn,Period1,Dev1,Stp1);
if (Period2>0) CountZZ(NP_BuferUp,NP_BuferDn,Period2,Dev2,Stp2);
if (Period3>0) CountZZ(HP_BuferUp,HP_BuferDn,Period3,Dev3,Stp3);
//+----------------------------------------------------------------+
string alert.level; string alert.message;
alert.message = symbol+" "+ tChartPeriod+ " at "+ DoubleToStr(Close[0] ,digits);
if ( Trigger1 && Alert.Lv1 )
{
if( FP_BuferUp[0] != 0 ) { Trigger1 = False ; alert.level =" ZZS: Level 1 Low; "; if(Box.Alerts) Alert(alert.level,alert.message); if(Email.Alerts) SendMail(alert.level,alert.message);}
if( FP_BuferDn[0] != 0 ) { Trigger1 = False ; alert.level =" ZZS: Level 1 High; "; if(Box.Alerts) Alert(alert.level,alert.message); if(Email.Alerts) SendMail(alert.level,alert.message);}
}
if ( Trigger2 && Alert.Lv2 )
{
if( NP_BuferUp[0] != 0 ) { Trigger2 = False ; alert.level =" ZZS: Level 2 Low; "; if(Box.Alerts) Alert(alert.level,alert.message); if(Email.Alerts) SendMail(alert.level,alert.message);}
if( NP_BuferDn[0] != 0 ) { Trigger2 = False ; alert.level =" ZZS: Level 2 High; "; if(Box.Alerts) Alert(alert.level,alert.message); if(Email.Alerts) SendMail(alert.level,alert.message);}
}
if ( Trigger3 && Alert.Lv3 )
{
if( HP_BuferUp[0] != 0 ) { Trigger3 = False ; alert.level =" ZZS: Level 3 Low; "; if(Box.Alerts) Alert(alert.level,alert.message); if(Email.Alerts) SendMail(alert.level,alert.message);}
if( HP_BuferDn[0] != 0 ) { Trigger3 = False ; alert.level =" ZZS: Level 3 High; "; if(Box.Alerts) Alert(alert.level,alert.message); if(Email.Alerts) SendMail(alert.level,alert.message);}
}
OldBars = Bars ;
int CountZZ( double& ExtMapBuffer[], double& ExtMapBuffer2[], int ExtDepth, int ExtDeviation, int ExtBackstep )
{
int shift, back,lasthighpos,lastlowpos;
double val,res;
double curlow,curhigh,lasthigh,lastlow;
for(shift=Bars-ExtDepth; shift>=0; shift--)
{
val=Low[Lowest(NULL,0,MODE_LOW,ExtDepth,shift)];
if(val==lastlow) val=0.0;
else
{
lastlow=val;
if((Low[shift]-val)>(ExtDeviation*Point)) val=0.0;
else
{
for(back=1; back<=ExtBackstep; back++)
{
res=ExtMapBuffer[shift+back];
if((res!=0)&&(res>val)) ExtMapBuffer[shift+back]=0.0;
}
}
}
ExtMapBuffer[shift]=val;
//--- high
val=High[Highest(NULL,0,MODE_HIGH,ExtDepth,shift)];
if(val==lasthigh) val=0.0;
else
{
lasthigh=val;
if((val-High[shift])>(ExtDeviation*Point)) val=0.0;
else
{
for(back=1; back<=ExtBackstep; back++)
{
res=ExtMapBuffer2[shift+back];
if((res!=0)&&(res<val)) ExtMapBuffer2[shift+back]=0.0;
}
}
}
ExtMapBuffer2[shift]=val;
}
// final cutting
lasthigh=-1; lasthighpos=-1;
lastlow=-1; lastlowpos=-1;
for(shift=Bars-ExtDepth; shift>=0; shift--)
{
curlow=ExtMapBuffer[shift];
curhigh=ExtMapBuffer2[shift];
if((curlow==0)&&(curhigh==0)) continue;
//---
if(curhigh!=0)
{
if(lasthigh>0)
{
if(lasthigh<curhigh) ExtMapBuffer2[lasthighpos]=0;
else ExtMapBuffer2[shift]=0;
}
//---
if(lasthigh<curhigh || lasthigh<0)
{
lasthigh=curhigh;
lasthighpos=shift;
}
lastlow=-1;
}
//----
if(curlow!=0)
{
if(lastlow>0)
{
if(lastlow>curlow) ExtMapBuffer[lastlowpos]=0;
else ExtMapBuffer[shift]=0;
}
//---
if((curlow<lastlow)||(lastlow<0))
{
lastlow=curlow;
lastlowpos=shift;
}
lasthigh=-1;
}
}
for(shift=Bars-1; shift>=0; shift--)
{
if(shift>=Bars-ExtDepth) ExtMapBuffer[shift]=0.0;
else
{
res=ExtMapBuffer2[shift];
if(res!=0.0) ExtMapBuffer2[shift]=res;
}
}
}
//+------------------------------------------------------------------+
int Str2Massive(string VStr, int& M_Count, int& VMass[])
{
int val=StrToInteger( VStr);
if (val>0)
{
M_Count++;
int mc=ArrayResize(VMass,M_Count);
if (mc==0)return(-1);
VMass[M_Count-1]=val;
return(1);
}
else return(0);
}
//+------------------------------------------------------------------+
int IntFromStr(string ValStr,int& M_Count, int& VMass[])
{
if (StringLen(ValStr)==0) return(-1);
string SS=ValStr;
int NP=0;
string CS;
M_Count=0;
ArrayResize(VMass,M_Count);
while (StringLen(SS)>0)
{
NP=StringFind(SS,",");
if (NP>0)
{
CS=StringSubstr(SS,0,NP);
SS=StringSubstr(SS,NP+1,StringLen(SS));
}
else
{
if (StringLen(SS)>0)
{
CS=SS;
SS="";
}
}
if (Str2Massive(CS,M_Count,VMass)==0)
{
return(-2);
}
}
return(1);
}
//+------------------------------------------------------------------+
I have read the documentation on this site dealing with objects, but the answers still eludes me.
1. All previous objects dissapear - Which part of the code deals with that?
2. current object remains on chart untill opposite object appears - What do I need to add?
3. object remains on a fixed position on chart (although this is not essential) Thanks.
PLEASE PLEASE PLEASE
So it is not possible? (it uses DRAW ARROW)
Hi
There is nothing the code you posted that draws arrows. I suggest you add the whole file as an attachment.
Cheers
Jellybean
Sorry about that, full code attached. Thanks.
Hi
The indicator buffers are set to draw arrows by SetIndexStyle(0,DRAW_ARROW,0,1); They are not "objects."
To delete old arrows you need to set the value of the index buffer for those bars to the EMPTY_VALUE, which is 0.0. See SetIndexEmptyValue(0,0.0);
One way to remove old arrows would be to add a check for non-zero values in the buffers (FP_BuferUp, etc.) and set old values to 0.0. However, without looking too deeply, I don't quite know how the zigzag function CountZZ() works. Some zigzag functions recalculate the last couple of points, so if you delete them they will just redraw.
Hope this helps.
Jellybean
Thank you Jellybean,
But I still don't get it. I have read through the MQl4 documentation relating to Draw Arrow function but am still stuck. Could anyone kindly explain to me how I can delete all previous arrows, keeping only the current arrow until a new one appears on this indicator. 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
Hi
I have arrows on the chart, based on highs and lows. I need to delete all past ones so that only the current arrow is displayed. Thanks in advance for any suggestions.