Can I ask some MT4 questions? - page 2

 
Hossein: I mean when I move object1 by mouse, I need the object2 to follow the direction of object1.

You need to monitor the position of object1 in OnChartEvent. See my (for MT4): 'Money Manager Graphic Tool' indicator by 'takycard' - Risk Management - Articles, Library comments - MQL5 programming forum - Page 6 #55 (2018.01.14 and modified for screen resolution #75 (2020.02.17)

 
William Roeder:

You need to monitor the position of object1 in OnChartEvent. See my (for MT4): 'Money Manager Graphic Tool' indicator by 'takycard' - Risk Management - Articles, Library comments - MQL5 programming forum - Page 6 #55 (2018.01.14 and modified for screen resolution #75 (2020.02.17)

Thanks
 
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
   EventSetMillisecondTimer(100);
   
   ObjectCreate(0,"Object1",OBJ_TREND,0,Time[40],High[1],Time[1],High[1]);
   ObjectSetInteger(0,"Object1",OBJPROP_RAY,0);
   ObjectSetInteger(0,"Object1",OBJPROP_COLOR,clrRed);
   ObjectSetInteger(0,"Object1",OBJPROP_WIDTH,3);

   ObjectCreate(0,"Object2",OBJ_TEXT,0,Time[20],High[20]);
   ObjectSetText("Object2","TEXT",12,"Arial",clrBlue);
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Timer function                                                   |
//+------------------------------------------------------------------+
void OnTimer()
  {
   datetime time_1 = ObjectGetInteger(0,"Object1",OBJPROP_TIME1,0);
   double price_1 = ObjectGetDouble(0, "Object1", OBJPROP_PRICE1,0);

   ObjectSetInteger(0,"Object2",OBJPROP_TIME1,time_1);
   ObjectSetDouble(0,"Object2",OBJPROP_PRICE1,price_1); 
  }
Hossein
:

Thanks

Hi William Roeder, Thank you for your help. I saw the links you advised, but as I am not a professional programmer, I didn't get what should I do exactly. Can you edit my code for monitoring the position of object1 in OnChartEvent (as you mentioned).  Really appreciated

 
please anyone help, how do i use the step over and step into buttons in metaeditor 4, i have been looking on YouTube but no luck 
Files:
mql4.jpg  138 kb
 
Hi everybody. I have written an indicator that creates a button on the chart. By pressing the button, it prints "Hello". Simple and easy!!! Then I save it as a new template. When I add the indicator on a new chart (by hand), it works well, but whenever I apply it as a template to a new chart it does not work. Anybody knows the reason? I would appreciated if h/she help me.
 
Can anyone suggest why the attached indicator  sometimes misses printing an alert and will not play any alert sounds. Thanks in anticipation of any help - John
Files:
 
John Escott #: Can anyone suggest why the attached indicator  sometimes misses printing an alert and will not play any alert sounds.

"Sometimes misses?" Considering that it has no code to Alert or PlaySound, why do you think it would ever do that.