Plotting a series of dots

 

Hi,

Just testing to draw dots on the chart in its simplest way. So i wrote this simple piece of code :

void OnTick() {
   
   SetParameters();

   static datetime bar_time=0;
   datetime this_bar_time=iTime(Symbol(),PERIOD_M1,0);

   if(bar_time!=this_bar_time)
     {
      bar_time=this_bar_time;

      ObjectCreate(0,up_arrow,OBJ_ARROW,0,0,0,0,0);          
      ObjectSetInteger(0,up_arrow,OBJPROP_ARROWCODE,159);    
      ObjectSetInteger(0,up_arrow,OBJPROP_TIME,this_bar_time);  
      ObjectSetDouble(0,up_arrow,OBJPROP_PRICE,Bid);
      ChartRedraw(0); 
     }  
}


So i check once per minute the bid price and put a dot on that place, this works.

But now, the next minute the dot moves along with the new price check. How can we keep the series of previous dots?

Sorry for the newbie question, i can make EA's quite well but chart functions are completely new for me;

thanks!

 

You have to give each object a separate object name.

string obj_name = "up_arrow" + IntegerToString((int)this_bar_time);
ObjectCreate(0, obj_name, OBJ_ARROW, 0, 0, 0, 0, 0);
:
:

This is just one example. Do it as you like.

Documentation on MQL5: Constants, Enumerations and Structures / Objects Constants / Object Properties
Documentation on MQL5: Constants, Enumerations and Structures / Objects Constants / Object Properties
  • www.mql5.com
All objects used in technical analysis are bound to the time and price coordinates: trendline, channels, Fibonacci tools, etc. But there is a number of auxiliary objects intended to improve the user interface that are bound to the always visible part of a chart (main chart windows or indicator subwindows): – defines the chart corner relative to...
 

exactly, this works,

thanks for the insight!