I've written a mod of the zigzag indicator that draws an equidistant channel based on the most recent confirmed zigzag points (not the very recent "wet paint" one). It's very simple, I just look back for the recent point's values and load them into an OBJ_CHANNEL - for which I've used the documented function. Works fine.
I now want to draw a pair of parallel lines outside this channel at the same vertical distance away as the vertical width of the original channel - so in effect, I'll get 4 parallel lines equidistant apart with that distance being set by the original channel. Simple enough surely.... I just have to find the vertical separation of the channel and add/subtract this from two points on each channel line and draw trend lines. The slight problem is that one of the channel lines only has one known point (the OBJ_CHANNEL function automatically draws it parallel without having to be given two points). The other issue is that none of the three known points are vertically aligned. Even so, I thought this would be easily solved using -
Code: Select all
double ObjectGetValueByTime(
long chart_id, // chart ID
string object_name, // object name
datetime time, // time
int line_id=0 // line ID
);Code: Select all
double price0 = ObjectGetValueByTime(ChartID(),channelName,time_1,0);
double price1 = ObjectGetValueByTime(ChartID(),channelName,time_1,1);By commenting the values of price0 and price1 I can see that price0 is correct but price1 doesn't relate to the chart - it's a massive number either positive or negative - and it's not EMPTY_VALUE. I haven't finished the code for drawing the extra lines because until I get these price values correct there's no point doing so.
So my (rather long winded, sorry) question is: Has anyone used ObjectGetValueByTime on a channel before and if so, how did you get it to report the correct value for the second line?
Thanks
Bruce