Is it possible to receive keyboard inputs in the strategy?
Author: bobydesi123
Creation Date: 6/7/2013 3:12 PM
profile picture

bobydesi123

#1
Eugene, Cone

My question is:
While a WLP strategy is executing there is any way to access the key pressed on the key board? The reason I want to do this is i have a strategy that scans a data set, while displaying the charts with some technical s on it. When i see a chart that i like i need to pause and may be use another key to save the symbol in to a watch list.
I can try win API and DLL32 to create a key hook, but it sounds like too much hassle. Is there a easy way?
Thank you in advance!
profile picture

Eugene

#2
How does your strategy accomplish displaying these different charts while executing?
profile picture

bobydesi123

#3
Eugene,
This is what i am trying to achieve. For example, I have a strategy that plots multiple ROC from a data set. An example of the code is posted below (actually it is one of yours :) )
I understand that the WL renders the chart after the completing the
protected override void Execute()
{
....
}
What i want to do is see the chart for individual symbol in the data set and select the one i like as the ROC is being plotted.
The only way possible, as i see it, is to individually click on symbol in the data set manually or enter them in the "GO" box.
I am wondering if there is a way to automate the manual clicking of hundreds of symbol. In essence execute ,protected override void Execute() {..} in a loop.

I am trying to see if can "send keys" from an another application to WL, to automatically click data set or select a new symbol in the "GO" box on the top left corner of WL where you would enter the symbol manually.

Thank you for taking time to read my lengthy and unusual question. Any of your suggestion will be useful as always, including the "send key" idea am persuing is even worth the effort. I am almost half way through with key and mouse hooks. I understand that .NET 4+ and VS10 supports a good input device interaction. Only thing i see in WL for keyboard interaction is one of those .input from the component library.

CODE:
Please log in to see this code.
profile picture

Eugene

#4
This is not the code I expected to see. ;) When asking for code, I thought you already found a way to display charts sequentially.

Your understanding is correct: rendering the chart is done after Execute(). Therefore I do not believe that hooking into KeyPressed (or whatever) event in a Strategy will get you there. Frankly, this approach with its complications is not elegant. Instead of all this interactivity, saving all charts upfront and sorting them out in an image viewer would be much easier. Too bad that it's not going to work: GetChartBitmap() does not work in a DataSetSymbols loop.

You can send key from an external app, maybe even from a second Strategy if you know Reflection well, but the problem is, there's no "I like how this chart looks" event. How would you communicate that to your event listener?
profile picture

bobydesi123

#5
Eugene,
Thank for your response. Here is a suggestion I have for future release of WL.
Can you have feature where the strategy works on a batch file? i.e. have text file or a dataset with desired symbols. A strategy will then go through each of the symbol sequentially, may with a little pause in between the execution. This will help, instead of manually clicking through 100 symbols. I am not sure how much of a work will that be, you have better idea.
Thanks for your help again u r a gem :)
profile picture

Eugene

#6
Thanks for the kind words.

However, for us simplification is above all else. The program just can't fit all possible single-user scenarios and features (that sometimes get pretty eccentric). For batch execution, we've already got the Strategy Monitor and Strategy Ranking tools. Clicking through charts for discretionary analysis certainly does not fit the concept of a mechanical trading application. Consequently, I'd suggest you leverage the existing capabilities through custom programming (if it's possible).
profile picture

bobydesi123

#7
Eugene,
Sorry to bother you yet again but i have Eureka moment. I think i know how to solve my problem. But i need little help with GetGlobal/SetGlobal.
Following is a little test code i wrote up.
CODE:
Please log in to see this code.


This is the output I get with the above code that executes a dataset with 4 stocks:(ccl,cuk,dri,kmx). Thanks in advance.

total sym 4 CCL

Data Global Memory empty
GetGlobal ds value is : 0
CCL
Data Global Memory empty
GetGlobal ds value is : 1
CUK
Data Global Memory empty
GetGlobal ds value is : 2
DRI
Data Global Memory empty
GetGlobal ds value is : 3
KMX

Question:
Why my Loop for checking GetGlobal == null failing? As clearly from the output GetGlobal(ds) is not null. I know it is something very silly but can't figure it out, so asking for expert's advice. Thank in advance.

CODE:
Please log in to see this code.
profile picture

Eugene

#8
Not sure how this is going to help you but everything is to the point.

Step 1. This code always starts by wiping out the global memory. It is empty.
Step 2. a) Then it starts looping by symbol. b) GetGlobal(ds) is always null if the current symbol is ds, of course.
Step 3. You push a value for the current symbol into the global memory and move on.
Step 4. See Step #2b.
profile picture

sourkraut

#9
bobbydesi123,

if you can live with stopping between symbols, here is an excerpt from one of my strategies that might help:

CODE:
Please log in to see this code.


Cheers,

Eb
profile picture

bobydesi123

#10
Thanks for the info. Eb,
Came back to this thread after a long time. Actually i searched the web and found a nice c# utility library from AutoIt. With this AutoIt library functions it was easier to simulate mouse/keyboard events for WLP.
Here is the link if you or anyone is interested:
http://www.autoitscript.com/forum/topic/72905-c-use-of-the-dll-some-idears-for-you/
This website uses cookies to improve your experience. We'll assume you're ok with that, but you can opt-out if you wish (Read more).