#property indicator_chart_window #property indicator_plots 0 double Open1,Open2,Close1,Close2; int OnCalculate(const int rates_total, const int prev_calculated, const int begin, const double &price[]) { Open1 =iOpen (_Symbol,PERIOD_M1,1); Open2 =iOpen (_Symbol,PERIOD_M1,2); Close1=iClose(_Symbol,PERIOD_M1,1); Close2=iClose(_Symbol,PERIOD_M1,2); //+------------------------------------------------------------------+ //| DELETE LINES | //+------------------------------------------------------------------+ if (Open1 <= Close1) for (double i=Open1; i <= Close1; i++) {ObjectDelete(0,"HighGap="+DoubleToString(i,2)); Comment("HighGap="+DoubleToString(i,2));} else if (Open1 >= Close1) for (double i=Close1; i <= Open1; i++) {ObjectDelete(0,"LowGap="+DoubleToString(i,2)); Comment("LowGap="+DoubleToString(i,2));} //+-------------------------------------------------------------------+ //| CREATE LINES | //+------------------------------------------------------------------+ if (Open1>Close1 && Open1<Close2) { CriarLinhaH(0,0,"LowGap="+Open1,Open1,clrOrange,STYLE_DOT,1,true,false,true,"Low"); } else if (Open1<Close1 && Open1>Close2) { CriarLinhaH(0,0,"HighGap="+Open1,Open1,clrBlue,STYLE_DOT,1,true,false,true,"High"); } return(rates_total); } //+------------------------------------------------------------------+ //| CODE FOR THE CREATION OF HORIZONTAL LINES: | //+-------------------------------------------------------------------+ void CriarLinhaH(const long janela, const int subjanela, const string nome, double preco, color cor, const ENUM_LINE_STYLE estilo, const int tamanho, const bool oculto, const bool fundo, bool selecionavel, string dica_=NULL) { if (ObjectFind(janela,nome)==-1) ObjectCreate(janela,nome,OBJ_HLINE,subjanela,0,preco); ObjectSetDouble(janela,nome,OBJPROP_PRICE,preco); ObjectSetInteger(janela,nome,OBJPROP_COLOR,cor); ObjectSetInteger(janela,nome,OBJPROP_STYLE,estilo); ObjectSetInteger(janela,nome,OBJPROP_WIDTH,tamanho); ObjectSetInteger(janela,nome,OBJPROP_HIDDEN,oculto); ObjectSetInteger(janela,nome,OBJPROP_BACK,fundo); ObjectSetInteger(janela,nome,OBJPROP_SELECTABLE,selecionavel); ObjectSetString(janela,nome,OBJPROP_TOOLTIP,dica_); }
Dominik Egert thanks for the feedback, but unfortunately I've tried it without success.
Maybe I'm doing something wrong, but look how I wrote the code with the ObjectDelete() suggestion.
Thanks for all the help, thanks a lot!
Try this (?);
int delObj( string namePart ){ int d=0, o = ObjectsTotal(0,-1,-1); while(o>0){o--; string n = ObjectName(0,o,-1,-1); if (StringFind(n,namePart ,0) != -1) d+=(int)ObjectDelete(0,n); } return(d); }
Try this (?);
Carl Schreiber you are light years ahead of me.
I really don't have the slightest idea where to paste this code (where I tried and changed only the error).
If it is not possible to fix this code, it could at least indicate where I can study this subject.
Thank you very much!
Carl Schreiber you are light years ahead of me.
I really don't have the slightest idea where to paste this code (where I tried and changed only the error).
If it is not possible to fix this code, it could at least indicate where I can study this subject.
Thank you very much!
#property indicator_chart_window #property indicator_plots 0 double Open1,Open2,Close1,Close2; int OnCalculate(const int rates_total, const int prev_calculated, const int begin, const double &price[]) { Open1 =iOpen (_Symbol,PERIOD_M1,1); Open2 =iOpen (_Symbol,PERIOD_M1,2); Close1=iClose(_Symbol,PERIOD_M1,1); Close2=iClose(_Symbol,PERIOD_M1,2); //+------------------------------------------------------------------+ //| DELETE LINES | //+------------------------------------------------------------------+ if (Open1 <= Close1) for (double i=Open1; i <= Close1; i++) delObj("HighGap"); else if (Open1 >= Close1) for (double i=Close1; i <= Open1; i++) delObj("LowGap"); // //+-------------------------------------------------------------------+ //| CREATE LINES | //+------------------------------------------------------------------+ if (Open1>Close1 && Open1<Close2) { CriarLinhaH(0,0,"LowGap="+Open1,Open1,clrOrange,STYLE_DOT,1,true,false,true,"Low"); } else if (Open1<Close1 && Open1>Close2) { CriarLinhaH(0,0,"HighGap="+Open1,Open1,clrBlue,STYLE_DOT,1,true,false,true,"High"); } return(rates_total); } //+------------------------------------------------------------------+ //| Code delete part of object | //+------------------------------------------------------------------+ int delObj( string namePart ) { int d=0, o = ObjectsTotal(0,-1,-1); while(o>0){o--; string n = ObjectName(0,o,-1,-1); if (StringFind(n,namePart ,0) != -1) d+=(int)ObjectDelete(0,n); } return(d); } //+------------------------------------------------------------------+ //| CODE FOR THE CREATION OF HORIZONTAL LINES: | //+-------------------------------------------------------------------+ void CriarLinhaH(const long janela, const int subjanela, const string nome, double preco, color cor, const ENUM_LINE_STYLE estilo, const int tamanho, const bool oculto, const bool fundo, bool selecionavel, string dica_=NULL) { if (ObjectFind(janela,nome)==-1) ObjectCreate(janela,nome,OBJ_HLINE,subjanela,0,preco); ObjectSetDouble(janela,nome,OBJPROP_PRICE,preco); ObjectSetInteger(janela,nome,OBJPROP_COLOR,cor); ObjectSetInteger(janela,nome,OBJPROP_STYLE,estilo); ObjectSetInteger(janela,nome,OBJPROP_WIDTH,tamanho); ObjectSetInteger(janela,nome,OBJPROP_HIDDEN,oculto); ObjectSetInteger(janela,nome,OBJPROP_BACK,fundo); ObjectSetInteger(janela,nome,OBJPROP_SELECTABLE,selecionavel); ObjectSetString(janela,nome,OBJPROP_TOOLTIP,dica_); }
he most I got with this code was to delete all lines based on part of the name. But what I need is to delete the precise lines.
Example: If the bullish candlestick is with the opening of 1906.50 and the closing of 1907.50.
Oh yes, delete HighGap=1907.30 and others that exist as long as they are included in this price range.
If you have the line in 1907.55 it should not be deleted.
The most I got is to delete all the lines from 1907, in other words, I can't perfectly consider the 2 decimal places.
I made the suggested change and the errors disappeared, but the lines persist on the chart. What a thing!
#property indicator_chart_window #property indicator_plots 0 double Open1,Open2,Close1,Close2; int OnCalculate(const int rates_total, const int prev_calculated, const int begin, const double &price[]) { Open1 =iOpen (_Symbol,PERIOD_M1,1); Open2 =iOpen (_Symbol,PERIOD_M1,2); Close1=iClose(_Symbol,PERIOD_M1,1); Close2=iClose(_Symbol,PERIOD_M1,2); //+------------------------------------------------------------------+ //| DELETE LINES | //+------------------------------------------------------------------+ if (Open1 <= Close1) for (double i=Open1; i <= Close1; i++) {ObjectDelete(0,"HighGap="+DoubleToString(i,2)); Comment("HighGap="+DoubleToString(i,2));} else if (Open1 >= Close1) for (double i=Close1; i <= Open1; i++) {ObjectDelete(0,"LowGap="+DoubleToString(i,2)); Comment("LowGap="+DoubleToString(i,2));} //+-------------------------------------------------------------------+ //| CREATE LINES | //+------------------------------------------------------------------+ if (Open1>Close1 && Open1<Close2) { CriarLinhaH(0,0,"LowGap="+DoubleToString(Open1),Open1,clrOrange,STYLE_DOT,1,true,false,true,"Low"); } else if (Open1<Close1 && Open1>Close2) { CriarLinhaH(0,0,"HighGap="+DoubleToString(Open1),Open1,clrBlue,STYLE_DOT,1,true,false,true,"High"); } return(rates_total); } //+------------------------------------------------------------------+ //| CODE FOR THE CREATION OF HORIZONTAL LINES: | //+-------------------------------------------------------------------+ void CriarLinhaH(const long janela, const int subjanela, const string nome, double preco, color cor, const ENUM_LINE_STYLE estilo, const int tamanho, const bool oculto, const bool fundo, bool selecionavel, string dica_=NULL) { if (ObjectFind(janela,nome)==-1) ObjectCreate(janela,nome,OBJ_HLINE,subjanela,0,preco); ObjectSetDouble(janela,nome,OBJPROP_PRICE,preco); ObjectSetInteger(janela,nome,OBJPROP_COLOR,cor); ObjectSetInteger(janela,nome,OBJPROP_STYLE,estilo); ObjectSetInteger(janela,nome,OBJPROP_WIDTH,tamanho); ObjectSetInteger(janela,nome,OBJPROP_HIDDEN,oculto); ObjectSetInteger(janela,nome,OBJPROP_BACK,fundo); ObjectSetInteger(janela,nome,OBJPROP_SELECTABLE,selecionavel); ObjectSetString(janela,nome,OBJPROP_TOOLTIP,dica_); }
If you are not saving the string names in an array, but reconstructing the names, the way you do it must be exactly the same.
The naming of objects is not an Approximation.
This needs to be precise.
If you are not saving the string names in an array, but reconstructing the names, the way you do it must be exactly the same.
The naming of objects is not an Approximation.
This needs to be precise.
Do you have any more suggestions for me to be able to delete these damn lines. My brain is frying lol!
- 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 need to delete the objects included in the price range between the opening and closing of the candle.
In my current script I can delete the approximated objects, as I understand it uses the rounded value based on opening or closing value depending on the case.
My head is frying can someone help me passing a more accurate code?
I'm a layman and I'm starting to write my first codes.
Thank you for your patience and all the help you can give me.
Thank you very much!