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


AutoHotkey Scripts
Updated: Views / Replies:12,149 / 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

  #11 (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,256 received

Slight revision of the above script. The line below:


Quoting 
str := get_url("http://mam.econoday.com/byday.asp?cust=mam&day=%A_DD%&month=%A_MM%&year=%A_YYYY%")

Should be replaced with the following lines:




Reply With Quote
 
  #12 (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,256 received

NT Save Workspace

Ninjatrader 'Save Workspace' does not seem to save files to disk immediately (bug?). If NT crashes or terminates abnormally, your workspace may not have been saved, and sometimes after crashes, the workspace will be corrupted, and you will have lost your setup. Using 'Save Workspace As' instead does not seem to have this issue, so I created a AuotHotKey script to use save as instead. It saves the workspace as 'zbak<workspace>', then saves it again using the original workspace name, so you have a backup of the workspace with the save operation. The z in the backup name is to force the backup names to sort at the end when listed.

The script also shows how to pop up a user message input box with a timeout, and read the yes, no cancel user response.

 
Code
;######################################
;###
;### Save NinjaTrader Workspace
;###
;### If NT crashes or terminates abnormally, your workspace may not have been saved, and may get corrupted
;### Save workspace as name 'zbak_<worksapce>', then save again with original workspace name
;###
;######################################

;### Control-F3 - Also defined inside NinjaTrader as Save Workspace
~^F3::
   msg := ""
   osWindows := ""
   ntWindows = 
   (
      
   ;###
   ;### Restore NinjaTrader Windows from Last Save
   ;###
   CoordMode, Mouse, Screen
   SetTitleMatchMode 2`n
     ;### Restore NinjaTrader Windows`n
   )

   WinGetActiveTitle, activeWin 
   if ( RegExMatch(activeWin, ".*?\(.*?\).*?\d+/\d+/\d+") or RegExMatch(activeWin, "Control Center - ") ) {	;### NinjaTrader Chart or Control Center
      WinActivate, Control Center -
      WinWaitActive Control Center -
      WinGetActiveTitle, title
      if ( RegExMatch(title, "Control Center - ") ) { 
         workspaceName := RegExReplace(title, "Control Center - ", "") ;### Ninja Conrtrol center and chart windows
          MsgBox, 3, , .                                 Save workspace %workspaceName% ?, 10
          IfMsgBox Yes 
          {
            WinActivate,   %title%
            WinWaitActive  %title%
            IfWinActive,   %title%
            {
              SendInput {Escape}{Alt Down}{f}{Alt Up}{w}{s}{s}{Enter}zbak_%workspaceName%{Enter}{y}
              Sleep 500
              SendInput {Escape}{Alt Down}{f}{Alt Up}{w}{w}{s}{s}{Enter}%workspaceName%{Enter}{y}
            }
          }
      }
   }
return

Reply With Quote
The following 6 users say Thank You to monpere for this post:
 
  #13 (permalink)
Elite Member
Capitol Heights, MD
 
Futures Experience: Intermediate
Platform: NinjaTrader
Broker/Data: Global Futures/eSignal
Favorite Futures: ES
 
Posts: 12 since Apr 2010
Thanks: 41 given, 11 received



monpere View Post
...
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
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")
}

ExitApp
[/code]

Hi, I would like to experiment with this script but cannot get it to work. AutoHotKey complains about line 57, saying that "pwr.ResponseText" contains an illegal character. I am not a programmer but a quick search of your script shows no other reference to that variable. Can you tell me what I might be missing. I am using Windows XP SP3.

Thx

Reply With Quote
 
  #14 (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,256 received

Scroll NT chart vertically

With NT, you can scroll a chart horizontally along the time axis using the arrow keys or the mouse wheel, but you cannot scroll a chart vertically along the price axis using these keys. Why not? One of the things I do every day after market is scroll through my charts to review every signal I took and/or missed etc. I also do this to train my eye to see my signals as they are developing by scrolling the candles in one at a time from the right edge of the chart. You can do this exercise with market replay, but I find Market Replay slow, cumbersome, buggy and works only half of the time for me. So, I wrote this AutoHotKey script to scroll a chart vertically using the Up/Down Arrow keys, or Conrtrol-MouseWheel.

 
Code
;###############################################
;###
;### 1. Srcoll NinjaTrader Chart Vertically with Up/Down Arrow keys or Control-Mouse Wheel
;###
;###############################################

;###
;### Inits
;###
CoordMode, Mouse, Screen	;### Mouse positioning mode is for entire desktop
lastWheelTime  := 0


~Up::
   wheelDirection =  1
~Down::
   if ( wheelDirection == 0 ) {
      wheelDirection = -1
   }
lastWheelTime := 0

    ;### NT Chart?
  WinGetTitle, title, A	;### get Window title
  if ( not RegExMatch(title, ".*?\(.*?\).*?\d+/\d+/\d+") ) {
    return
  }

^WheelUp::
   if ( wheelDirection == 0 ) {
      wheelDirection := 1			;### Control Wheel Up
   }

^WheelDown::
   if ( wheelDirection == 0 ) {
      wheelDirection := -1			;### Control Wheel Down
   }

  if ( wheelDirection == 0 ) {
     return
  }

    ;### Restrict to 1 move per 0.5 seconds to prevent mouse wheel from flooding key stream and killing NinjaTrader
  ;zz := A_TickCount - lastWheelTime
  ;ToolTip, TickCount %A_TickCount% lastWheelTime %lastWheelTime% = %zz%, (Width)-500, 500
  if (A_TickCount - lastWheelTime < 500 ) {
    wheelDirection := 0
    return
  }

    ;### Not NT Chart
   WinGetTitle, title, A
   if ( not RegExMatch(title, ".*?\(.*?\).*?\d+/\d+/\d+") ) {
      if ( wheelDirection > 0 ) 
         Send {WheelLeft}
      else
         Send {WheelRight}

      wheelDirection = 0
      return
   }

   ;###
   ;### Scroll NT Chart Up/Down
   ;###
   ;### Get mouse position
  MouseGetPos, mouseX, mouseY,
  WinGetPos,   winX,   winY,  Width, Height, A
  dragX  := winX + Width  - 25
  dragY  := winY + Height - 100			;### winY+300 puts cursor on 'ENTRY' field if chart trader visible

    ;### Init
  SetMouseDelay, 0 
  BlockInput Mouse
  MouseMove, dragX, dragY, 0

    ;### Insure no buttons at drag location, in case chart trader is visible
  MouseGetPos, , , , controlName
  if ( RegExMatch(controlName, "i)(Button|Combo|Edit)") ) {
     BlockInput Off
     MsgBox Active Control '%controlName%' `n   found at window drag location %dragX%, %dragY%`n   Operation not performed
     MouseMove, mouseX, mouseY, 0
     wheelDirection = 0
     return
  }

    ;### Do up/down drag in right price scale
  Send {Escape}
  Send {Control Down}
  MouseClickDrag, Left, dragX, dragY, dragX, dragY-(50*wheelDirection)
  Send {Control Up}

    ;### Do up/down drag again in alternate location in case chart trader is visible
  dragX := dragX - 175
  Send {Escape}
  Send {Control Down}
  MouseClickDrag, Left, dragX, dragY, dragX, dragY-(50*wheelDirection)
  Send {Control Up}

  MouseMove, mouseX, mouseY, 0		;### Move mouse back to original position
  Send {Escape}
  BlockInput Off

    ;### Save wheel motion time
  lastWheelTime := A_TickCount

  wheelDirection = 0
return
By the way I also use a customized version of this awesome NT indicator to scroll charts properly like with the mouse like a truly first rate charting software vendor would implement:

https://futures.io/download/vip_elite_circle/985-download.html?view

Reply With Quote
The following 5 users say Thank You to monpere for this post:
 
  #15 (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,256 received


Morpheus View Post
Hi, I would like to experiment with this script but cannot get it to work. AutoHotKey complains about line 57, saying that "pwr.ResponseText" contains an illegal character. I am not a programmer but a quick search of your script shows no other reference to that variable. Can you tell me what I might be missing. I am using Windows XP SP3.

Thx

You are probably passing in a weird character to the function, or the website is returning a weird character. If you feel comfortable sharing the info, what is the url of the web page you are trying to access?

Reply With Quote
 
  #16 (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,256 received

Mouse Key Mappings

One of the things I do everyday during, and after market, is markup all my charts with every signal that occurred during the day. I generally use the NT Line Segment Tool, the Ellipse, and the Line Arrow tools to do the majority of this markup. I like the ellipse tool, because you can draw a straight horizontal line, a straight vertical line or a colored ellipse, all using the single ellipse tool. I combine these to show a trade as winner, loser, BE, trail stopped, etc. So, I created this script to remap my mouse buttons to switch between these tools. I use a 5 button mouse, and use the side buttons for this. Single click of the left side button selects the Ellipse tool, a Double Click selects the Line Arrow, a single click of the Right side button deselects any draw tool.

I have also programmed my Middle mouse button to place a trade ruler on the chart, with risk/reward and trade position sizing, but that functionality is programmed in this indicator: TradeRuler, indicator in the futures.io (formerly BMT) download section.

 
Code
;######################################
;###
;### Function key remapings
;###
;######################################

ntLine    = F2
ntArrow   = F3
ntEllipse = F4

;### Set Current NT draw tool
~F2:: 
  ntDrawTool := ntLine		;### Line Segment
return
~F4::
  ntDrawTool := ntEllipse	;### Elipse
return

;######################################
;###
;### Mouse key remapings
;###
;######################################

;### Mouse X2 button - ESC
XButton2::
    Send {Escape}
    lastEscTime := A_TickCount
return

;### Mouse X1 button - Change Ninja Drawing Tool
XButton1::
WinGetTitle, title, A	;### get Window title
if ( RegExMatch(title, ".*?\(.*?\).*?\d+/\d+/\d+") ) { ;### NT Chart?
     if (lastKeyCode = "XButton1" and A_TickCount - lastKeyTime < 500 ) {
       keyClickCount := keyClickCount + 1 
     }
     else {
       keyClickCount := 1
     }

        ;### Single Click - NinjaTrader Ellipse Drawing Tool
     if ( keyClickCount == 1 ) {
        Send {%ntDrawTool%}
     }
        ;### Double Click - NinjaTrader Arrow Drawing Tool
     else if ( keyClickCount == 2 ) {
        Send {%ntArrow%}
     }
}
lastKeyCode := "XButton1"
lastKeyTime := A_TickCount
return


Last edited by monpere; September 27th, 2012 at 03:40 PM.
Reply With Quote
The following 4 users say Thank You to monpere for this post:
 
  #17 (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,256 received

Save Chart or Desktop

Here's how I save my charts. Ctrl-S to save the current chart, Ctrl-Shift-S to save the entire desktop for multiple charts. The image names are automatically named using the chart name, the current date/time, and an optional user specified tag. This might help if you record charts in your journal. This naming convention allows me to list and review charts by date, instrument, or other specific criteria. Uses Microsoft Paint to save the chart window or desktop 'c:\tmp\' folder.

 
Code
;############################################################
;###
;### Save current chart or desctop image to c:\tmp folder
;###
;############################################################
save_type=

^+s::
save_type = (desktop)

^s::
WinGetActiveTitle, activeWin 
if ( GetKeyState("ScrollLock","T") and RegExMatch(activeWin, ".*?\(.*?\).*?\d+/\d+/\d+") )	;### NinjaTrader Chart or Control Center
{
  symbol := SubStr(activeWin,1,RegExMatch(activeWin, " ")-1)
  if ( RegExMatch(save_type, "desktop") ) 
    Send {PrintScreen}	;### Capture entire desktop for multiple charts
  else 
    Send !{PrintScreen}	;### Capture chart window
  Sleep 250

  run mspaint.exe,,Min,pid
  InputBox, tag, Save %save_type% Image Tag
  WinWait, ahk_pid %pid%, ,10

  IfWinExist, ahk_pid %pid%  
  {
    WinActivate 
    WinWaitActive
    WinGet, win_id, ID, A
    Send ^v
    WinMenuSelectItem, ahk_pid %pid%, , File, Save As,
    Sleep 1000
    SendInput c:\tmp\%symbol%_%tag%_%A_MMM%%A_DD%_%A_Hour%h%A_Min%m%A_Sec%.jpg{Enter}
    Sleep 500
    SendInput {y}
    Sleep 500
    SendInput {n}
    WinClose, ahk_id %win_id%
  }
  else  {
     MsgBox Could not start Microsoft Paint to save Print Screen
  }
}

save_type=
return

Reply With Quote
The following 6 users say Thank You to monpere for this post:
 
  #18 (permalink)
Elite Member
Rechovot
 
Futures Experience: Advanced
Platform: NinjaTrader
Broker/Data: CQG
Favorite Futures: Index,Currency and Energy futures
 
perryg's Avatar
 
Posts: 1,703 since Jan 2010
Thanks: 504 given, 6,257 received


monpere View Post
Here's how I save my charts. Ctrl-S to save the current chart, Ctrl-Shift-S to save the entire desktop for multiple charts. The image names are automatically named using the chart name, the current date/time, and an optional user specified tag. This might help if you record charts in your journal. This naming convention allows me to list and review charts by date, instrument, or other specific criteria. Uses Microsoft Paint to save the chart window or desktop 'c:\tmp\' folder.

 
Code
;############################################################
;###
;### Save current chart or desctop image to c:\tmp folder
;###
;############################################################
save_type=

^+s::
save_type = (desktop)

^s::
WinGetActiveTitle, activeWin 
if ( GetKeyState("ScrollLock","T") and RegExMatch(activeWin, ".*?\(.*?\).*?\d+/\d+/\d+") )	;### NinjaTrader Chart or Control Center
{
  symbol := SubStr(activeWin,1,RegExMatch(activeWin, " ")-1)
  if ( RegExMatch(save_type, "desktop") ) 
    Send {PrintScreen}	;### Capture entire desktop for multiple charts
  else 
    Send !{PrintScreen}	;### Capture chart window
  Sleep 250

  run mspaint.exe,,Min,pid
  InputBox, tag, Save %save_type% Image Tag
  WinWait, ahk_pid %pid%, ,10

  IfWinExist, ahk_pid %pid%  
  {
    WinActivate 
    WinWaitActive
    WinGet, win_id, ID, A
    Send ^v
    WinMenuSelectItem, ahk_pid %pid%, , File, Save As,
    Sleep 1000
    SendInput c:\tmp\%symbol%_%tag%_%A_MMM%%A_DD%_%A_Hour%h%A_Min%m%A_Sec%.jpg{Enter}
    Sleep 500
    SendInput {y}
    Sleep 500
    SendInput {n}
    WinClose, ahk_id %win_id%
  }
  else  {
     MsgBox Could not start Microsoft Paint to save Print Screen
  }
}

save_type=
return

Very useful. I have noticed that although you request the image to be a jpg file, it is always a bmp file with the extension jpg. I tried changing to png file in oder to get a smaller file, but it still saves very large bmp files.
Is there a way around this ?

Reply With Quote
 
  #19 (permalink)
Elite Member
San Diego, California
 
Futures Experience: Intermediate
Platform: Sierra Chart
Broker/Data: IB, OEC, Optimus, DDT
Favorite Futures: ES, ZN
 
Posts: 221 since Jun 2010
Thanks: 513 given, 157 received


monpere View Post
Here's how I save my charts. Ctrl-S to save the current chart, Ctrl-Shift-S to save the entire desktop for multiple charts. The image names are automatically named using the chart name, the current date/time, and an optional user specified tag. This might help if you record charts in your journal. This naming convention allows me to list and review charts by date, instrument, or other specific criteria. Uses Microsoft Paint to save the chart window or desktop 'c:\tmp\' folder.

 
Code
;############################################################
;###
;### Save current chart or desctop image to c:\tmp folder
;###
;############################################################
save_type=

^+s::
save_type = (desktop)

^s::
WinGetActiveTitle, activeWin 
if ( GetKeyState("ScrollLock","T") and RegExMatch(activeWin, ".*?\(.*?\).*?\d+/\d+/\d+") )	;### NinjaTrader Chart or Control Center
{
  symbol := SubStr(activeWin,1,RegExMatch(activeWin, " ")-1)
  if ( RegExMatch(save_type, "desktop") ) 
    Send {PrintScreen}	;### Capture entire desktop for multiple charts
  else 
    Send !{PrintScreen}	;### Capture chart window
  Sleep 250

  run mspaint.exe,,Min,pid
  InputBox, tag, Save %save_type% Image Tag
  WinWait, ahk_pid %pid%, ,10

  IfWinExist, ahk_pid %pid%  
  {
    WinActivate 
    WinWaitActive
    WinGet, win_id, ID, A
    Send ^v
    WinMenuSelectItem, ahk_pid %pid%, , File, Save As,
    Sleep 1000
    SendInput c:\tmp\%symbol%_%tag%_%A_MMM%%A_DD%_%A_Hour%h%A_Min%m%A_Sec%.jpg{Enter}
    Sleep 500
    SendInput {y}
    Sleep 500
    SendInput {n}
    WinClose, ahk_id %win_id%
  }
  else  {
     MsgBox Could not start Microsoft Paint to save Print Screen
  }
}

save_type=
return

Is there a way to auto capture part of the screen based on coordinates and dimensions (x,y,w,h)?

Reply With Quote
 
  #20 (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,256 received



perryg View Post
Very useful. I have noticed that although you request the image to be a jpg file, it is always a bmp file with the extension jpg. I tried changing to png file in oder to get a smaller file, but it still saves very large bmp files.
Is there a way around this ?

In Vista the default save type rom MS Paint is .jpg, it might be .bmp in Windows XP. I can add a couple of lines to force to save as .jpg or .png


Last edited by monpere; October 9th, 2012 at 12:16 AM.
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 09:09 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-28 in 0.14 seconds with 20 queries on phoenix via your IP 54.162.50.232