Sharing results between Qscripts? [Semi-Solved]

Have a QScript to share, or need help with programming? Post your comment here.
Post Reply
sbank
Posts: 174
Joined: Tue Jul 21, 2015 9:35 pm
Contact:

Sharing results between Qscripts? [Semi-Solved]

Post by sbank » Thu Jan 25, 2018 10:19 pm

Hi All,

I have two questions around the feasibility of sharing the results from one Qscript in one chart so that another (and different) Qscript from another chart. My two questions are really around 1) how to do this especially w.r.t locking/reading/writing. and 2) how does one use a system test to test this out?

Using concrete examples, I have two charts open. Chart 1, 30 minute ES. Chart 2, 10 minute ES. I figured I could have the Qscript running in the 30 minute window to just write the result to a file. Then the 10 minute QScript could just read from this. I figured as long as I am doing writing in one, and reading in the other, I should not need to worry about locking? But what if the writing takes a weee bit more time, such that the 10 minute reader goes to check for the results, but misses the update? (since the writing is still theoretically happening. This could be off every 3 bars then.)

My second part of this question is around how one would go about back testing this. My 30 minute QScript was not going to keep history of the data, but I guess that is a work around? (i.e. save data, 1 line for each bar, and just deliminate the data with commas or carets or something.)

thx for any pointers or examples.


PS: I thought about just implementing the 30 minute qscript in the 10 minute qscript (or vice-versa) but unfortunately my algos are not that friendly.
Last edited by sbank on Wed Feb 14, 2018 3:14 am, edited 1 time in total.

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

Re: Sharing results between Qscripts?

Post by earik » Fri Jan 26, 2018 5:51 pm

Hi sbank,

The synchronizing part is actually pretty tricky, since you don't know which chart is going to update first. At one point I started building global variables for this sort of thing, but got caught in the weeds as far as figuring out how to specify execution order between all the scripts in an easy way, and ended up not finishing. What ended up replacing that was being able to load multiple time frames on a single chart and then just query the data from each symbol within a single script. That was back in the days of PRO v1.x, when CQG powered the backend. It all still works, but you need CQG as the data provider to get access to it, which is expensive. We'll add that to IQFeed pretty soon, which will help with this sort of thing a lot.

Earik

sbank
Posts: 174
Joined: Tue Jul 21, 2015 9:35 pm
Contact:

Re: Sharing results between Qscripts?

Post by sbank » Fri Jan 26, 2018 8:16 pm

Thanks Earik for the response.

Would going down the DLL path help me at all? (I haven't really had a chance to look at that example DLL, but it might be easiest for me in the long run to just start writing everything in C. But then I would still have to figure out the backtests.... But I guess that is what nights are for. :-)

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

Re: Sharing results between Qscripts?

Post by earik » Mon Jan 29, 2018 5:35 pm

Hi Sbank,

DLLs are definitely an option. I remember years ago Lars wrote one for passing global variables, and it seemed to work pretty well from what I remember. The issue is still going to be figuring out how to synchronize everything, which is the thing that is going to cause you the most headaches. There's no way to ensure that the chart you want data from is going to be able to finish and pass the data in time before the chart that you need the data to get to enters its QScript processing phase...

Earik

kjociii
Posts: 15
Joined: Tue Jul 21, 2015 9:15 pm
Contact:

Re: Sharing results between Qscripts?

Post by kjociii » Tue Jan 30, 2018 1:11 am

Hi Sbank,
Throwing out an idea here but you would have to try it out to see if it would work. This won't work for historical data but I believe it will work in real-time.

30 Min chart:
Use the file_exists to check if file1 exists and if so, the 10min chart is still using it. Only write to this file if it doesn't exist and only write to it once per 30min bar.

10min chart:
Use a mod 30 on the time (or currenttime is another option) and only read from file1 if the mod30 > 1 or 2 (1 or 2 min past the half hour) as that should give the 30Min chart time to be done writing to the file. Take the values from file1 and concatenate it to file2 (which will give you a running database of the 30min values). Delete file1 to allow the 30min chart to write to the file on the close of the 30min bar. Use file2 for any extra data calls you need from the 10min chart.

Good luck!
Kenn
Wave59 Solution Provider
Custom QScript Programming
kenn@scriptbuilder.net

sbank
Posts: 174
Joined: Tue Jul 21, 2015 9:35 pm
Contact:

Re: Sharing results between Qscripts?

Post by sbank » Wed Feb 14, 2018 2:55 am

Thanks Kenn. Very interesting idea. Thanks for the idea.

Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests