Download MetaTrader 5

Dont understand why ObjectCreate is created only once?

To add comments, please log in or register
Stephen Reynolds
7767
Stephen Reynolds  

Im trying to get the object OBJ_ARROW_THUMB_UP to appear every time the if condition is true when i test over a few days. Code as follows :

input int MaPeriod = 200;
input ENUM_MA_METHOD MaMethod = MODE_EMA;   
input ENUM_APPLIED_PRICE MaPrice = PRICE_CLOSE;

// OnTick() event handler                
void OnTick()    
{
   double close = Close[1];  
   datetime time = iTime(NULL,0,1);  
   double ma = iMA(_Symbol,_Period,MaPeriod,0,MaMethod,MaPrice,1);    

   // Buy order condition  
   if(close > ma) 
   {                             
      ObjectCreate("Buy",OBJ_ARROW_THUMB_UP,0,time,close);               
   }

   // Sell order condition
   if(close < ma)
   {
      ObjectCreate("Sell",OBJ_ARROW_THUMB_DOWN,0,time,close);
   }
} 

Im using OnTick() event handler as far as i understand this should count every tick that happens. But why does it only displays the object once on each if condition. It doesnt create the object if the condition appears again?

JD4
1100
JD4  
You have to specify the Object you are trying to create, if you are trying to create multiple Objects, they have to have different names.  You can have multiple Objects of the same type, just not the same names.
whroeder1
16103
whroeder1  
Do you think your parents could create two renzbub? You created it, with a specific name. You can't create another with the same name.
DeanDeV
330
DeanDeV  
WHRoeder:
Do you think your parents could create two renzbub? You created it, with a specific name. You can't create another with the same name.
LOL
To add comments, please log in or register