NexusFi: Find Your Edge


Home Menu

 





AutoHotkey Scripts


Discussion in NinjaTrader

Updated
      Top Posters
    1. looks_one monpere with 23 posts (98 thanks)
    2. looks_two traderap101 with 13 posts (12 thanks)
    3. looks_3 trendisyourfriend with 12 posts (0 thanks)
    4. looks_4 perryg with 6 posts (2 thanks)
      Best Posters
    1. looks_one monpere with 4.3 thanks per post
    2. looks_two traderap101 with 0.9 thanks per post
    3. looks_3 SilverFut with 0.7 thanks per post
    4. looks_4 perryg with 0.3 thanks per post
    1. trending_up 35,904 views
    2. thumb_up 115 thanks given
    3. group 35 followers
    1. forum 64 posts
    2. attach_file 10 attachments




 
Search this Thread

AutoHotkey Scripts

  #41 (permalink)
loopit
Singapore
 
Posts: 1 since Oct 2016
Thanks Given: 2
Thanks Received: 1

I upgraded the Autohotkey to work with NinjaTrader 8. Basically it just uses Ctrl-TAB to reset the tab fields, tabs into the number and increments.

It only works from 10-31, as I didn't code in padding zeros. And I hard-coded the 2016 year.

Modified from Peresai's script

 
Code

WinWait, Historical Data, 
IfWinNotActive, Historical Data, , WinActivate, Historical Data, 
WinWaitActive, Historical Data,
;
;  Setup Initial State, -- Edit as appropriate before running.
;
StartDate = 12 ; This is the 1st date to process. (YYYYMMDD format )
LoopCnt = 10		; times to loop (number of days from 1st day to download)
EndDate = %StartDate%
;EndDate += %LoopCnt%, days	; This is the last date to process
DownLoadTime = 220		; Seconds to wait before next step  ( Minimun 10 )
Instrument = "CL 11-16"		; Instrument to download '1st letter only down arrow {Down} for next

;				; {Down n} for n down arrows.
ProcessDate = %StartDate%	; Set Currently Processing Date
Loops = %LoopCnt%
;
outputdebug, "Start [": %StartDate% ":" %EndDate% ":" %ProcessDate% : %Loops% "]"  ; outputs to DebugView
;
;  Start the sequence
;
StartSeq:
;
WinActivate, Historical Data,
;

; Reset tab location
Send, {LCtrl down}{Tab}{LCtrl up}{LCtrl down}{Tab}{LCtrl up}


; Get to the Date Field (assuming Download was last selected)  
  Send, {Tab}{Tab}{Tab}{Tab}{Tab}

; clear the date
  Send, {Right}{Right}{Right}{Right}{Right}{Right}{Right}{Right}
  Send, {Backspace}{Backspace}{Backspace}{Backspace}{Backspace}{Backspace}{Backspace}

; Add new date and year
  send, %ProcessDate%2016{TAB}{Enter}

outputdebug, "Sent [": %TimeString% ":" %ProcessDate% "]"
;
;  Twin Powers Activate
;
; Sleep, 2000                     ; 2 seconds to see the data request box
; send, {Enter}          
         ; pushes the Enter button
; Sleep, 5000                     ; 5 second delay
; send, {Enter}                   ; clears the "No data available" box if present
;
;   Update Current Date
;
; ProcessDate += 1, days
ProcessDate += 1
ToolTip %ProcessDate%
;
;   Wait for download to occur	
;
   x := DownLoadTime * 1000
   sleep, %x%
;  sleep, 500
;

;   next itteration
;
outputdebug, "Compare [": %ProcessDate% ":" %EndDate% : %Loops% "]"
Loops -= 1
 if ( Loops > 0 ) { 
outputdebug, "Loop again"
	goto StartSeq
	}
;
;   Thats all she wrote.
;
outputdebug, "All Done [": %TimeString% ":" %ProcessDate% ":" %EndDate% ":" %Loops% "]"   ; outputs to DebugView

 exit

Reply With Quote
Thanked by:

Can you help answer these questions
from other members on NexusFi?
MC PL editor upgrade
MultiCharts
Better Renko Gaps
The Elite Circle
ZombieSqueeze
Platforms and Indicators
Exit Strategy
NinjaTrader
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Diary of a simple price action trader
26 thanks
Just another trading journal: PA, Wyckoff & Trends
24 thanks
Tao te Trade: way of the WLD
22 thanks
My NQ Trading Journal
16 thanks
HumbleTraders next chapter
9 thanks
  #42 (permalink)
 SilverFut 
Brisbane + Queensland/Australia
 
Experience: Beginner
Platform: NinjaTrader, Sierra Chart
Broker: CQG, IQFeed
Trading: S&P Emini Futures
Posts: 54 since Mar 2015
Thanks Given: 38
Thanks Received: 89

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

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.


 
Code
; --------- 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 https://www.keyboardtrader.com/customized-trading-keyboard.html. It is a access-IS 15 x 8 base. See layout picture




This can be used to setup any programmable keyboard. Modify to suit your needs and number of platforms.




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
Click image for larger version

Name:	Trading Keyboard Hotkeys.PNG
Views:	222
Size:	34.9 KB
ID:	218652  
Attached Files
Elite Membership required to download: MACRO_KEYS_FOR_EACH_PLATFORM_v3.XLS
Elite Membership required to download: Hotkeys_3_Platforms_A.txt
Reply With Quote
Thanked by:
  #43 (permalink)
 markbb10 
Treasure Coast, Florida
 
Experience: Advanced
Platform: Ninja 8
Trading: Futures
Posts: 135 since Aug 2012
Thanks Given: 57
Thanks Received: 50


Has anyone done any recent work with autohotkey to place orders via chart clicks or to manipulate stops/targets during a trade?

Thanks,
Mark

Reply With Quote
  #44 (permalink)
traderap101
London UK
 
Posts: 18 since Jul 2022
Thanks Given: 3
Thanks Received: 16

NinjaTrader 8 Multi Instrument and Multi Date Range Historical Market Replay Data Download Automation


Functionality
Script automates the download of Historical Market Replay data for multiple instruments and download dates by simulating mouse clicks and keystrokes on NinjaTrader GUI.

This is my first AutoHotkey script so may need changes after user testing and feedback !

Installation & Usage
Install AutoHotkey V2 -
https://www.autohotkey.com/
https://www.autohotkey.com/download/ahk-v2.exe
Save this code with a .ahk extension into a Windows folder

There are 5 parameters in the script to check/modify -
  1. InstrumentList - Comma separated list of instruments. This example code show MNQ and MES
  2. StartDate - Starting date for download. Check with your broker/market data provider documentation as to how much historical market replay data they provide. e.g. Rithmic only seems to have 90 days of Market Replay Data
  3. NumberofDaysToDownload - Can be set to whatever valid number of days you want
  4. SkipSaturday - Should be set to false for Equities and Futures
  5. SkipSunday - Should be set to false for Equities. Can be set to true for Futures which start trading on Sunday

Start NinjaTrader 8 and make sure the Control Center window is Active

Double click the script to start the mouse and keyboard stroke emulation. Windows will know the association between a .ahk file extension and will invoke the AutoHotkey interpreter automatically. There is no need to run AutoHotkey from Windows Menu separately.

Whilst the script is running DO NOT use any other window as it could send the emulation to the wrong active window. There is some defensive code where the script tries to make the NT8 Historical Data window the active window before sending any mouse or keystrokes but the code might not cover all scenarios.

If you need to abort the download then close the Historical Data window and the script will detect that the window is not present and exit.

When using for the first time, just try for 1 or 2 instruments, a valid start date and number of days to download set to 1. This will make sure your installation is working before using the multi instrument and multi day download parameters.

If you have a slow PC then SleepBetweenActions may need to be increased from 400ms to a higher value.

Testing
Tested only on NinjaTrader 8.1.1.1, Windows 11, AutoHotkey v2

Tested only for Futures.

If you are a developer and have Visual Studio Code installed then get the extensions AutoHotkey v2 Language Support by thqby and vscode-autohotkey-debug by zero-plusplus to see the scripts debug messages as it processes.

Warning
Do not have other windows open apart from NinjaTrader 8 open to avoid possible issues with the script sending mouse and keystrokes to 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

*/

#SingleInstance Force

/* Comma separated instrument list to download.  Make sure you type in the correct name without any extraneous spaces or characters. */
InstrumentList := "MNQ 06-23,MES 06-23"

/* Starting date to process in YYYYMMDD format */
StartDate := 20230605

/* Number of days to download */
NumberofDaysToDownload := 2

/* Skip Days */
SkipSaturday := true
SkipSunday := false

/* Script Static Variables */
TodaysDate := A_YYYY A_MM A_DD
SleepBetweenActions := 400                  ; Number of millseconds to wait between keystroke/mouse actions on windows
HistoricalData := "Historical Data"

/* Window Co-ordinates for arious windows. */
/* Use C:\Program Files\AutoHotkey\WindowSpy.ahk (AutoHotkey Window Spy) */
/* to identify these positions if script does not work */

/* 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

/* Historical Data window resize whilst processing mouse clicks and getting button status */
XFixedSizeHDWindow := 1
YFixedSizeHDWindow := 1
WFixedSizeHDWindow := 750
HFixedSizeHDWindow := 650

/* Function for a formatted debug message */
MyDebug(MessagePrefix, Message, ShowMessageBox := false)
{
    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"))

/* Start the mouse and keystroke emulation */
MyDebug("Message", "Starting Historical Market Replay Data Download for " NumberofDaysToDownload " day" (NumberofDaysToDownload == 1 ? "" : "s"), false)

if (WinExist(HistoricalData)) {
    MyDebug("Message", "Closing existing open " HistoricalData " window", false)
    WinClose(HistoricalData)
    Sleep SleepBetweenActions
}

if (WinExist("Control Center")) {
    MyDebug("Message", "Found Control Center window", 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(HistoricalData, , 5)) {
        MyDebug("Message", "Opened " HistoricalData " window", false)
        WinActivate

        /* Get current Historical Data window size and position */
        WinGetPos(&XCurrentHDWindow, &YCurrentHDWindow, &WCurrentHDWindow, &HCurrentHDWindow, HistoricalData)

        /* Resize Historical Data window to fixed values to ensure correct mouse click positions */
        WinMove(XFixedSizeHDWindow, YFixedSizeHDWindow, WFixedSizeHDWindow, HFixedSizeHDWindow, HistoricalData)

        /* Expand the rotating triangle for Get Market Replay data */
        MouseClick("Left", XRotatingTriangle, YRotatingTriangle)
        Sleep SleepBetweenActions

        /* 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 */
            Loop (LoopCnt) {

                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", false)
                        ProcessDate := DateAdd(ProcessDate, 1, "Days")
                        continue
                    }

                    MyDebug("Processing", Instrument " for date " FormatTime(ProcessDate, "ShortDate") "", false)

                    /* 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)

                        Sleep SleepBetweenActions

                        if (WinExist(HistoricalData)) {
                            WinActivate
                            Sleep SleepBetweenActions
                        }
                        else {
                            MyDebug("Error", "Could not find " HistoricalData " after acknowledging Error window pop-up", false)
                            break
                        }
                    }
                    else {
                        loop {
                            Sleep SleepBetweenActions * 10
                            if WinExist(HistoricalData)
                                WinActivate
                            else {
                                MyDebug("Error", "Exiting script as Historical Data window not found", true)
                                return
                            }
                        } Until (!StrCompare(BeforeColor, PixelGetColor(645, 625)))
                    }

                    ProcessDate := DateAdd(ProcessDate, 1, "Days")

                    LoopCnt -= 1
                }
                else {
                    MyDebug("Message", "Closing " HistoricalData " window", false)
                }
            }
        }

        if (WinExist(HistoricalData)) {
            /* Revert to original Historical Window size and position */
            WinMove(XCurrentHDWindow, YCurrentHDWindow, WCurrentHDWindow, HCurrentHDWindow, HistoricalData)

            MyDebug("Message", "Closing " HistoricalData " window", false)
            WinClose(HistoricalData)
        }
    }
    else {
        MyDebug("Error", "Could not find " HistoricalData " window", true)
        return
    }
}
else {
    MyDebug("Error", "Could not find Control Center window", true)
    return
}

MyDebug("Complete", "Script Historical Market Replay Data Download Finished", true)

return

Leave me feedback or suggestions if you do use this script including a successful or unsuccessful installation!

Reply With Quote
Thanked by:
  #45 (permalink)
 
trendisyourfriend's Avatar
 trendisyourfriend 
Quebec Canada
Market Wizard
 
Experience: Intermediate
Platform: NinjaTrader
Broker: AMP/CQG
Trading: ES, NQ, YM
Frequency: Daily
Duration: Minutes
Posts: 4,527 since Oct 2009
Thanks Given: 4,174
Thanks Received: 6,019

If i understand correctly, we just need to copy paste the text within the code area and save it under whatever name. Do we need to add a specific extention to the file name ?

Is it normal that the ;InstrumentList starts with a ';' ?

Reply With Quote
  #46 (permalink)
 
trendisyourfriend's Avatar
 trendisyourfriend 
Quebec Canada
Market Wizard
 
Experience: Intermediate
Platform: NinjaTrader
Broker: AMP/CQG
Trading: ES, NQ, YM
Frequency: Daily
Duration: Minutes
Posts: 4,527 since Oct 2009
Thanks Given: 4,174
Thanks Received: 6,019

I have installed the AHK and i see this window when it runs:


I have tried to open your code which is in a notepad format but that does not work.

Is there a way to open a txt file in AHK ? I can't seem to find the menu item for that.

Reply With Quote
  #47 (permalink)
traderap101
London UK
 
Posts: 18 since Jul 2022
Thanks Given: 3
Thanks Received: 16

I have amended the posted code to show an example for downloading data for MNQ and MES. So copy code again into a .ahk file extension rather than .txt.

Then just double click on it. Windows will automatically process this file through the installed AutoHotkey program.

The ; character in the code is used for commenting out a line in AutoHotkey.

Reply With Quote
  #48 (permalink)
 
trendisyourfriend's Avatar
 trendisyourfriend 
Quebec Canada
Market Wizard
 
Experience: Intermediate
Platform: NinjaTrader
Broker: AMP/CQG
Trading: ES, NQ, YM
Frequency: Daily
Duration: Minutes
Posts: 4,527 since Oct 2009
Thanks Given: 4,174
Thanks Received: 6,019

I have installed an editor and i was able to copy/paste the text into the new window in the editor and click the run button.

The script executes but the Dom window opens and it stalls there. I am using NT version 8.0.28.0 64-bit.

I think this command is the problem
/* Click Tools menu item */
MouseClick("Left", 250, 10)

Reply With Quote
  #49 (permalink)
traderap101
London UK
 
Posts: 18 since Jul 2022
Thanks Given: 3
Thanks Received: 16

/* Click Tools menu item */
MouseClick("Left", 250, 10)

This is the position for the Tools menu option on my NT8 V8.1.1.1 and the mouseclick at this position opens up another menu on which the script clicks the Historical Data option

Tools Menu



Post an image of your equivalent screen so that I can see if your layout is different to mine.

Reply With Quote
  #50 (permalink)
 
trendisyourfriend's Avatar
 trendisyourfriend 
Quebec Canada
Market Wizard
 
Experience: Intermediate
Platform: NinjaTrader
Broker: AMP/CQG
Trading: ES, NQ, YM
Frequency: Daily
Duration: Minutes
Posts: 4,527 since Oct 2009
Thanks Given: 4,174
Thanks Received: 6,019


How can i find the exact position of this menu ?

Reply With Quote




Last Updated on June 18, 2023


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
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.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts