Download MetaTrader 5

objectdelete

To add comments, please log in or register
Improve your rating. Execute orders in Freelance service!
Ester Purnamasari Sirait
30
Ester Purnamasari Sirait 2013.11.24 17:18 

hi,

i have indicator candlestick pattern, and it works ok with my modifications about some patterns in it.

problem is when changing TF it delete text i entered on chart. not label text. i know this is because of this code : ObjectsDeleteAll(0, OBJ_TEXT);

when i put this code - ObjectDelete("text_object"); and change TF, my text stays on chart, that's good, but also stays text from indicator!! and become a mess, as seen on picture.

for example i want to text "DCC" or "Engulf"- from indicator, be deleted when i change TF, so i put this code- ObjectDelete("text_DCC"); compile, -and nothing. it stays on chart when changeTF. when i open object list (Ctrl+B) i see that every text "DCC" or "Engulf"on chart have much different numbers after, as seen on picture.
i try with ObjectDelete("text_DCC*");
or ObjectDelete("text_DCC+");
and still nothing after compiling. is there any code who will delete DCC + numbers after text?

Ester Purnamasari Sirait
30
Ester Purnamasari Sirait 2013.11.24 17:23  
pic
whroeder1
14544
whroeder1 2013.11.24 17:44  
skip: is there any code who will delete DCC + numbers after text?

Why can't YOU code it?

void deleteDCC(){
   for(int iObj=ObjectsTotal()-1; iObj >= 0; iObj--){
      string   on = ObjectName(iObj);
      if(StringFind(on, "DCC") == 0)  ObjectDelete(on);
}  }

Was that SO hard?


Or a general solution from my code
#define ONDA_BEGINS     0
#define ONDA_CONTAINS   1
void ObjectNameDeleteAll(string name, int where=ONDA_BEGINS, int type=EMPTY){
   for(int iObj=ObjectsTotal()-1; iObj >= 0; iObj--){
      string   on = ObjectName(iObj);
      if(type != EMPTY) if(ObjectType(on) != type) continue;
      if(name != ""){
         int   iPos  = StringFind(on, name);
         if (iPos < 0)                             continue;
         if (iPos > 0 && where == ONDA_BEGINS)     continue;
      }
      ObjectDelete(on);
   }
}
Ester Purnamasari Sirait
30
Ester Purnamasari Sirait 2013.11.24 18:25  
ok man, big thanx. i m not so in it, coding and mql4. i find on google what is the reason for it. i was learn something about candle code from molanis short video. at the end it's not that hard.
all i know is to open it in metaeditor, delete some things, change colors, some values, compile, and test if it's ok.

can u tell me where exactly to put this first code? in this section
- int deinit() { ?

or somewhere else?

again thnx man!
Ester Purnamasari Sirait
30
Ester Purnamasari Sirait 2013.11.24 21:28  

ok, i figured it out in a few times.

now it look like this and it's working for DCC.

it's good. it dont delete text on chart and delete DCC when change timeframe. it's not a mess anymore.

but i have "engulf" "pierc" and "englf" to add in code. now i m asking what parametar i should change to add these three?

int deinit() {
   
    {for(int iObj=ObjectsTotal()-1; iObj >= 0; iObj--){
      string   on = ObjectName(iObj);
      if(StringFind(on, "DCC") == 0)  ObjectDelete(on);
}  }
whroeder1
14544
whroeder1 2013.11.25 02:36  
skip: now i m asking what parametar i should change to add these three?
Your question is the equivalent of "When I turn the wheel to the left the car turns left. What should I do to make it turn right?"learn to code it, or pay someone. We're not going to code it FOR you. We are willing to HELP you when you post your attempt (using SRC) and the nature of your problem.
Ester Purnamasari Sirait
30
Ester Purnamasari Sirait 2013.11.25 22:16  
ok, i tried to do what i think you told me.(i assume wrong)
i add new sentence with "Pierc" and it pass compile,

but did not erase "pierc" from chart. it stay after change TF.

int deinit() {
   
    {for(int iObj=ObjectsTotal()-1; iObj >= 0; iObj--){
      string   on = ObjectName(iObj);
      if(StringFind(on, "DCC") == 0)  ObjectDelete(on);
     if(StringFind(on, "Pierc") == 0)  ObjectDelete(on);
}  }
then make copy of whole code with "pierc"

and bunch of errors show.

its important to me to text object stay on chart with this indicator, because i learn to trade with no EA-s. i using elliott wave, previous high and low, pivots etc... so this is the reason

why i need text on chart.

so if i bothering you with my ignorance about coding, (i know this is wrong forum for me) it's ok, i will understand if i see no answer from you.

as you say: learn or pay.

int deinit() {
   
    {for(int iObj=ObjectsTotal()-1; iObj >= 0; iObj--){
      string   on = ObjectName(iObj);
      if(StringFind(on, "DCC") == 0)  ObjectDelete(on);
     
}  }
   {for(int iObj=ObjectsTotal()-1; iObj >= 0; iObj--){
      string   on = ObjectName(iObj);
      if(StringFind(on, "Pierc") == 0)  ObjectDelete(on);
     
Files:
whroeder1
14544
whroeder1 2013.11.25 22:56  
skip:
i add new sentence with "Pierc" and it pass compile,

but did not erase "pierc" from chart. it stay after change TF.

      if(StringFind(on, "DCC") == 0)  ObjectDelete(on);
     if(StringFind(on, "Pierc") == 0)  ObjectDelete(on);
then make copy of whole code with "pierc"

and bunch of errors show.

int deinit() {
   
:     
   }     // Deinit ends here.
   {for  // This code is not in a function - error
  1. but i have "engulf" "pierc" and "englf" to
    But you didn't try to delete "pierc" you tried to delete "Pierc". And according to your image you don't have "englf" either.
  2. Of course
Ester Purnamasari Sirait
30
Ester Purnamasari Sirait 2013.11.29 10:58  

it's working, this is the code, as you wrote to me:

int deinit() {
   {for(int iObj=ObjectsTotal()-1; iObj >= 0; iObj--){
      string   on = ObjectName(iObj);
      
      if(StringFind(on, "PrcLn") == 0)  ObjectDelete(on);
      if(StringFind(on, "DCC") == 0)  ObjectDelete(on);
      if(StringFind(on, "Engulf") == 0)  ObjectDelete(on);
      if(StringFind(on, "Engul") == 0)  ObjectDelete(on);
}  }
   return(0);

i made some mistakes before, while edited some words in metaeditor, but now is perfect.

thanx! i wouldn't do it without your help.

anaelisa
7
anaelisa 2013.12.21 19:28  
Wow, I have to learn a lot yet.
To add comments, please log in or register