Download MetaTrader 5
To add comments, please log in or register
MQL5 Cloud Network speeds up calculations. Try it!
Stephen Reynolds
483
Stephen Reynolds 2015.07.24 15:54 

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
1101
JD4 2015.07.24 17:30  
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
13596
whroeder1 2015.07.24 18:20  
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 2015.07.25 13:22  
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