Draw a simple horizontal line

 

I have read a bit about drawing objects, however I want something very simple and I can't find it explained anywhere.

I want to draw a horizontal, straight line from one end of the securities window to the other at a price that I specify.

Any help would be really appreciated.

Thank you very much!

 
ObjectCreate("UniqueName", OBJ_HLINE, 0, Time[0], YourPrice, 0, 0);
 

Thank you so much!

 

Hi Phy,

thanks. but this doesn't seem to work in my case.

I get no errors or warning, but still it doesn't seem to do anything. no lines no nothing. any ideas?

here is my code:

haopen1 = iCustom(NULL, 0, HA_indicator_name, 2,1);

haclose1 = iCustom(NULL, 0, HA_indicator_name, 3,1);

hahigh1 = iCustom(NULL, 0, HA_indicator_name, 0,1);

halow1 = iCustom(NULL, 0, HA_indicator_name, 1,1);

haopen2 = iCustom(NULL, 0, HA_indicator_name, 2,2);

haclose2 = iCustom(NULL, 0, HA_indicator_name, 3,2);

hahigh2 = iCustom(NULL, 0, HA_indicator_name, 0,2);

halow2 = iCustom(NULL, 0, HA_indicator_name, 1,2);

Print("haopen1= ", haopen1, " haclose1= ",haclose1, " hahigh1= ", hahigh1," halow1= ",halow1);

ObjectCreate("hl_hahigh", OBJ_HLINE, 0, Time[0], hahigh1, 0, 0);

ObjectCreate("hl_halow", OBJ_HLINE, 0, Time[0], halow1, 0, 0);

ObjectCreate("hl_haopen", OBJ_HLINE, 0, Time[0], haopen1, 0, 0);

ObjectCreate("hl_haclose", OBJ_HLINE, 0, Time[0], haclose1, 0, 0);

ObjectSet("hl_hahigh", OBJPROP_COLOR, Green);

ObjectSet("hl_halow", OBJPROP_COLOR, Red);

ObjectSet("hl_haopen", OBJPROP_COLOR, Blue);

ObjectSet("hl_haclose", OBJPROP_COLOR, Yellow);

Thanks a Lot!!

Wasseem

 

You might be waiting for a long time when you reply to a post that is over 3 years old . . .

ObjectCreate()

Horzontal lines only use one coordinate . . . not two "OBJ_HLINE Horizontal line. Uses price part of first coordinate." . . . you are drawing your lines at a price level of 0

Try . . .

ObjectCreate("hl_hahigh", OBJ_HLINE, 0, hahigh1);
 
From my code
void HLine(string name, double P0, color clr){  //      #define WINDOW_MAIN 0
    if (!Show.Objects)  return;
    if      (ObjectMove( name, 0, Time[0], P0 )){}
    else if (!ObjectCreate( name, OBJ_HLINE, WINDOW_MAIN, Time[0], P0 ))
        Alert("ObjectCreate(",name,",HLINE) failed: ", GetLastError() );
    if (!ObjectSet(name, OBJPROP_COLOR, clr )) // Allow color change
        Alert("ObjectSet(", name, ",Color) [1] failed: ", GetLastError() );
    if (!ObjectSetText(name, PriceToStr(P0), 10))
        Alert("ObjectSetText(",name,") [3] failed: ", GetLastError());
}
Reason: