Download MetaTrader 5
To add comments, please log in or register
Track Market top sellers!
Ernest Klokow
1069
Ernest Klokow 2014.10.08 09:07 

I am writing an EA and want the EA to draw a horizontal line at a specific price level that is entered through an external variable.

I have looked at using the function e.g. SetLevelStyle(0,1,clrBlack); but it seems to require a SetIndexBuffer which stipulates an array. In my case I want a line on just one specific level.

Will anyone be so kind and help me with a solution?

honest_knave
953
honest_knave 2014.10.08 09:31  
These links on ObjectCreate and OBJ_HLINE should get you started, with examples.
whroeder1
13596
whroeder1 2014.10.08 13:43  
ernest02: . SetLevelStyle(0,1,clrBlack); but it seems to require a SetIndexBuffer which stipulates an array.
It does not stipulate an array. It stipulates a buffer and EA's don't have buffers.
Ernest Klokow
1069
Ernest Klokow 2014.10.08 14:31  
honest_knave:
These links on ObjectCreate and OBJ_HLINE should get you started, with examples.

Thanks for that guidance. I have written a snippet of code and it draws the required horizontal line, but it want to draw the line with every pass. I wrote some code that I thought would stop it from happening - but to no avail.

How can I stop this attempts at redrawing? (Getting 4200 error codes all the time which means the object already exists)

Here is the code:

if (ObjectName (0) != "pricelevel");
        {
if (!ObjectCreate(
   "pricelevel",
   OBJ_HLINE,
   0,    
   0,
   PriceLevel,
   0,
   0,
   0,
   0
   ))
   {
      Print("Error: can't create line! code #",GetLastError());
      return(0);
   }
}
honest_knave
953
honest_knave 2014.10.08 15:18  
ernest02:

Thanks for that guidance. I have written a snippet of code and it draws the required horizontal line, but it want to draw the line with every pass. I wrote some code that I thought would stop it from happening - but to no avail.

How can I stop this attempts at redrawing? (Getting 4200 error codes all the time which means the object already exists)

Here is the code:

 

// if (ObjectName (0) != "pricelevel");
   if (ObjectFind(0,"pricelevel") < 0)
        {
if (!ObjectCreate(
   "pricelevel",
   OBJ_HLINE,
   0,    
   0,
   PriceLevel,
   0,
   0,
   0,
   0
   ))
   {
      Print("Error: can't create line! code #",GetLastError());
      return(0);
   }
}

 

Untested / uncompiled. 

Ernest Klokow
1069
Ernest Klokow 2014.10.08 16:42  
honest_knave:

 

 

Untested / uncompiled. 

Thank you SO much! Greatly appreciate your assistance!
honest_knave
953
honest_knave 2014.10.08 19:34  
You're most welcome
/
To add comments, please log in or register