Download MetaTrader 5
To add comments, please log in or register
Publish your application in the Market - 7 million potential clients will see it
Wemerson Guimaraes
535
Wemerson Guimaraes 2015.06.17 15:22 

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); 
honest_knave
969
honest_knave 2015.06.17 15:35  

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 

Wemerson Guimaraes
535
Wemerson Guimaraes 2015.06.17 16:35  

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!

honest_knave
969
honest_knave 2015.06.17 19:53  

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. 

Wemerson Guimaraes
535
Wemerson Guimaraes 2015.06.17 20:32  

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);
honest_knave
969
honest_knave 2015.06.17 20:46  

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);  

} 
Wemerson Guimaraes
535
Wemerson Guimaraes 2015.06.18 00:35  

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!

honest_knave
969
honest_knave 2015.06.18 06:20  
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.
Wemerson Guimaraes
535
Wemerson Guimaraes 2015.06.18 20:18  
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!

/
To add comments, please log in or register