Download MetaTrader 5
To add comments, please log in or register
Add the thread to Favorites. Track the changes even faster!
AYMERIC75
112
AYMERIC75 2014.08.11 12:05 

Hi everyone,

 I have a problem with my EA, indeed i want to display a THUMB UP for each tick on the graph, so i wrote the following EA but the problem is that it only displays the thumb for the 1st tick and then no more ticks....

Cheers


Aymeric


int init()
  {
  
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start() // dans int start() le programme se recharge à chaque nouveau tick
{

    ObjectCreate(0,"name",OBJ_ARROW_THUMB_UP,0,Time[0],Bid);
    return(0);

}

Keith Watford
Moderator
7891
Keith Watford 2014.08.11 12:10  

All objects have to have individual names.

You create an object on the first tick named "name"

2nd tick, the EA cannot create another object with the same name. If you used error reporting, you would see that you get the error "Object already exists". 

AYMERIC75
112
AYMERIC75 2014.08.11 12:34  
Thank you for your answer, so is there a solution to make a loop that create the same object over and over ?
AYMERIC75
112
AYMERIC75 2014.08.11 12:40  

Okay i just found a nearby solution by adding ObjectDelete("name"); just before ObjetCreate(...) this way the EA display a new thumb for each tick, but is erases the previous one...


So is it possible to save all the thumbs on the graphic ?

Keith Watford
Moderator
7891
Keith Watford 2014.08.11 13:21  
AYMERIC:

Okay i just found a nearby solution by adding ObjectDelete("name"); just before ObjetCreate(...) this way the EA display a new thumb for each tick, but is erases the previous one...


So is it possible to save all the thumbs on the graphic ?


Yes, add a counter declared outside of any function (after any external inputs, before init)

  int counter=0;
  ObjectCreate(0,"name"+(string)counter,OBJ_ARROW_THUMB_UP,0,Time[0],Bid);
  counter++;

 Remember to delete the objects in deinit

AYMERIC75
112
AYMERIC75 2014.08.11 13:37  
Thanks a lot it works !
/
To add comments, please log in or register