Aligning vertical text object

 

Good afternoon,

I am working on a little indicator which recognizes candlestick patterns and I have problems drawing the pattern name in a vertical text object. My problem is that all texts are "centered" from the object source position, and I can't align it properly on the chart. The end result is that for the most part, text labels are not readable. Is there a nice way to align the text to the left/right of the source position? If not, is there a way to move the text to the bottom or the top of the chart while keeping its angle? I believe that probably not, but it is worth asking ;)


This is the function that draws the text object and the line.

void DrawLabel(string text, datetime x1, double vPrice, color vcolor, string description)
{
   // Label
   string label = OLabel +" - "+DoubleToStr(x1, 0);
   ObjectCreate(label, OBJ_TEXT, 0, x1, vPrice);
   ObjectSetText(label, text, 8, "Tahoma", vcolor);
   ObjectSet(label, OBJPROP_ANGLE, 90);  
   ObjectSet(label, OBJPROP_BACK, true);
   
   // Line
   string LineName = OLabel +"Line - "+DoubleToStr(x1, 0); 
   ObjectCreate(LineName, OBJ_VLINE, 0, x1, vPrice);
   ObjectSet(LineName, OBJPROP_STYLE, STYLE_DOT);
   ObjectSet(LineName, OBJPROP_COLOR, vcolor);
   ObjectSet(LineName, OBJPROP_BACK, true);
}

Thanks in advance!

 
 
ubzen:
Thanks Uzben! :)
 
flaab:

Good afternoon,

I am working on a little indicator which recognizes candlestick patterns 

I have done this before by painting the bars,  you only have 4 colours to play with but you can have 2 or more Indicators . . .  so the first could paint inside bars, outside bars, engulfing and DOJI the second double tops, double bottoms, etc, etc
 
RaptorUK:
I have done this before by painting the bars,  you only have 4 colours to play with but you can have 2 or more Indicators . . .  so the first could paint inside bars, outside bars, engulfing and DOJI the second double tops, double bottoms, etc, etc

Hi Raptor,

Thanks for your message. I would like to code up over 20 patters so colors would not be enough. And memorizing the legend would be hard. This is what I've got so far.

What I am doing is paiting the involved bars orange and all the other bars blue and red as normal, and adding a label.

BTW How would you code up the recognition between a hammer and a hanged man candle pattern?


 
flaab:

Hi Raptor,

Thanks for your message. I would like to code up over 20 patters so colors would not be enough. And memorizing the legend would be hard. This is what I've got so far.

What I am doing is paiting the involved bars orange and all the other bars blue and red as normal, and adding a label.

BTW How would you code up the recognition between a hammer and a hanged man candle pattern?

I don't know the difference between a "hammer" and a "hanged man" so I wouldn't be able to code it . . . at least not without looking it up first  

Once you have your Indicator how are you going to use it ?  just for manual trading

 
RaptorUK:

I don't know the difference between a "hammer" and a "hanged man" so I wouldn't be able to code it . . . at least not without looking it up first  

Once you have your Indicator how are you going to use it ?  just for manual trading ? 

There is no difference between a "hammer" and a "hanging man" candle, it's the position relative to others candles that determines one either.
 

While thinking about candle patterns you should also think about this . . .

https://www.mql5.com/en/forum/138317 

 
RaptorUK:

I don't know the difference between a "hammer" and a "hanged man" so I wouldn't be able to code it . . . at least not without looking it up first  

Once you have your Indicator how are you going to use it ?  just for manual trading ? 

It is for manual trading ;-) I've added Harami and Piercing so far, and the charts are already a complete mess. It is almost useless for < H1.


 


 
angevoyageur:
There is no difference between a "hammer" and a "hanging man" candle, it's the position relative to others candles that determines one either.
Exactly :-/
 

Speaking of chaos...


Reason: