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
38,972 views
thumb_up
115 thanks given
group
35 followers
forum
64 posts
attach_file
10 attachments
June 10th, 2023, 03:14 PM
London UK
Posts: 18 since Jul 2022
Thanks Given: 3
Thanks Received: 16
Can you post an image of your equivalent Control Center window. I am curious as to why your Tools menu co-ordinates on Control Center are different to my version of NT8.
To identify co-ordinate positions on a Window, run the program AutoHotkey Window Spy found in the AutoHotkey installation
"C:\Program Files\AutoHotkey\WindowSpy.ahk"
This should also be listed under Windows Start menu for AutoHotkey
Hover your mouse over the Nt8 Control Center to find the co-ordinates of the Tools menu.
However rather than go down this path, if others also encounter similar issues because of layout changes between different versions of NT8, I can change the script to work on an open Historical Data window which the user has to manually open before running the script.
June 10th, 2023, 03:23 PM
Quebec Canada
Market Wizard
Experience: Intermediate
Platform: NinjaTrader
Broker: AMP/CQG
Trading: ES, NQ, YM
Frequency: Daily
Duration: Minutes
Posts: 4,530 since Oct 2009
Thanks Given: 4,183
Thanks Received: 6,030
traderap101
Can you post an image of your equivalent Control Center window. I am curious as to why your Tools menu co-ordinates on Control Center are different to my version of NT8.
.
June 10th, 2023, 03:27 PM
London UK
Posts: 18 since Jul 2022
Thanks Given: 3
Thanks Received: 16
trendisyourfriend
Ok, run the WindowSpy program, select the Control Center window so it is Active in Windows , hover your mouse over the centre of the Tools section and tell me what co-ordinates you get in the "Mouse Position" section under "Window"
"
June 10th, 2023, 03:36 PM
Quebec Canada
Market Wizard
Experience: Intermediate
Platform: NinjaTrader
Broker: AMP/CQG
Trading: ES, NQ, YM
Frequency: Daily
Duration: Minutes
Posts: 4,530 since Oct 2009
Thanks Given: 4,183
Thanks Received: 6,030
traderap101
Ok, run the WindowSpy program, select the Control Center window so it is Active in Windows , hover your mouse over the centre of the Tools section and tell me what co-ordinates you get in the "Mouse Position" section under "Window"
"
333,12 between the two letters 'o' of Tools
The other mouse click for 'Get Market Replay Data' :
/* Select Instrument Field */
MouseClick("Left", 30, 625)
Mine is at 18, 629
June 10th, 2023, 03:47 PM
London UK
Posts: 18 since Jul 2022
Thanks Given: 3
Thanks Received: 16
OK, it looks like there are subtle changes in the window layout between different versions of NinjaTrader . The following variables are the positions the script uses for mouse clicks and download button status. These will need to be checked for their co-ordinate positions for a users NT8 version if it's not V8.1.1.1.
These can be found through AutoHotkey Window Spy C:\Program Files\AutoHotkey\WindowSpy.ahk and then the code will need to be changed.
Code
/* Tools Menu on Control Center */
XTools := 250
YTools := 10
/* Rotating triangle on Historial Data for Get Market Replay data */
XRotatingTriangle := 35
YRotatingTriangle := 630
/* Instrument field on Historical Data window */
XInstrument := 30
YInstrument := 625
/* Download button */
XDownloadButton := 645
YDownloadButton := 610
I will have a think about whether there is an alternative way to find these positions programmatically for the next version.
Thanks.
June 10th, 2023, 05:11 PM
Quebec Canada
Market Wizard
Experience: Intermediate
Platform: NinjaTrader
Broker: AMP/CQG
Trading: ES, NQ, YM
Frequency: Daily
Duration: Minutes
Posts: 4,530 since Oct 2009
Thanks Given: 4,183
Thanks Received: 6,030
traderap101
OK, it looks like there are subtle changes in the window layout between different versions of
NinjaTrader . The following 3 code fragments are the different mouse clicks in the script. These will need to be checked for their co-ordinate positions for a users installation. Once these have been found through Window Spy, then the code will need to be changed.
.
The script works perfectly now with these settings:
I needed to modify three mouseclick coordinates and another one for the BG color of the download button.
Code
MyDebug("Message", "Found Control Center window")
WinActivate
Sleep SleepBetweenActions / 2
/* Click Tools menu item */
MouseClick("Left", 333, 12)
---
if (WinWait(HistoricalData, , 5)) {
MyDebug("Message", "Opened " HistoricalData " window")
WinActivate
/* Expand the rotating triangle for Get Market Replay data */
MouseClick("Left", 35, 630)
Sleep SleepBetweenActions
---
if (WinExist(HistoricalData)) {
WinActivate
; Skip weekend days based on user configuration
if ((SkipSaturday and !StrCompare(FormatTime(ProcessDate, "WDAY"), "7")) or (SkipSunday and !StrCompare(FormatTime(ProcessDate, "WDAY"), "1"))) {
MyDebug("Skipping", Instrument " for date " FormatTime(ProcessDate, "ShortDate") " as it is a weekend skip date")
ProcessDate := DateAdd(ProcessDate, 1, "Days")
continue
}
MyDebug("Processing", Instrument " for date " FormatTime(ProcessDate, "ShortDate") "")
/* Select Instrument Field */
MouseClick("Left", 68, 624)
---
/* Get colour of a download button pixel before presssing enter as this pixel color will be checked to see if download has finished */
BeforeColor := PixelGetColor(817, 659)
June 10th, 2023, 05:24 PM
Quebec Canada
Market Wizard
Experience: Intermediate
Platform: NinjaTrader
Broker: AMP/CQG
Trading: ES, NQ, YM
Frequency: Daily
Duration: Minutes
Posts: 4,530 since Oct 2009
Thanks Given: 4,183
Thanks Received: 6,030
Do you think you could adapt your script to download historical datas ?
Ideally, here is what i would need:
Given a defined list of instruments, i need to download data from a specific date in the past to now using a 1 minute chart.
Then, once the minute data have been downloaded, we repeat the process but this time using a 500 tick chart .
June 10th, 2023, 05:52 PM
Quebec Canada
Market Wizard
Experience: Intermediate
Platform: NinjaTrader
Broker: AMP/CQG
Trading: ES, NQ, YM
Frequency: Daily
Duration: Minutes
Posts: 4,530 since Oct 2009
Thanks Given: 4,183
Thanks Received: 6,030
I tried to run your script to download 2 days and for 3 instruments. It just processes 1 instrument, the 1st in the list and for 1 day. After that, i see no activity going on and if i try to bring another window in front, the script brings the historical data window in front but still nothing happens. I need to close the historicacl data window to force the script to generate an error and stop.
June 11th, 2023, 08:48 AM
Quebec Canada
Market Wizard
Experience: Intermediate
Platform: NinjaTrader
Broker: AMP/CQG
Trading: ES, NQ, YM
Frequency: Daily
Duration: Minutes
Posts: 4,530 since Oct 2009
Thanks Given: 4,183
Thanks Received: 6,030
trendisyourfriend
I tried to run your script to download 2 days and for 3 instruments. It just processes 1 instrument, the 1st in the list and for 1 day. After that, i see no activity going on and if i try to bring another window in front, the script brings the historical data window in front but still nothing happens. I need to close the historicacl data window to force the script to generate an error and stop.
I found the problem thid morning with fresh eyes.
I needed to update this line:
June 12th, 2023, 05:15 PM
London UK
Posts: 18 since Jul 2022
Thanks Given: 3
Thanks Received: 16
V1.2 Market Replay Download for Multi-Instrument and Multi-Date
Here is V1.2 of the code. The main changes in this version are:
Resizes the Historical Data window to a predefined size during the script execution so that fields are in known positions during execution. Reverts back to original size after script execution.
XTools variable added so that script can handle x-axis variation of the Tools menu position in the Control Center window between NinjaTrader 8.0.28.0 and NinjaTrader 8.1.1.1. For NinjaTrader 8.0.28.0 change the script as followsXTools := 300
Adds an option to see a progress window with status bar whilst the download is happening. This is just a visual and has no bearing on the script itself. To turn it offShowStatusWindow := false
User Parameters
The most likely parameters that a user may need to modify are the following:
/* Comma separated instrument list to download. Make sure you type in the correct name without any extraneous spaces or characters. */
InstrumentList := "MNQ 09-23,MES 09-23"
/* Starting date to process in YYYYMMDD format */
StartDate := 20230605
/* Number of days to download */
NumberofDaysToDownload := 2
/* Skip Days */
SkipSaturday := true
SkipSunday := false
/* Download progress status window toggle */
ShowProgressWindow := true
/* Number of millseconds to wait between keystroke/mouse actions on windows */
SleepBetweenActions := 400
Usage
If you need to abort the script then close the Historical Data window. Do NOT bring any other window into active focus whilst it is running as the script might accidentally send mouse clicks / keystrokes into the wrong window.
Code
/*
Written by Trader AP
Use at your own risk
V1.0 - 10 June 2023 - Original Version
V1.1 - 10 June 2023 - Amended to resize Historical Window to specific size/position in order to
mouseclick and detect download button in the right position
V1.2 - 12 June 2023 - Added a Status Window to see progress of script. Tested on NT 8.0.28.0 64-bit which requires slightly different parameters for XTools = 300
*/
#SingleInstance Force
/* Comma separated instrument list to download. Make sure you type in the correct name without any extraneous spaces or characters. */
InstrumentList := "MNQ 09-23,MES 09-23"
/* Starting date to process in YYYYMMDD format */
StartDate := 20230605
/* Number of days to download */
NumberofDaysToDownload := 2
/* Skip Days */
SkipSaturday := true
SkipSunday := false
/* Download progress status window toggle */
ShowProgressWindow := true
/* Number of millseconds to wait between keystroke/mouse actions on windows */
SleepBetweenActions := 400
/* Today's date in YYYYMMDD format */
TodaysDate := A_YYYY A_MM A_DD
/* Window Title Names */
HistDataWindow := "Historical Data"
DownloadWindow := "Download Progress"
/* Size of Download progress window */
DownloadWindowSize := "W400 H30 cgreen vMyProgress"
/* The following are window x & y positions needed for mouse clicks and keystrokes */
/* Use C:\Program Files\AutoHotkey\WindowSpy.ahk (AutoHotkey Window Spy) */
/* to identify these positions if script does not work */
/* Position of Tools menu on Control Center window */
/* Change XTools to 300 for Ninja Trader 8.0.28.0 */
XTools := 250
YTools := 10
/* Position of rotating triangle for Get Market Replay data in Historical Data window */
XRotatingTriangle := 35
YRotatingTriangle := 630
/* Position of Instrument field in Historical Data window */
XInstrument := 30
YInstrument := 625
/* Position of download button in Historical Data window */
XDownloadButton := 645
YDownloadButton := 610
/* Resize Historical Data window to the following whilst processing mouse clicks and getting button status */
XFixedSizeHDWindow := 1
YFixedSizeHDWindow := 1
WFixedSizeHDWindow := 750
HFixedSizeHDWindow := 650
/* Function for formatted debug & status bar messages */
MyDebug(MessagePrefix, Message, ShowMessageBox := false, ShowStatusOnBar := false)
{
if (ShowProgressWindow && ShowStatusOnBar && WinExist(DownloadWindow)) {
MyProgressStatusBar.SetText(FormatTime(A_Now, "ShortDate") " " A_Hour ":" A_Min ":" A_Sec " " Format("{1:-12}", MessagePrefix ": ") Message)
}
OutputDebug FormatTime(A_Now, "ShortDate") " " A_Hour ":" A_Min ":" A_Sec " " Format("{1:-12}", MessagePrefix ": ") Message "`n"
if ShowMessageBox {
MsgBox(Message, MessagePrefix, MessagePrefix == "Error" ? "Icon!" : "Iconi")
}
}
/* A few defensive checks on user parameters */
if (StrLen(InstrumentList) = 0) {
MyDebug("Error", "Script InstrumentList is blank", true)
return
}
if (StrLen(StartDate) != 8) {
MyDebug("Error", "Script StartDate is not in the right format", true)
return
}
if (DateDiff(TodaysDate, StartDate, "days") < 0) {
MyDebug("Error", "Script StartDate " FormatTime(StartDate, "ShortDate") " is greater than today's date", true)
return
}
/* Change number of download days to not exceed today's system date */
NumberofDaysToDownload := Min(NumberofDaysToDownload, DateDiff(TodaysDate, StartDate, "days"))
/* Calculate the number of items to download */
TotalDownloadItems := 0
Loop Parse, InstrumentList, "," {
TotalDownloadItems += 1
}
TotalDownloadItems := TotalDownloadItems * NumberofDaysToDownload
/* Start the mouse and keystroke emulation */
MyDebug("Message", "Starting Historical Market Replay Data Download for " NumberofDaysToDownload " day" (NumberofDaysToDownload == 1 ? "" : "s"), false)
MyDebug("Message", "Total Number of Downloads " TotalDownloadItems)
if (WinExist(HistDataWindow)) {
MyDebug("Message", "Closing existing open " HistDataWindow " window", false, false)
WinClose(HistDataWindow)
Sleep SleepBetweenActions
}
if (WinExist("Control Center")) {
MyDebug("Message", "Found Control Center window", false, false)
WinActivate
Sleep SleepBetweenActions / 2
/* Click Tools menu item */
MouseClick("Left", XTools, YTools)
Sleep SleepBetweenActions
/* Select Historical Data menu item */
SendInput "{Down}{Down}{Down}{Down}{Down}{Enter}"
if (WinWait(HistDataWindow, , 5)) {
MyDebug("Message", "Opened " HistDataWindow " window", false, false)
WinActivate
/* Get current Historical Data window size and position */
WinGetPos(&XCurrentHDWindow, &YCurrentHDWindow, &WCurrentHDWindow, &HCurrentHDWindow, HistDataWindow)
/* Resize Historical Data window to fixed values to ensure correct mouse click positions */
WinMove(XFixedSizeHDWindow, YFixedSizeHDWindow, WFixedSizeHDWindow, HFixedSizeHDWindow, HistDataWindow)
/* Expand the rotating triangle for Get Market Replay data */
MouseClick("Left", XRotatingTriangle, YRotatingTriangle)
Sleep SleepBetweenActions
/* Create a progress window with status bar */
if (ShowProgressWindow) {
MyGui := Gui(, "Download Progress")
MyProgress := MyGui.Add("Progress", DownloadWindowSize)
MyProgressStatusBar := MyGui.Add("StatusBar", , "")
MyGui.Show
}
/* Loop through instruments */
Loop Parse, InstrumentList, "," {
Instrument := A_LoopField ; Process each instrument in list
ProcessDate := StartDate ; Start date to be processed for each instrument
LoopCnt := NumberofDaysToDownload ; Number of days to download for each instrument
/* Loop through download dates for each instrument */
While (LoopCnt > 0) {
; Skip weekend days based on user configuration
if ((SkipSaturday and !StrCompare(FormatTime(ProcessDate, "WDAY"), "7")) or (SkipSunday and !StrCompare(FormatTime(ProcessDate, "WDAY"), "1"))) {
MyDebug("Skipping", Instrument " for date " FormatTime(ProcessDate, "ShortDate") " as it is a weekend skip date", false, true)
ProcessDate := DateAdd(ProcessDate, 1, "Days")
if (ShowProgressWindow) {
MyProgress.Value += 100 / TotalDownloadItems
}
continue
}
if (WinExist(HistDataWindow)) {
WinActivate
MyDebug("Processing", Instrument " for date " FormatTime(ProcessDate, "ShortDate"), false, true)
/* Select Instrument Field */
MouseClick("Left", XInstrument, YInstrument)
/* Clear Instrument and Date fields and then fill them in */
SendInput "^a{Del}" Instrument "{Tab}^a{Del}" FormatTime(ProcessDate, "ShortDate")
/* Get colour of a download button pixel before presssing enter as this pixel color will be checked to see if download has finished */
BeforeColor := PixelGetColor(XDownloadButton, YDownloadButton)
SendInput "{Tab}{Enter}"
Sleep SleepBetweenActions * 6
if (WinExist("Error")) {
WinActivate
SendInput "{Enter}"
MyDebug("Error", Instrument " for date " FormatTime(ProcessDate, "ShortDate") " NinjaTrader responded with an Error window", false, true)
Sleep SleepBetweenActions
}
else {
loop {
Sleep SleepBetweenActions * 10
if WinExist(HistDataWindow)
WinActivate(HistDataWindow)
else {
MyDebug("Error", "Exiting script as either Historical Data window closed", true, true)
/* Close download progress window */
if (ShowProgressWindow && WinExist(DownloadWindow)) {
MyGui.Destroy
}
return
}
} Until (!StrCompare(BeforeColor, PixelGetColor(645, 625)))
}
ProcessDate := DateAdd(ProcessDate, 1, "Days")
if (ShowProgressWindow) {
MyProgress.Value += 100 / TotalDownloadItems
}
LoopCnt -= 1
}
else {
MyDebug("Message", "Closing " HistDataWindow " window", false)
}
} ; Loop Instruments
} ; Loop InstrumentList
/* Close download progress window */
if (ShowProgressWindow && WinExist(DownloadWindow)) {
MyGui.Destroy
}
if (WinExist(HistDataWindow)) {
/* Revert to original Historical Window size and position */
WinMove(XCurrentHDWindow, YCurrentHDWindow, WCurrentHDWindow, HCurrentHDWindow, HistDataWindow)
MyDebug("Message", "Closing " HistDataWindow " window", false, false)
WinClose(HistDataWindow)
}
}
else {
MyDebug("Error", "Could not find " HistDataWindow " window", true, false)
return
}
}
else {
MyDebug("Error", "Could not find Control Center window", true, false)
return
}
MyDebug("Complete", "Script Historical Market Replay Data Download Finished", true, false)
return
Last Updated on June 18, 2023