Arrows/ObjectCreate overwriting Bars..

 

I am printing some arrows on the graphics.. Only for learning purposes...

As you can see on the image below, There are times, that the arrow is over the bar. There are a way to print the arrows more distant (upper or down) to the bar end?

Arrows 

 

ObjectCreate(0, name, OBJ_ARROW, 0, Time[shift], High[shift], 0, 0); 
 

ANCHOR_TOP and ANCHOR_BOTTOM are options for OBJ_ARROW

More than that and you will need to add spacing to the High / Low values manually 

 

I try this before... whan anchored to a bar with smaill tail, overwites the bar...

 

To do this manually I try but not works... 

 

ObjectCreate(0, name, OBJ_ARROW, 0, Time[shift], High[shift] * 1.2); 

For example when print on a Upper candle, try to increase the value returned by High[shift] in 20% expecting the arrow be printed mor above, but not works!

 

If you anchor your top arrows with ANCHOR_BOTTOM and your bottom arrows with ANCHOR_TOP you shouldn't get any overlap.

 

Failing that, use Point to get your distances. 

 

Yes the print was made a couple of candles after the arrows printed... but the code is right...

if( cmd == CMD_DOWN ) {

   ObjectCreate(0,name,OBJ_ARROW,0,Time[shift],Low[shift]);

   ObjectSetInteger(0, name, OBJPROP_ANCHOR, ANCHOR_BOTTOM);

   ObjectSetInteger(0,name,OBJPROP_ARROWCODE, 236);

   ObjectSetInteger(0,name,OBJPROP_WIDTH, 2);

   ObjectSetInteger(0,name,OBJPROP_COLOR, clrGreen); 

} 

 

if( cmd == CMD_UP ) {

   ObjectCreate(0,name,OBJ_ARROW,0,Time[shift],High[shift]);

   ObjectSetInteger(0, name, OBJPROP_ANCHOR, ANCHOR_TOP);

   ObjectSetInteger(0,name,OBJPROP_ARROWCODE, 238);

   ObjectSetInteger(0,name,OBJPROP_WIDTH, 2);

   ObjectSetInteger(0,name,OBJPROP_COLOR, clrRed);  

} 

ChartRedraw(0);
 

Your code is not quite right. Here are the changes:

 

if( cmd == CMD_DOWN ) {

   ObjectCreate(0,name,OBJ_ARROW,0,Time[shift],Low[shift]);

   ObjectSetInteger(0, name, OBJPROP_ANCHOR, ANCHOR_TOP);

   ObjectSetInteger(0,name,OBJPROP_ARROWCODE, 236);

   ObjectSetInteger(0,name,OBJPROP_WIDTH, 2);

   ObjectSetInteger(0,name,OBJPROP_COLOR, clrGreen); 

} 

 

if( cmd == CMD_UP ) {

   ObjectCreate(0,name,OBJ_ARROW,0,Time[shift],High[shift]);

   ObjectSetInteger(0, name, OBJPROP_ANCHOR, ANCHOR_BOTTOM);

   ObjectSetInteger(0,name,OBJPROP_ARROWCODE, 238);

   ObjectSetInteger(0,name,OBJPROP_WIDTH, 2);

   ObjectSetInteger(0,name,OBJPROP_COLOR, clrRed);  

} 
 

Ok, now works!

My bad,  i do not understood the anchor... If I am getting the Higher price on the candle to place the arrow position ( High[shift] ), that is on the candle top... I do not understand why should i anchor on bottom (Higher[shift] x ANCHOR_BOTTOM)....

But it's working... The only thing that matters is the result!

 

Thanks my friend!

 
wemersonrv:

Ok, now works!

My bad,  i do not understood the anchor... If I am getting the Higher price on the candle to place the arrow position ( High[shift] ), that is on the candle top... I do not understand why should i anchor on bottom (Higher[shift] x ANCHOR_BOTTOM)....

But it's working... The only thing that matters is the result!

 

Thanks my friend!

It is confusing - the anchor refers to which part of the arrow (not the candle) you want to pin to the spot defined by price/time.
 
honest_knave:
It is confusing - the anchor refers to which part of the arrow (not the candle) you want to pin to the spot defined by price/time.

Ok... thanks... I'ts working fine!

Reason: