Dark Theme
Light Theme
Trading Articles
Article Categories
Article Tools
Welcome to NexusFi: the best trading community on the planet, with over 150,000 members Sign Up Now for Free
Genuine reviews from real traders, not fake reviews from stealth vendors
Quality education from leading professional traders
We are a friendly, helpful, and positive community
We do not tolerate rude behavior, trolling, or vendors advertising in posts
We are here to help, just let us know what you need
You'll need to
register in order to view the content of the threads and start contributing to our community.
It's free for basic access, or support us by becoming an Elite Member -- see if you qualify for a discount below.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
Updated June 18, 2023
Top Posters
looks_one
monpere
with 23 posts (98 thanks)
looks_two
traderap101
with 13 posts (12 thanks)
looks_3
trendisyourfriend
with 12 posts (0 thanks)
looks_4
perryg
with 6 posts (2 thanks)
Best Posters
looks_one
monpere
with 4.3 thanks per post
looks_two
traderap101
with 0.9 thanks per post
looks_3
SilverFut
with 0.7 thanks per post
looks_4
perryg
with 0.3 thanks per post
trending_up
39,395 views
thumb_up
115 thanks given
group
35 followers
forum
64 posts
attach_file
10 attachments
October 8th, 2012, 07:33 PM
Bala, PA, USA
Experience: Intermediate
Platform: NinjaTrader
Broker: Mirus, IB
Trading: SPY, Oil, Euro
Posts: 1,854 since Jul 2010
Thanks Given: 300
Thanks Received: 3,373
omaha786
Is there a way to auto capture part of the screen based on coordinates and dimensions (x,y,w,h)?
I don't think this can be done using normal windows functionality. But if you use a program like Irfanview instead of MS Paint, it has an option to capture the current monitor only rather then the entire extended desktop if you are using multiple monitors.
Can you help answer these questions from other members on NexusFi?
Best Threads (Most Thanked) in the last 7 days on NexusFi
October 9th, 2012, 01:17 AM
Rechovot
Experience: Advanced
Platform: NinjaTrader
Broker: CQG
Trading: Index,Currency and Energy futures
Posts: 1,644 since Jan 2010
Thanks Given: 508
Thanks Received: 6,288
monpere
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
It would be very helpful if you could add those lines to save in png format.
October 9th, 2012, 09:07 AM
Bala, PA, USA
Experience: Intermediate
Platform: NinjaTrader
Broker: Mirus, IB
Trading: SPY, Oil, Euro
Posts: 1,854 since Jul 2010
Thanks Given: 300
Thanks Received: 3,373
perryg
It would be very helpful if you could add those lines to save in png format.
To save the file in .png format replace the following line:
SendInput c:\tmp\%symbol%_%tag%_%A_MMM%%A_DD%_%A_Hour%h%A_Min%m%A_Sec%.jpg{Enter}
with this line:
SendInput c:\tmp\%symbol%_%tag%_%A_MMM%%A_DD%_%A_Hour%h%A_Min%m%A_Sec%{Tab}p{Enter}
October 9th, 2012, 12:39 PM
Rechovot
Experience: Advanced
Platform: NinjaTrader
Broker: CQG
Trading: Index,Currency and Energy futures
Posts: 1,644 since Jan 2010
Thanks Given: 508
Thanks Received: 6,288
monpere
To save the file in .png format replace the following line:
SendInput c:\tmp\%symbol%_%tag%_%A_MMM%%A_DD%_%A_Hour%h%A_Min%m%A_Sec%.jpg{Enter}
with this line:
SendInput c:\tmp\%symbol%_%tag%_%A_MMM%%A_DD%_%A_Hour%h%A_Min%m%A_Sec%{Tab}p{Enter}
Works like a charm. Thanks
November 3rd, 2012, 12:18 PM
Bala, PA, USA
Experience: Intermediate
Platform: NinjaTrader
Broker: Mirus, IB
Trading: SPY, Oil, Euro
Posts: 1,854 since Jul 2010
Thanks Given: 300
Thanks Received: 3,373
By the way, all the code in this thread can be combined into one script. All the code in the thread is extracted from one single script (Included below) that I run once in the morning when I turn on my computer. You can optionally run it in your autoexec.bat file or put in in your Startup folder.
Code
;###
;### AutoHotKey hotkey file for Ninjatrader related trading
;###
;### User Date Description
;### ------ -------- -------------
;### xxxxxx Dec 2010 Created
;###
;###
;### Inits
;###
CoordMode, Mouse, Screen ;### Mouse positioning mode is for entire desktop
BlockInput SendAndMouse
lastKeyCode := 0
lastKeyTime := 0
lastWheelTime := 0
lastEscTime := 0
lastNTwindow := 0
keyClickCount := 0
wheelDirection := 0
ntDrawTool := "F4" ;### Default to Line Segment draw tool
restoreFile := "C:\TMP\restore_workspace"
;### Number of NinjaTrader monitors. Monitors affects key/chart assignment
NTmonitors := 3
if 0 > 0 ;### Any command line arguments?
{
NTmonitors = %1% ;### 1st command line argument is number of monitors to use for chart trading
}
;######################################
;###
;### Get Monitor and Chart positions based on number of
;### monitors and size of each monitor
;###
;######################################
SysGet, Monitors, MonitorCount
Loop, %Monitors%
{
SysGet, M%A_Index%_Name, MonitorName, %A_Index%
SysGet, Monitor%A_Index%, MonitorWorkArea, %A_Index%
M%A_Index%_Width := Monitor%A_Index%Right - Monitor%A_Index%Left
M%A_Index%_Height := Monitor%A_Index%Bottom - Monitor%A_Index%Top
desktopWidth += M%A_Index%_Width
C1 := Monitor%A_Index%Left + 100
C2 := Monitor%A_Index%Right - 100
;### Left Monitor
if ( Monitor%A_Index%Left < 0 ) {
M1C1 = %C1%, 650 ;### Left Monitor, Chart 1
M1C2 = %C2%, 650 ;### Left Monitor, Chart 2
}
;### Center Monitor
else if ( Monitor%A_Index%Left == 0 ) {
M2C1 = %C1%, 650 ;### Left Monitor, Chart 1
M2C2 = %C2%, 650 ;### Left Monitor, Chart 2
}
;### Right Monitor
else {
M3C1 = %C1%, 650 ;### Left Monitor, Chart 1
M3C2 = %C2%, 650 ;### Left Monitor, Chart 2
}
}
;###
;### Assign Keys to Monitors/Charts
;###
;### Default for 3 monitors
myNumPadEnter := M3C1
myDblNumPadEnter := M3C1
myNumPadInsert := M2C2
myDblNumPadInsert := M1C2
myKeyPageUp := M3C1
myKeyPageDn := M3C1
myKeyHome := M2C2
myKeyEnd := M2C2
myKeyInsert := M1C2
myKeyDelete := M1C2
;### Reassign keys if 2 or 3 monitors used for NT charts
if ( NTmonitors == 2 ) {
myNumPadEnter := M2C2
myDblNumPadEnter := M2C2
myNumPadInsert := M2C1
myDblNumPadInsert := M1C2
myKeyPageDn := M2C2
myKeyPageUp := M2C2
myKeyEnd := M2C1
myKeyHome := M2C1
myKeyInsert := M1C2
myKeyDelete := M1C2
}
else
if ( NTmonitors == 1 ) {
myNumPadEnter := M1C1
myDblNumPadEnter := M1C1
myNumPadInsert := M1C2
myDblNumPadInsert := M1C2
myKeyPageDn := M1C2
myKeyPageUp := M1C2
myKeyEnd := M1C1
myKeyHome := M1C1
myKeyInsert := M1C1
myKeyDelete := M1C1
}
;######################################
;###
;### Check mam.econonday.com and Forex Factory
;### for FOMC/Bernake events for today
;###
;######################################
get_news_events("FOMC,Bernanke") ;### Get Fed events
get_news_events( events )
{
;### EconoDay
msg :=""
str = http://mam.econoday.com/byday.asp?cust=mam&day=%A_DD%&month=%A_MM%&year=%A_YYYY%
str := get_url(str)
;str := get_url("http://mam.econoday.com/byday.asp?cust=mam&day=31&month=8&year=2012")
Loop, parse, events, `, , %A_Space%%A_Tab%
{
pattern := "iP)\d+:\d+.*?" . A_LoopField
index := RegExMatch(str, pattern)
if ( index > 0 ) {
str := SubStr(str,index)
msg := "Eononday Event`r`n" . SubStr(str,1,RegExMatch(str, "\n")) . "`r`n`r`n"
}
}
;### ForexFactory
;str := get_url("http://www.forexfactory.com/index.php?day=aug31.2012")
str := get_url("http://www.forexfactory.com")
Loop, parse, events, `, , %A_Space%%A_Tab%
{
pattern := "iP)\d+:\d+.*?" . A_LoopField
index := RegExMatch(str, pattern)
if ( index > 0 ) {
str := SubStr(str,index)
msg := msg . "ForexFactory Event`r`n" . SubStr(str,1,RegExMatch(str, "\n")) . "`r`n`r`n"
}
}
if ( msg != "" ) {
MsgBox %msg%
}
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
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")
}
;######################################
;###
;### Send NinjaTrader Key
;###
;######################################
send_ninja_key( key, monitorKey, ninjaKey )
{
global ;### Default to global variables
local ninjaActive := 0
WinGetActiveTitle, activeWin
if ( RegExMatch(activeWin, ".*?\(.*?\).*?\d+/\d+/\d+") or RegExMatch(activeWin, "Control Center - ") ) ;### NinjaTrader Chart or Control Center
;IfWinExist Control Center ;### Insure NinjaTrader is running
{
if ( GetKeyState("ScrollLock","T") ) { ;### Insure Scroll Lock Key is ON
ninjaActive := 1
local modifier := ""
if ( GetKeyState("Control", "P") ) { ;### Control Key pressed?
modifier = %modifier%^
}
if ( GetKeyState("Shift", "P") ) { ;### Shift Key Pressed?
modifier = %modifier%+
}
if ( lastKeyCode = %key% and A_TickCount - lastKeyTime < 500 ) {
keyClickCount := keyClickCount + 1
}
else {
keyClickCount := 1
}
if ( keyClickCount == 1 ) { ;### Single Click - Activate chart
screenXY := %monitorKey%
Send {Click %screenXY%, Right}{Escape}
}
else if ( keyClickCount >= 3 ) { ;### Tripple Click - Execute Entry Order
Send {%ninjaKey%}{%ninjaKey%}{%ninjaKey%}
}
}
KeyWait, %key% ;### Prevent key continuous repeat when holding the key down
lastKeyCode := %key%
lastKeyTime := A_TickCount
}
;### NT keys are not Activated, send normal key
if ( ninjaActive == 0 ) {
Send {%key%}
}
return
}
;#############################################
;###
;### Keyboard multi-monitor hotkey remapings
;###
;#############################################
;#
;### Disable the ALT-C, ALT-E, ALT-P, they move windows around monitors. I don't want that funcitonality
!c::
!e::
!p::
return
;######################################
;###
;### Function key remapings
;###
;######################################
;### Set Crrent NT draw tool
~F2::
ntDrawTool = F2 ;### Line Segment
return
~F4::
ntDrawTool = F4 ;### Elipse
return
;######################################
;###
;### Mouse key remapings
;###
;######################################
;### Mouse X1 Key - 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 {F4}
Send {%ntDrawTool%}
}
;### Double Click - NinjaTrader Arrow Drawing Tool
else if ( keyClickCount == 2 ) {
Send {F3}
}
}
lastKeyCode := "XButton1"
lastKeyTime := A_TickCount
return
;######################################
;###
;### NinjaTrader Buy/Sell Hot keys
;###
;######################################
;###
;### 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
Insert::
^Insert::
^+Insert::
send_ninja_key("Insert", "myKeyInsert", "NumPadAdd")
return
Delete::
^Delete::
^+Delete::
send_ninja_key("Delete", "myKeyDelete", "NumPadSub")
return
Home::
^Home::
^+Home::
send_ninja_key("Home", "myKeyHome", "NumPadAdd")
return
End::
^End::
^+End::
send_ninja_key("End", "myKeyEnd", "NumPadSub")
return
PgUp:: ;### PageUp
^PgUp:: ;### Control-PageUp
^+PgUp:: ;### Control-Shift-PageUp
send_ninja_key("PgUp", "myKeyPageUp", "NumPadAdd") ;### Activate Chart 4
return
PgDn::
^PgDn::
^+PgDn::
send_ninja_key("PgDn", "myKeyPageDn", "NumPadSub")
return
;### Middle Mouse Button
;### This is to prevent NT the mini data box popup error message when a chart object is currently selected
MButton::
if (A_TickCount - lastWheelTime > 500 ) { ;### Prevents MButton recursion
WinGetTitle, title, A ;### Get Active Window title
if ( RegExMatch(title, ".*?\(.*?\).*?\d+/\d+/\d+") ) { ;### NT Chart window?
if ( title = lastNTwindow) {
Send {Escape} ;### Send ESC first to de-select any selected chart object
}
}
lastWheelTime := A_TickCount ;### Save Middle Button click time, to prevent recursion
Send {MButton} ;### Send Middle button
lastNTwindow = %title%
}
return
;####################################
;###
;### Switch Monitors
;###
;###################################
;### Keypad Enter with ScrollLock
;### Single Click - Right Most Monitor Right Most chart C3
;### Double Click - Right Most Monitor Left chart C2
NumpadEnter::
IfWinExist Control Center
if ( GetKeyState("ScrollLock", "T") ) {
if ( lastKeyCode = "NumpadEnter" and A_TickCount - lastKeyTime < 500 ) {
keyClickCount := keyClickCount + 1
}
else {
keyClickCount := 1
}
;### Single Click - Right Most Monitor, Right Most chart C3
if ( keyClickCount == 1 ) {
Send {Click %myNumPadEnter%, Right}{Escape}
}
;### Double Click - Right Most Monitor, Left Chart C2
else if ( keyClickCount == 2 ) {
Send {Click %myDblNumPadEnter%, Right}{Escape}
}
}
lastKeyCode := "NumpadEnter"
lastKeyTime := A_TickCount
return
;### Keypad 0 with ScrollLock
;### Single Click - Center Left Chart C1
;### Double Click - Center Left Chart C0
;### Triple Click - Center of Left Most Monitor (Laptop)
Numpad0::
NumpadIns::
IfWinExist Control Center
if ( GetKeyState("ScrollLock", "T") ) {
if (lastKeyCode = "NumpadIns" and A_TickCount - lastKeyTime < 500 ) {
keyClickCount := keyClickCount + 1
}
else {
keyClickCount := 1
}
;### Single Click - Center Right Chart C1
if ( keyClickCount == 1 ) {
Send {Click %myNumPadInsert%, Right}{Escape}
}
;### Double Click - Center Left Chart C0
else if ( keyClickCount == 2 ) {
Send {Click %myDblNumPadInsert%, Right}{Escape}
}
;### Tripple click - Center of Left Most Monitor (Laptop)
else if ( keyClickCount == 3 ) {
Click -650, 400,Right
Sleep, 200
Send {Escape}
}
}
lastKeyCode := "NumpadIns"
lastKeyTime := A_TickCount
return
;###############################################
;###
;### Scroll NT Chart Up/Down
;###
;### Control-Mouse Wheel
;### XButton2-Mouse Wheel
;###
;### 1. Srcoll NinjaTrader Chart Vertically
;### 2. Srcoll Firefox Horizontally
;###
;###############################################
~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
}
;### NT Chart?
WinGetTitle, title, A
if ( not RegExMatch(title, ".*?\(.*?\).*?\d+/\d+/\d+") ) { ;### Not NT Chart
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
;### End Scroll Up/Down
;######################################
;###
;### Save current chart picture
;###
;######################################
;### Control-P - Print a chart window
^p::
WinGetActiveTitle, activeWin
if ( GetKeyState("ScrollLock","T") and RegExMatch(activeWin, ".*?\(.*?\).*?\d+/\d+/\d+") ) ;### NinjaTrader Chart or Control Center
{
symbol := SubStr(activeWin,1,RegExMatch(activeWin, " ")-1)
Send !{PrintScreen}
Sleep 250
run mspaint.exe,,Min,pid
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%_%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
}
}
return
;######################################
;###
;### Save/Restore NinjaTrader window layout
;###
;######################################
;### Control-F3 - Also defined inside NinjaTrader as Save Workspace
~^F3::
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
;###
;### Ninjatrader 'Save Workspace' does not save files to disk.(bug)
;### Using'Save Workspace As' here instead to bypass the bug until NT provides a fix
;### Save wokspace as 'ztmp', then save again with original workspace name
;###
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}
;WinMenuSelectItem, %title%, , File, Workspaces, Save Workspace As,
;SendInput ztmp{Enter}{y}
;WinMenuSelectItem, , , File, Workspaces, Save Workspace As,
;SendInput %workspaceName%{Enter}{y}
}
}
}
}
return
December 16th, 2012, 11:27 PM
Bala, PA, USA
Experience: Intermediate
Platform: NinjaTrader
Broker: Mirus, IB
Trading: SPY, Oil, Euro
Posts: 1,854 since Jul 2010
Thanks Given: 300
Thanks Received: 3,373
I stumbled upon this website netfonds.no where you can download free historical tick data for equities. I use Interactive Brokers which does not provide historical tick data, so i have to record tick data from the live market with NT by putting a list of stocks in my market analyzer. There should be no need to do that any more by being able to download historical data on demand from this website.
I wrote this AutoHotkey script to download data for a stock symbol, and automatically convert the data into NinjaTrader import file format.
Usage:
get_netfonds_tick_data.ahk Symbol.Exchange YYYYMMDD_Date
Symbol: Stock symbol
Exchange: AMEX=A, NYSE =N, NASDAQ =O
YYYYMMDD_Date: Date in YYYYMMDD format
Example: get_netfonds_tick_data.ahk SPY.A 20121125
The file name created is <Symbol>.txt, which can be imported directly into NT. You need to use GMT+1 timezone to import since the website is in Norway, so the ticks are time stamped with that timezone.
Code
;###
;###
;### Get historical tick dta from www.netfonds.no and convert to NinjaTrader Tick Import format
;###
;### www.nefonds.no website is in Norway, so data must be inported in NT using their timezone GMT+1
;###
;###
if 0 < 2
{
MsgBox Usage:`n`nget_netfonds_tick_data.ahk Symbol.Exchange YYYYMMDD_Date`n`nSymbol: `t`tStock symbol`nExchange: `tAMEX=A, NYSE=N, NASDAQ=O`nYYYYMMDD_Date: `tDate in YYYYMMDD format`n`nExample: get_netfonds_tick_data.ahk SPY.A 20121125
ExitApp
}
;### Get command line parameters
date = %A_YYYY%%A_MM%%A_DD%
i := 1
Loop, %0% {
if ( i == 1) {
symbol := %A_Index%
}
if ( i == 2) {
date := %A_Index%
}
i++
}
ToolTip, . ...Getting %date% %symbol% Tick Data... `n`n , 300, 500
str = http://hopey.netfonds.no/tradedump.php?date=%date%&paper=%symbol%&csv_format=txt
if ( !RegExMatch(symbol, "\..") ) {
MsgBox Invalid symbol '%symbol%'. Please specify symbols as <Symbol>.<Exchange> `n`nExample: SLV.A, C.N, FB.O`n`n N=NYSE, A=AMEX, O=NASDAQ
ExitApp
}
symbol := SubStr(symbol,1, RegExMatch(symbol, "\..")-1)
;savefile = c:\tmp\%symbol%.txt
savefile = %symbol%.txt
FileDelete, %savefile%
buffer :=""
;### Get data from netfonds web page
str := get_url(str)
len := StrLen(str)
i := 1
n := RegExMatch(str, "\d\d\d\d\d\d\d\dT") ;### skip header line
;### Check returned data
if ( n <= 0 ) {
MsgBox Unrecognized data format returned from web page.`n`no Verify user parameters
ExitApp
}
Loop, %len% {
buf := SubStr(str,n, 100)
line := SubStr(buf,1, RegExMatch(buf, " \d\d\d\d\d\d\d\dT")-1)
;### Get data
RegExMatch(line, "^.*?(\d\d\d\d)(\d\d)(\d\d)T(\d\d)(\d\d)(\d\d)\s+(.*?)\s+(.*?)\s+", Match)
year := Match1
month := Match2
day := Match3
hour := Match4
min := Match5
sec := Match6
price := Match7
vol := Match8
;### Format data into NinjaTrader import file format
buffer = %buffer%%year%%month%%day% %hour%%min%%sec%;%price%;%vol%`r`n
i ++
linelen := StrLen(line)
n += linelen +1
;### Feedback
if ( mod(i, 500 ) == 0 ) {
ToolTip, . ...Processing %symbol% Ticks...`n`n%symbol% %A_Index%: %year%%month%%day% %hour%%min%%sec%;%price%;%vol% `n`n, 300, 500
;### Write buffer after every 50 lines or so
FileAppend, %buffer%, %savefile%
buffer := ""
}
if ( n > len) {
break ;### Done
}
}
;### Write any left over data
FileAppend, %buffer%, %savefile%
MsgBox %i% entries processed.`n`no Import files into NinjaTrader using GMT+1 Timezone
Exitapp
;######################################
;###
;### 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
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")
}
^x::
MsgBox, 3, , . Terminate program?, 1000
IfMsgBox Yes
{
ExitApp
}
return
December 21st, 2012, 04:37 PM
Bala, PA, USA
Experience: Intermediate
Platform: NinjaTrader
Broker: Mirus, IB
Trading: SPY, Oil, Euro
Posts: 1,854 since Jul 2010
Thanks Given: 300
Thanks Received: 3,373
Lately my eyes have been bothering me from staring at the screen so long. Maybe my age is catching up to me. I learned about the 20/20/20 vision rule for people who work at computer screens all day. It says, to prevent eye fatigue, and prevent eye muscles to atrophy at the focus length of the eye to the screen, every 20 minutes, take the eyes off the screen and focus on an object 20 feet away for at least 20 seconds.
Given how focus I generally am once I am at the computer, I find that genrall 2 or 3 hours will go by without me even noticing. So, I wrote this little piece of code to remind me every 30 minutes to take an eye break. It just pops up a message on the screen. If I don;t hit OK, the pop -up is removee after 15 seconds. When I get the pop=up, I will get up, walk away from the computer, stretch my legs, do my eye exercises, etc. for about a minute or so.
Code
;#############################################
;###
;### 30 Minute Eye Break Timer
;###
;#############################################
set_timers() ;### Set 30 min eye break timer
^x::
MsgBox, 3, , . Terminate Eyebreak Timer?, 1000
IfMsgBox Yes
{
ExitApp
}
return
set_timers() {
SetTimer, EyeBreak, 1800000
}
return
EyeBreak:
MsgBox, 1, ,. Eye Break`n`n [ %A_Hour%:%A_Min% ], 15
return
December 28th, 2012, 11:13 AM
Knoxville, TN
Experience: Beginner
Platform: NT7
Trading: SPY
Posts: 34 since Dec 2012
Thanks Given: 12
Thanks Received: 22
Thanks so much for all of these scripts.
Yes, it's very important to protect the eyes. Great idea for a script. I used to get bad eyestrain from prolonged sessions on the computer but I don't anymore thanks to getting a good pair of glasses. I have a prescription pair with a slight zoom in magnification (so my eyes don't strain as hard to read stuff on the screen) + anti-glare + they're shaded yellow which is nice (the brand is Gunnar).
But anyway, I'm a tad bit confused about the Cursor Buy/Sell script. When I go under the price and do left mouse click + Control-B, it works, and enters a buy limit. When I go over the price and do left mouse click + Control-S, nothing happens (besides that really quick window pop up for entering the order that closes a millisecond later). Strange how one would work and not the other.
Any idea what's going on?
December 28th, 2012, 12:33 PM
Bala, PA, USA
Experience: Intermediate
Platform: NinjaTrader
Broker: Mirus, IB
Trading: SPY, Oil, Euro
Posts: 1,854 since Jul 2010
Thanks Given: 300
Thanks Received: 3,373
lllusion
Thanks so much for all of these scripts.
Yes, it's very important to protect the eyes. Great idea for a script. I used to get bad eyestrain from prolonged sessions on the computer but I don't anymore thanks to getting a good pair of glasses. I have a prescription pair with a slight zoom in magnification (so my eyes don't strain as hard to read stuff on the screen) + anti-glare + they're shaded yellow which is nice (the brand is Gunnar).
But anyway, I'm a tad bit confused about the Cursor Buy/Sell script. When I go under the price and do left mouse click + Control-B, it works, and enters a buy limit. When I go over the price and do left mouse click + Control-S, nothing happens (besides that really quick window
pop up for entering the order that closes a millisecond later). Strange how one would work and not the other.
Any idea what's going on?
All it is doing is duplicating the keystrokes a user would do to enter a Sell Limit order above the price. Try do this manually and make sure this is working manually using Right-Click, ten Press 's', then press Enter. If that works, then it may be a timing issue, if the keystrokes are being sent to fast for you system. If it's a timing issue, you can try the statement 'SetKeyDelay, 500' at the top of the script
December 28th, 2012, 01:14 PM
Knoxville, TN
Experience: Beginner
Platform: NT7
Trading: SPY
Posts: 34 since Dec 2012
Thanks Given: 12
Thanks Received: 22
I did it manually and it worked so it probably is indeed a timing issue. Here's your code I have entered in:
Quoting
;######################################
;###
;###
NinjaTrader Buy/Sell Hot keys
;###
;######################################
;###
;### 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
Insert::
^Insert::
^+Insert::
send_ninja_key("Insert", "myKeyInsert", "NumPadAdd")
return
Delete::
^Delete::
^+Delete::
send_ninja_key("Delete", "myKeyDelete", "NumPadSub")
return
Home::
^Home::
^+Home::
send_ninja_key("Home", "myKeyHome", "NumPadAdd")
return
End::
^End::
^+End::
send_ninja_key("End", "myKeyEnd", "NumPadSub")
return
PgUp:: ;### PageUp
^PgUp:: ;### Control-PageUp
^+PgUp:: ;### Control-Shift-PageUp
send_ninja_key("PgUp", "myKeyPageUp", "NumPadAdd") ;### Activate Chart 4
return
PgDn::
^PgDn::
^+PgDn::
send_ninja_key("PgDn", "myKeyPageDn", "NumPadSub")
return
;### Middle Mouse Button
;### This is to prevent NT the mini data box popup error message when a chart object is currently selected
MButton::
if (A_TickCount - lastWheelTime > 500 ) { ;### Prevents MButton recursion
WinGetTitle, title, A ;### Get Active Window title
if ( RegExMatch(title, ".*?\(.*?\).*?\d+/\d+/\d+") ) { ;### NT Chart window?
if ( title = lastNTwindow) {
Send {Escape} ;### Send ESC first to de-select any selected chart object
}
}
lastWheelTime := A_TickCount ;### Save Middle Button click time, to prevent recursion
Send {MButton} ;### Send Middle button
lastNTwindow = %title%
}
return
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.
Last Updated on June 18, 2023