Page 1 of 1

drawing lines in the future

Posted: Wed Mar 09, 2016 10:02 am
by q0paz
Hi Guys,

I have read the 'Building Drawing Tools' in the helpfile.

I have a routine that calculates dates into the future and I want to be able to draw vertical lines at these dates.

Since the routine produces a DateTime for which there won't actually be a bar on the chart Date_to_Bar will return -1 and I can't see how to identify the x of the identified pixel corresponding to my date. I can't use hotspots because the script will generate the DateTimes.

I need something that mirrors the Price_to_Pixel function i.e. x-pixel = Date_to_Pixel(dateTime)

Also, amusingly, searching this BB for 'future', 'future' gets ignored because it's too common. :)

Any clues ??

Thanks

Re: drawing lines in the future

Posted: Wed Mar 09, 2016 6:27 pm
by earik
Hi Q,

Does it have to be a drawing tool with hotspots? If you can use trendlines instead, that would really simplify things. Trendlines work with barnumbers, so if you get the barnumber for your target line, you can draw it in the future. Vertical trendlines just have price1 = 0, price2 = some big number. Use offet_to_barnum and barnum_to_offset to convert around from barnumbers to offsets in the future. So if you are calculating astro (let's say) for 50 bars in the future, you can get the date by using year[-50], month[-50], etc, figure out your target, then get the actual bar by using offset_to_barnum, or just adding 50 to the current bar. That's how I've always done lines in the future. Check out the QScript library for a script I wrote (Astro_Fixed_Multiples), and you'll have an example of how to do all that stuff.

Regards,

Earik