In Part 77 we wrapped our discussion of text chart objects and status displays. This time we’ll take a look at graphical chart objects.
While text objects can be attached directly to the chart and not be affected by candle movement (X/Y pixel positioning), graphical objects are “attached” to price and time and move with the candles. That’s good if you’re using them to describe price action – trend lines, fibonacci’s, gan lines, etc. – but it’s rather annoying when you are trying to display, for example, a thermometer bar on the chart to show price momentum (just a small rant, since that is what I wanted to do with my last indicator ;).)
So, how are graphical objects described in MT4? Well, you probably saw a small inkling of how it’s done when we first discussed the ObjectCreate() function:
bool ObjectCreate(string name, int type, int window, datetime time1, double price1, datetime time2=0, double price2=0, datetime time3=0, double price3=0). Graphical objects are described with the time/price parameters of the ObjectCreate() function. All objects must use the time1 and price1 parameters, but the rest of them can be left out if you don’t need them to describe your particular object. They will default to 0.
If you’ll recall, when you create an OBJ_LABEL, you just put 0s in the time1 and price1 parameters and describe the location by setting the OBJPROP_XDISTANCE and OBJPROP_YDISTANCE in the ObjectSet() function. That’s because the OBJ_LABEL object is tied to the chart window rather than the chart price action. As the price action moves, the OBJ_LABEL objects remain stationary with respect to the window.
The other graphical objects (including OBJ_TEXT) are attached to the price action and will scroll to the left as new candles appear. That’s because their position is described using time and price. For instance, if you describe a trend line and attach a point of the line to a price candle, it will always (theoretically – but that’s a rant for another day ;)) be attached to that price candle at that point. Some objects only require a single coordinate (time/price combination) to describe their positions (e.g. OBJ_TEXT, OBJ_ARROW), some use multiple coordinates (e.g. OBJ_TREND, OBJ_CHANNEL) some only use portions of the coordinates (time only or price only, e.g. OBJ_VLINE, OBJ_HLINE, OBJ_REGRESSION.)
That wraps up the week. Everyone have a great weekend! Thanks for your attention and please follow me on Twitter and LinkedIn.
Winner’s Edge Trading, as seen on: