Problem with ObjectCreate

 

Sorry, my english ;-(

Where is problem EA code?

I want draw horizontal line, maximum of Buffer[]

****************************

This is my code (section code)

...

int max = ArrayMaximum(Buffer,Bars,0); // Buffer is initialize indicator buffer

if(ObjectFind("max") == -1)
{
ObjectCreate("max", OBJ_HLINE, 1, Time[20], max);
ObjectSet("max", OBJPROP_STYLE, STYLE_DASHDOTDOT);
ObjectSet("max", OBJPROP_COLOR, Green);
}
else
{
ObjectMove("max", 1, Time[20], max);
}

...

*****************************

It not works correctly. Horizontal line is drawing only value zero, but indicator from Buffer[] !=0 !

If parameter "max" change to value (example "3"), horizontal line is drawing ok.

Thank you for help. Endy

 
ObjectCreate only work in main window not subwindow
 

But code

ObjectCreate("max", OBJ_HLINE, 1, Time[20], 3);
ObjectSet("max", OBJPROP_STYLE, STYLE_DASHDOTDOT);
ObjectSet("max", OBJPROP_COLOR, Green);

works correctly, line is drawing ???

How is drawing horizontal line maximu Buffer to subwindow?

Reason: