drawing lines in the future

Have a QScript to share, or need help with programming? Post your comment here.
Post Reply
q0paz
Posts: 1
Joined: Tue Jul 21, 2015 8:54 pm
Location: Singapore
Contact:

drawing lines in the future

Post by q0paz » Wed Mar 09, 2016 10:02 am

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

User avatar
earik
Site Admin
Posts: 438
Joined: Mon Dec 01, 2014 12:41 pm
Contact:

Re: drawing lines in the future

Post by earik » Wed Mar 09, 2016 6:27 pm

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

Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests