AutoHotkey Scripts - NinjaTrader | futures io social day trading
futures io futures trading


AutoHotkey Scripts
Updated: Views / Replies:12,134 / 41
Created: by monpere Attachments:4

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
 4  
 
Thread Tools Search this Thread
 

AutoHotkey Scripts

  #31 (permalink)
Elite Member
Bala, PA, USA
 
Futures Experience: Intermediate
Platform: NinjaTrader
Broker/Data: Mirus, IB
Favorite Futures: SPY, Oil, Euro
 
monpere's Avatar
 
Posts: 1,858 since Jul 2010
Thanks: 300 given, 3,255 received


lllusion View Post
I did it manually and it worked so it probably is indeed a timing issue. Here's your code I have entered in:

I attempted to put the set key delay in there but it didn't work --- I'm guessing I didn't enter it in right. Can you put it in there for me so I can copy and paste it over? Thanks again kind sir! In the meantime I will start reading some of their manual online.

You have some other code in there that are not relevant. Try the following code. It puts a 1 sec delay between each keystroke.

 
Code
;###
;### Control-B-Left Mouse Key -> Ninjatrader Buy at cursor price level on the chart
;###
;SetKeyDelay, 500

^b::
if ( GetKeyState("ScrollLock",   "T") ) {	;### Insure Scroll Lock Key is ON
   if ( GetKeyState("LControl",  "D") ) {	;### Insure Control Key Key is Down
      if ( GetKeyState("LButton","D") ) {	;### Insure Left Mouse  Key is Down
        ;Send {Escape}{Click Up Left}{Click Up Right}{b}{Enter}{Escape}
         Send {Escape}
         Sleep, 1000
         Send {Click Up Left}
         Sleep, 1000
         Send {Click Up Right}
         Sleep, 1000
         Send {b}
         Sleep, 1000
         Send {Enter}
         Sleep, 1000
         Send {Escape}
      }
   }
}
return

;###
;### Control-S-Left Mouse Key -> Ninjatrader Sell at cursor price level on the chart
;###
^s::
if ( GetKeyState("ScrollLock",   "T") ) {	;### Insure Scroll Lock Key is ON
   if ( GetKeyState("LControl",  "D") ) {	;### Insure Control Key Key is Down
      if ( GetKeyState("LButton","D") ) {	;### Insure Left Mouse  Key is Down
        ;Send {Escape}{Click Up Left}{Click Up Right}{s}{Enter}{Escape}
         Send {Escape}
         Sleep, 1000
         Send {Click Up Left}
         Sleep, 1000
         Send {Click Up Right}
         Sleep, 1000
         Send {s}
         Sleep, 1000
         Send {Enter}
         Sleep, 1000
         Send {Escape}
      }
   }
}
return

Reply With Quote
The following user says Thank You to monpere for this post:
 
  #32 (permalink)
Elite Member
Knoxville, TN
 
Futures Experience: Beginner
Platform: NT7
Favorite Futures: SPY
 
lllusion's Avatar
 
Posts: 34 since Dec 2012
Thanks: 12 given, 22 received

I tried it with the delay and it simply did it slower, without actually triggering a sell limit. It just opens the "confirm order placement" y/n box then it closes without putting the sell limit in. It's so weird because when I do the exact same thing for the buy limit, it works.

This is a big bummer because this is an extremely useful hotkey to have... should I just try reinstalling ninjatrader or something? I don't think there is anything wrong with your code.

Reply With Quote
 
  #33 (permalink)
Elite Member
Bala, PA, USA
 
Futures Experience: Intermediate
Platform: NinjaTrader
Broker/Data: Mirus, IB
Favorite Futures: SPY, Oil, Euro
 
monpere's Avatar
 
Posts: 1,858 since Jul 2010
Thanks: 300 given, 3,255 received



lllusion View Post
I tried it with the delay and it simply did it slower, without actually triggering a sell limit. It just opens the "confirm order placement" y/n box then it closes without putting the sell limit in. It's so weird because when I do the exact same thing for the buy limit, it works.

This is a big bummer because this is an extremely useful hotkey to have... should I just try reinstalling ninjatrader or something? I don't think there is anything wrong with your code.

You did not mention order confirmation before. Looks like you have Order Confirmation active and the order confirmation pop-up window is receiving some of the key strokes, causing the unintended behavior. The script is not intended to work with Order Confirmation given that its purpose is to enter orders quickly. If you turn off order confirmation, I think it should work as designed. To turn off order confirmation go to Tools->Options->General Tab, and De-Select 'Confirm Order Placement'

Reply With Quote
The following user says Thank You to monpere for this post:
 
  #34 (permalink)
Elite Member
Knoxville, TN
 
Futures Experience: Beginner
Platform: NT7
Favorite Futures: SPY
 
lllusion's Avatar
 
Posts: 34 since Dec 2012
Thanks: 12 given, 22 received

Aaaah I understand. I was not aware you could turn off order confirmation. Will do this. Thanks again.

Reply With Quote
 
  #35 (permalink)
Elite Member
Bala, PA, USA
 
Futures Experience: Intermediate
Platform: NinjaTrader
Broker/Data: Mirus, IB
Favorite Futures: SPY, Oil, Euro
 
monpere's Avatar
 
Posts: 1,858 since Jul 2010
Thanks: 300 given, 3,255 received

Rollover volume

I roll over futures contracts based on volume. I wrote the following NinjaTrader indicators, RolloverVolume and BarChartDotComVolumes so i can determine which contracts have the highest volume for my traded instruments. But given that I use this functionality only once a month for monthly contracts or once every 3 months for quarterly contracts, there's no real reason why I want these indicators on my charts the rest of the time, even though I wrote them in such a way to use minimal resources.

So, I wrote this AutoHotkey script to duplicate the latter indicator and get the contracts volume from barchart.com without involving NinjaTrader at all, therefore it can be used with any trading platform. I can just run the script on demand, once a month to determine which contract I want to trade. It gets end of day volume by default, or you can pass an "I" as a command line argument in order to get intraday volume instead. You can update the list of instruments in the code.

Note: The code may need to be updated, if barchart.com changes the format of the associated web page in the future.

 
Code
;###
;### Get the highest contract front month volumes from barchart.com
;###

volmode := "D"			;### Volume mode D=EndOfDay, I=IntraDay
voltype := "EndOfDay"
result  := ""
Loop, %0%  {
    param := %A_Index%
	if ( RegExMatch(param, "^I") ) {
		volmode := "I"			;### IntraDay Volume
		voltype := "IntraDay"
	}
}

months := "JanFebMarAprMayJunJulAugSepOctNovDec"

get_symbols("CL, GC, YG, NQ, X, B6, E6, DX, RJ")	;### Symbols List

ToolTip
MsgBox, 64, , Contracts with Highest %voltype% Volumes`n`n%result%

ExitApp

get_symbols( symbols ) 
{
	global
	Loop, parse, symbols, `, , %A_Space%%A_Tab%
	{
		symbol = %A_LoopField%
		ToolTip,`n      ...Getting %symbol% %voltype% Volume...        `n`n   `n`n, 300, 500
		url  = http://www.barchart.com/commodityfutures/%symbol%?mode=%volmode%&view=&_dts1=volume
		str := get_url(url)
		RegExMatch(str, "s)/quotes/futures/" . %symbol% . ".*?title.*?=(.*?)>\s*(.*?)\s+.*?\((...).*?(\d+).*?ds_volume.*?(\d.*?)<", Match)
		title    := Match1
		contract := Match2
		month    := Match3
		year     := Match4
		volume   := Match5
		SetFormat, Float, 02.0	;### For 2 digit numeric month format
		mon      := Floor(RegExMatch(months, month)/3)+1.0
		result    = %result%%symbol%`t%mon%-%year%`t%contract%`t%volume%`t%title%`n
	}
	return
}


;######################################
;###
;### Get Web Page Text
;###
;######################################
get_url(url, line=""){
   doc := ComObjCreate("HTMLfile")
   pwhr := ComObjCreate("WinHttp.WinHttpRequest.5.1")
   pwhr.Open("GET",url) 
   pwhr.Send()
   doc.write(pwhr.ResponseText)
  ;text := doc.body.outerText
   text := doc.body.outerHTML
   if not line
      return, text
   s := InStr(text, "`n", 0, 1, line-1)
   e := InStr(text, "`n", 0, s+1)
   return, Trim(SubStr(text, s+1, e-s-1), "`r`n")  
}

;###
;### Exit Script
;###

^x::
MsgBox, 3, , .                           Terminate Rollover_Volume?, 1000
IfMsgBox Yes 
{
  ExitApp
}
return


Last edited by monpere; January 1st, 2013 at 07:33 PM.
Reply With Quote
The following 8 users say Thank You to monpere for this post:
 
  #36 (permalink)
Elite Member
Raleigh NC/USA
 
Futures Experience: Beginner
Platform: NinjaTrader
Favorite Futures: stocks
 
Posts: 27 since Oct 2014
Thanks: 108 given, 11 received

Toggle Update on Bar Close

Anyone familiar with modifying indicators via AutoHotKey?

In a NT chart, I'd like to be able to automate the process of bringing up the indicators window (easy enough) and then going through every indicator on the chart and toggling "Update on Bar Close" between True and False.

This would be useful to avoid the resource demands of constantly running realtime charts with Update on Bar Close set to False, but would still provide a means of quickly seeing the current indicators levels if the current bar were closed right now.

Reply With Quote
 
  #37 (permalink)
Trading Apprentice
Hong Kong
 
Futures Experience: Beginner
Platform: NinjaTrader, Interactive brokers
Favorite Futures: Stocks
 
Posts: 3 since May 2015
Thanks: 2 given, 0 received

Netfonds Ninjatrader

Hi Monpere,

Your script - Free Stock historical Tick Data

Thanks very much for posting these very useful scripts. Have been researching Netfonds myself today and looked by chance if somebody else had tackled this same exercise.

As a very novice coder I had difficulty getting this to work. Displayed the first confirmation MsgBox and nothing more.

Would you please provide an example of how I would personalise your script to request UVXY, XIV and SPY?

Many thanks and regards,
Andrew


Last edited by kitcaptain; February 13th, 2016 at 07:51 AM.
Reply With Quote
 
  #38 (permalink)
Trading Apprentice
Amsterdam , Netherlands
 
Futures Experience: Beginner
Platform: NInjaTrader
Favorite Futures: Eminis ES
 
Posts: 1 since Mar 2016
Thanks: 1 given, 0 received


monpere View Post
Several people have discussed how to quickly place orders on Ninjatrader charts. I do this using the following script. It basically issues Ninjatrader buy/sell stop or limit using the NT chart trading cursor menu. Autohotkey scripts are designed to normally run in the background as stay resident programs, so you generally run the script once, it stays in memory, and you can repeatedly use the programmed hot key sequence to perform the desired function.

In my scripts I generally require the 'Scroll Lock' key to be set for any hot key to be executed. This prevents accidental executions. When I see the Scroll Lock LED is turned On, on my keyboard, I know my keyboard is live.
In the following script, I require that the user presses down the left mouse key at the desired price level and hit Control-B for buy, or Control-S for sell. This should prevent your cat from walking across the keyboard and entering a trade

 
Code
;###
;### Control-B-Left Mouse Key -> Ninjatrader Buy at cursor price level on the chart
;###
^b::
if ( GetKeyState("ScrollLock",   "T") ) {	;### Insure Scroll Lock Key is ON
   if ( GetKeyState("LControl",  "D") ) {	;### Insure Control Key Key is Down
      if ( GetKeyState("LButton","D") ) {	;### Insure Left Mouse  Key is Down
         Send {Escape}{Click Up Left}{Click Up Right}{b}{Enter}{Escape}
      }
   }
return

;###
;### Control-S-Left Mouse Key -> Ninjatrader Sell at cursor price level on the chart
;###
^s::
if ( GetKeyState("ScrollLock",   "T") ) {	;### Insure Scroll Lock Key is ON
   if ( GetKeyState("LControl",  "D") ) {	;### Insure Control Key Key is Down
      if ( GetKeyState("LButton","D") ) {	;### Insure Left Mouse  Key is Down
         Send {Escape}{Click Up Left}{Click Up Right}{s}{Enter}{Escape}
      }
   }
}
return

I want to modify this by having a simple mouse click + key press to buy and sell. I dont want to use the control key. Can you please share the modified code ?
Is it possible to have the Char Z to buy and Char X to sell , instead of B to buy and S to sell .

Reply With Quote
 
  #39 (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: 37 given, 66 received

Can someone please let me know if the following is possible with AutoHotKey.


My issue is that I'm trying to see if it can function as I need if I try and setup a trading keyboard (Trading Keyboard | Sample Configurations | Keyboard Trader) with 3 separate macros for each key press that will then send the same action to 3 separate platforms.
(1 = Sierra Charts running IQFeed (SIM), 2 = Sierra Charts running CQG (LIVE), 3 = NinjaTrader 8 running IQFeed (SIM).)
I've switch the majority of my trading over to Sierra Charts but I've had to keep NT for Jigsaw DOM which I use to find entries/exits. I've been executing on Sierra Charts with the CQG broker data but I'm finding it difficult when scalping to track the exact price level of my live order entry and stop price level (that's on SC) while looking at the Jigsaw DOM on NT.

So I started looking around for some option that would allow a macro button solution so that when I entered a live trade on Sierra Charts w/CQG broker data, that same order would be entered as a SIM trade on Sierra Charts w/IQFeed and NT8 w/IQFeed and show the same order price levels on the Jigsaw DOM as the order price levels on the live trade on Sierra Charts that is executing the live trade to the broker. Then I only need to closely watch one screen.


The software for the keyboard (SoftProg Keyboard and Keypad Programming Utility) allows "layering" (Multiple macros) on the same key.

I've been trying to test the concept using the current keyboard I have (Roccat MK Pro) and setup the same macro key sequence (Buy Market = ALT+A) in Sierra Charts and (Buy Market = ALT+A) in Ninjatrader 8. (This would not be the case with the dedicated trading keyboard - each platform would get its own unique macro sequence for each task but the 3 unique macros would be bound to the same key press).


The problem I seem to be running into is that it will only execute the macro on whatever chart that has been clicked on to "bring it to the front" in Windows (Running Windows 8.1). So if I first click on Sierra charts chart, then ALT+A it will execute the Buy order on SC. Then if I click on NT8 chart and press ALT+A, it will execute the Buy order on NT8.

Each platform forces the chart to be clicked on first to become "active" and only then will it accept the macro sequence. I've talked to Sierra Charts support and they said I should explore trying to find a solution with AutoHotKey.

Is it possible to write a hotkey/script so that when a key is pressed (EG for a Buy market order), it will first make the required platform chart "active" and then execute the order on that platform, and that this same process can be executed for 3 separate platforms?

EG
Buy At Market button =
Make Sierra Charts LIVE chart# "active" - Execute Buy order
Make Sierra Charts SIM chart# "active" - Execute Buy order
Make Ninjatrader 8 SIM chart# "active" - Execute Buy order

Macros ideally would be all tied to one button on the keyboard or if that isn't possible, tie each macro to one key-switch and use dual or quad key caps so that 2 or 4 key-switches are activated at the same time. The keyboard in the above link has software that allows "layering" of macros (2 layers) on the same switch. From what I can gather this should allow 3 macros to a switch. Would that software ( SoftProg Keyboard and Keypad Programming Utility ) be able to be used with AutoHotKey?

Is there a solution or workaround to getting this to all work as I've described? Will AutoHotKey be the right path to start going down?

I'm only trying to trade 1 instrument at a time - 30yr Treasuries ZB. But I also have 10yr and 5yr charts and DOMs running over a total of 4 screens.


If there are any more details that might help, please let me know.


Last edited by SilverFut; September 1st, 2016 at 12:52 PM.
Reply With Quote
 
  #40 (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: 37 given, 66 received


For anyone else interested, I came across this that might help others with limited coding ability.

https://autohotkey.com/boards/viewtopic.php?f=6&t=143
Pulover's Macro Creator ? The Complete Automation Tool


I'm still to figure out if it can help with the tasks I need but it looks interesting and might help others.

Reply With Quote

Reply



futures io > > > > AutoHotkey Scripts

Thread Tools Search this Thread
Search this Thread:

Advanced Search



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

July Journal Challenge w/$1100 in prizes from TopstepTrader

July
 

An Afternoon with FIO member Softsoap

Elite only

Battlestations: Show us your trading desks and win $750 in prizes

August
 

Extended Ask Me Anything w/Brett Steenbarger

Elite only

Prototyping Python Strategies (part 3) w/Ran Aroussi

Elite only

Brannigan Barrett w/Axia Futures

Elite only

Introduction to Phillip Capital futures brokerage services

Aug TBD

How Monte Carlo Analysis Can Help Your Trading w/Kevin Davey

Elite only
     

Similar Threads
Thread Thread Starter Forum Replies Last Post
ninja & AutoHotKey for order entrys bobarian NinjaTrader 55 April 6th, 2016 02:59 PM
Some Matlab scripts around vwap wh Matlab, R project and Python 6 July 21st, 2015 06:56 PM
Get Autohotkey to work with Sierra Chart? vegasfoster Sierra Chart 2 March 21st, 2011 03:54 AM
Public class, passing values between scripts tinkerz NinjaTrader Programming 2 May 11th, 2010 11:41 AM
Communicate Between Scripts webart NinjaTrader Programming 6 April 30th, 2010 02:42 PM


All times are GMT -4. The time now is 02:55 AM.

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-07-23 in 0.14 seconds with 20 queries on phoenix via your IP 54.80.10.30