Hotkey's for Trading Keyboard - completed AHK code - Sierra Chart | futures io social day trading
futures io futures trading


Hotkey's for Trading Keyboard - completed AHK code
Updated: Views / Replies:419 / 0
Created: by SilverFut Attachments:3

Welcome to futures io.

(If you already have an account, login at the top of the page)

futures io is the largest futures trading community on the planet, with over 90,000 members. At futures io, our goal has always been and always will be to create a friendly, positive, forward-thinking community where members can openly share and discuss everything the world of trading has to offer. The community is one of the friendliest you will find on any subject, with members going out of their way to help others. Some of the primary differences between futures io and other trading sites revolve around the standards of our community. Those standards include a code of conduct for our members, as well as extremely high standards that govern which partners we do business with, and which products or services we recommend to our members.

At futures io, our focus is on quality education. No hype, gimmicks, or secret sauce. The truth is: trading is hard. To succeed, you need to surround yourself with the right support system, educational content, and trading mentors Ė all of which you can find on futures io, utilizing our social trading environment.

With futures io, you can find honest trading reviews on brokers, trading rooms, indicator packages, trading strategies, and much more. Our trading review process is highly moderated to ensure that only genuine users are allowed, so you donít need to worry about fake reviews.

We are fundamentally different than most other trading sites:
  • We are here to help. Just let us know what you need.
  • We work extremely hard to keep things positive in our community.
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts.
  • We firmly believe in and encourage sharing. The holy grail is within you, we can help you find it.
  • We expect our members to participate and become a part of the community. Help yourself by helping others.

You'll need to register in order to view the content of the threads and start contributing to our community.  It's free and simple.

-- Big Mike, Site Administrator

Reply
 
Thread Tools Search this Thread
 

Hotkey's for Trading Keyboard - completed AHK code

  #1 (permalink)
Elite Member
Brisbane + Queensland/Australia
 
Futures Experience: Beginner
Platform: NinjaTrader, Sierra Chart
Broker/Data: CQG, IQFeed
Favorite Futures: S&P Emini Futures
 
Posts: 54 since Mar 2015
Thanks: 38 given, 70 received

Hotkey's for Trading Keyboard - completed AHK code

Hopefully this is the correct place to post this - Please move if not appropriate.

I have been looking for a solution for awhile to send the same order to multiple platforms (Sierra Charts LIVE, Sierra Charts SIM, NT8 SIM). I've switched all live trading over to Sierra Charts and most of the charting but have had to still use NT for Jigsaw. This caused a bit of a issue with not being able to see active orders on the Jigsaw DOM and I ended up having to try watch 2 separate screens when in a trade and this became a issue when I needed to closely watch the Jigsaw DOM as I would sometimes loose track of price levels.

So the solution was to setup hotkeys that would send the same command to each platform with the ability to turn off/on the commands to the Sierra Charts LIVE platform as needed on the fly.

Here is the working code that I have come up with using AutoHotKey (https://autohotkey.com/)
Please excuse any mistakes or lack of proper coding etiquette, this is the 1st thing I've put together. Any feedback, pointers or better ways would be greatly appreciated. (A big thanks has to go to a mate who sat down and explained what Variables are and how to capture them for the session.)


After all 3 platforms are running, launch complied AHK program.


; --------- Click on and make active charts on platform 1 then use the hotkey - Ctrl + R

^R::
WinGet, WinID, ID, A ; --------- This finds and stores the variable Window ID for that platform for that session.
WinID_ctrl_R= ahk_id %WinID%
WinActivate, %WinID_ctrl_R% ; --------- This is the stored variable Window ID for that platform for that session that can then be called on later.
Return

; ---------- Click on and make active charts on platform 2 then use the hotkey - Ctrl + Y
^Y::
WinGet, WinID, ID, A ; --------- This finds and stores the variable Window ID for that platform for that session.
WinID_ctrl_Y= ahk_id %WinID%
WinActivate, %WinID_ctrl_Y% ; --------- This is the stored variable Window ID for that platform for that session that can then be called on later.
Return

; Click on and make active charts on platform 3 then use the hotkey - Ctrl + Q
^Q::
WinGet, WinID, ID, A ; --------- This finds and stores the variable Window ID for that platform for that session.
WinID_ctrl_Q= ahk_id %WinID%
WinActivate, %WinID_ctrl_Q% ; --------- This is the stored variable Window ID for that platform for that session that can then be called on later.
Return


#If GetKeyState("ScrollLock", "T") ; --------- This sets up "Scroll lock" key as a toggle - On = send command, Off = Don't send command. Only what is inside the #If statements are affected.
^Z:: ; ---------------------------------------------- Hotkey Ctrl + Z (Hotkey is only pressed once but depending on "Scroll Lock" toggle position, it will be sent to LIVE platform or not).
WinActivate, %WinID_ctrl_R% ; -------------- This references Platform 1 session WinID
Send, {LAlt Down}{s}{LAlt Up} ; ------------ Platform trade hotkey Alt + S
#If ; ------------------------------------------------ Closes #If statement
^Z:: ; ---------------------------------------------- Hotkey Ctrl + Z (This hotkey command gets sent always and will activate 2 platforms)
WinActivate, %WinID_ctrl_Y% ; -------------- This references Platform 2 session WinID
Send, {LAlt Down}{a}{LAlt Up} ; ------------ Platform trade hotkey Alt + A
WinActivate, %WinID_ctrl_Q% ; -------------- This references Platform 3 session WinID
Send, {LAlt Down}{j}{LAlt Up} ; ------------ Platform trade hotkey Alt + J
Return ; ---------------------------------------------- Reset

#If GetKeyState("ScrollLock", "T") ; --------- This sets up "Scroll lock" key as a toggle - On = send command, Off = Don't send command. Only what is inside the #If statements are affected.
^A:: ; ---------------------------------------------- Hotkey Ctrl + Z
WinActivate, %WinID_ctrl_R% ; -------------- This references Platform 1 session WinID
Send, {LAlt Down}{t}{LAlt Up} ; ------------ Platform trade hotkey Alt + T
#If ; ------------------------------------------------ Closes #If statement
^A:: ; ---------------------------------------------- Hotkey Ctrl + Z
WinActivate, %WinID_ctrl_Y% ; -------------- This references Platform 2 session WinID
Send, {LAlt Down}{b}{LAlt Up} ; ------------ Platform trade hotkey Alt + B
WinActivate, %WinID_ctrl_Q% ; -------------- This references Platform 3 session WinID
Send, {LAlt Down}{k}{LAlt Up} ; ------------ Platform trade hotkey Alt + K
Return ; ---------------------------------------------- Reset

; (This same process is repeated through each set until the last 2 which are slightly different)

#If GetKeyState("ScrollLock", "T")
^X::
WinActivate, %WinID_ctrl_R%
Send, {LAlt Down}{u}{LAlt Up}
#If
^X::
WinActivate, %WinID_ctrl_Y%
Send, {LAlt Down}{c}{LAlt Up}
WinActivate, %WinID_ctrl_Q%
Send, {LAlt Down}{l}{LAlt Up}
Return

#If GetKeyState("ScrollLock", "T")
^S::
WinActivate, %WinID_ctrl_R%
Send, {LAlt Down}{v}{LAlt Up}
#If
^S::
WinActivate, %WinID_ctrl_Y%
Send, {LAlt Down}{d}{LAlt Up}
WinActivate, %WinID_ctrl_Q%
Send, {LAlt Down}{m}{LAlt Up}
Return

#If GetKeyState("ScrollLock", "T")
^C::
WinActivate, %WinID_ctrl_R%
Send, {LAlt Down}{w}{LAlt Up}
#If
^C::
WinActivate, %WinID_ctrl_Y%
Send, {LAlt Down}{e}{LAlt Up}
WinActivate, %WinID_ctrl_Q%
Send, {LAlt Down}{n}{LAlt Up}
Return

#If GetKeyState("ScrollLock", "T")
^D::
WinActivate, %WinID_ctrl_R%
Send, {LAlt Down}{x}{LAlt Up}
#If
^D::
WinActivate, %WinID_ctrl_Y%
Send, {LAlt Down}{f}{LAlt Up}
WinActivate, %WinID_ctrl_Q%
Send, {LAlt Down}{o}{LAlt Up}
Return

#If GetKeyState("ScrollLock", "T")
^B::
WinActivate, %WinID_ctrl_R%
Send, {LAlt Down}{y}{LAlt Up}
#If
^B::
WinActivate, %WinID_ctrl_Y%
Send, {LAlt Down}{g}{LAlt Up}
WinActivate, %WinID_ctrl_Q%
Send, {LAlt Down}{p}{LAlt Up}
Return


; (These following 2 are only relevant to Sierra Charts because NT doesn't support the function currently. Ask NT to include this function in future releases as its great to use)
; This is for the "Stop Order Tick Up" and "Stop Order Tick Down" hotkeys avalible in Sierra Charts.


#If GetKeyState("ScrollLock", "T") ; --------- This sets up "Scroll lock" key as a toggle - On = send command, Off = Don't send command. Only what is inside the #If statements are affected.
^V:: ; ---------------------------------------------- Hotkey Ctrl + V
WinActivate, %WinID_ctrl_R% ; -------------- This references Platform 1 session WinID
Send, {LAlt Down}{z}{LAlt Up} ; ------------ Platform trade hotkey Alt + Z
#If ; ------------------------------------------------ Closes #If statement
^V:: ; ---------------------------------------------- Hotkey Ctrl + V
WinActivate, %WinID_ctrl_Q% ; -------------- This references Platform 3 session WinID
Send, {LAlt Down}{q}{LAlt Up} ; ------------ Platform trade hotkey Alt + Q
Return ; ---------------------------------------------- Reset

#If GetKeyState("ScrollLock", "T")
^F::
WinActivate, %WinID_ctrl_R%
Send, {LAlt Down}{1}{LAlt Up}
#If
^F::
WinActivate, %WinID_ctrl_Q%
Send, {LAlt Down}{r}{LAlt Up}
Return


See attached "Hotkeys_3_Platforms_A.txt" for full code. This needs to be saved as a .ahk file before it can be complied. Open file in Notepad>save as>(Save as type: All files)> yourfilename.ahk>Save.

Must have AutoHotKey installed> right mouse click yourfilename.ahk> Compile Script
It will then produce the autohotkey application and when its needed> right mouse click> Open
It will stay running in the task manager background processes for the computer session or until you manually kill it in Windows Task Manager.

The Sierra Charts LIVE platform was positioned 1st in line, followed by NT SIM with the Jigsaw DOM as this is the order of importance I needed when live trading and to cut down on slippage due to delayed execution when 3 commands are sent one after the other. I have noticed some small differences of 1 tick occasionally on the 3rd platform but I'm not really using it to live trade, its just the fall back sim trade so it doesn't cause any real issue for me.

The above AHK program will then make each platform "window" active when needed. If you manually switch charts (Child Tab) on all 3 platforms and bring a new instrument to the forefront EG- ES to ZB, the hotkeys will then work on those charts.

NOTE: You MUST activate "Trading Keyboard Short Cuts Enabled" on EACH chart you need in Sierra charts. When each chart is at the forefront in Sierra Charts> Trade> Trading Keyboard Short Cuts Enabled. It will then allow Hotkeys to be used on this chart when its at the forefront of the parent window and will only use hotkeys on that chart while its at the forefront "active". (I think you need to enable "Chart Trade Mode" and(??) "Attach Trade Window to Chart"on each chart the hotkeys will be used on.)

Nt doesn't need each chart enabled, it has a global setting. Tools> Options> Trading> Use Order Entry hot keys. It will then allow Hotkeys to be used on this chart when its at the forefront of the parent window and will only use hotkeys on that chart while its at the forefront "active". (I think you need to enable "Chart Trader" on each chart the hotkeys will be used on.)


I kept Alt + "*" for the hotkeys to be set inside each platform and have attached a spreadsheet with the legend I used for each platform. These must be manually set in each platforms hotkey settings. Alternatively, you can change the code to suit your own platform hotkey bindings. In the code, I used all lower case for the platform hotkey alphabetic keys but on the legend I used uppercase so that they clearly show what letters are used.

I used Ctrl + "*" for the hotkeys for AHK.

This then allowed "Shift" to still be used normally for typing on the keyboard and not accidentally fire off a hotkey that triggers a order somewhere.

I setup a custom Trading keyboard from Trading Keyboard | Sample Configurations | Keyboard Trader. It is a access-IS 15 x 8 base. See layout picture




My next thing to tackle is to setup and use the 5 keys in the upper left of the "Trading Keyboard Hotkeys.PNG" to somehow bind them to individual child tabs in each trading platform window so that 1 key will bring all 3 platforms ES charts to the forefront, another will bring all 3 platforms 30yr US Treasuries ZB charts to the forefront and so on.
Seeming to run into some major issues with doing this as AutoHotKey doesn't like finding child tabs, making them active and bringing them to the forefront inside the parent window. There are ways around it by using known x, y screen positions and auto-mouse clicking the tabs but this would mean everything needs to stay in the same relative screen positions all the time with nothing obstructing the mouse click target which is not ideal. The other option is to search for a image of the tab name but this is slow and prone to issues from what I have read.

If anyone knows how to do this using AutoHotkey or even a completely different language/way, it would be great to hear some options to look into.

Please give feedback on where I can improve, this is my 1st effort and its taken a bit to get my head around.

I hope this can help someone else in some way.

Attached Thumbnails
Hotkey's for Trading Keyboard - completed AHK code-trading-keyboard-hotkeys.png  
Attached Files
Register to download File Type: xls MACRO_KEYS_FOR_EACH_PLATFORM_v3.XLS (10.0 KB, 6 views)
Register to download File Type: txt Hotkeys_3_Platforms_A.txt (2.3 KB, 6 views)

Last edited by SilverFut; September 27th, 2016 at 02:45 PM.
Reply With Quote
The following user says Thank You to SilverFut for this post:

Reply



futures io > > > > Hotkey's for Trading Keyboard - completed AHK code

Thread Tools Search this Thread
Search this Thread:

Advanced Search



Upcoming Webinars and Events (4:30PM ET unless noted)

Adam Grimes: TBA

Elite only

NinjaTrader: TBA

Dec 7

Linda Bradford Raschke: TBA

Elite only

Ran Aroussi: TBA

Elite only
     

Similar Threads
Thread Thread Starter Forum Replies Last Post
KeyTrader - a simple numeric keyboard trading tool ratfink The Elite Circle 68 September 28th, 2015 12:13 AM
NEW KEYBOARD TRADING for NINJA TRADER? ? OpalDragon NinjaTrader 3 May 25th, 2015 04:56 PM
Lazy keyboard username's trading journal asdfasdf Elite Trading Journals 5 April 13th, 2015 02:25 PM
Rating a transaction after it is completed Big Mike Hire a Consultant or Programmer 0 January 24th, 2013 03:11 AM
looking for C# code for a keyboard command simulation max-td NinjaTrader Programming 3 December 29th, 2010 10:24 AM


All times are GMT -4. The time now is 08:13 PM.

Copyright © 2017 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432, info@futures.io
All information is for educational use only and is not investment advice.
There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
no new posts
Page generated 2017-11-24 in 0.12 seconds with 20 queries on phoenix via your IP 54.162.250.227