Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

[Release] Historical data download helper

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    [Release] Historical data download helper

    Hi everyone. I know this is my first post on the forum but I am making this post to help everyone, else with a problem that I had which was limiting my use of NinjaTrader.
    I was not able to find this online for free, so I want to share this simple script which I created and I hope you guys are welcoming of that because as far as I know, we are limited to downloading 1 day at a time. I seen there were solutions available online for a fee unfortunately I do not have the funds and I'm sure there are others like myself who would appreciate this.
    I present you all with this simple autohotkey script which you can build and compile yourself.
    What this does is automate the process of entering all the dates so you don't have to manually click for every day. This is essentially useful if you plan on trying to download over a year worth of data, and are limited to manually downloading every day.
    How it works is press F10 to get the location and color for the download button
    Press F11 to get the location to click to enter text
    Press F12 to activate which Checks for the color for the download box at the location to click the download button, in order to see if its possible to continue
    Then the text is automatically entered for you in descending dates based on the start day you provided.
    Further instructions can be found in the comments. Thank you all for reading and I hope you enjoy this release I hope I can at least help one person. Thank you all again, and good luck traders.
    Code:
     
    #Persistent
    #SingleInstance
    ;//Welcome. Thank you for using my script brought to you by Elijahxtm
    ;//Instructions here
    ;//Press F10 while hovering over download to get mouse location and color
    ;//Press F11 while hovering over text input box to get mouse location to enter text
    ;//Before use change x,y,z for current day and month and optionally the sleep ammount and number of days.
    ;//Press F12 to start the script
    ;//===================================================================================================
    
    MsgBox, "Press F10 while hovering over the download button. Press F11 to set Again. Press F11 to set text location, F12 to start. ;//Get first input for download button
    ;//Calulate x y z enter current date
    x = 11 ;//Current Month ------------Change this
    y = 21 ;//Current Day  -------------Change this START DATE
    z = 2019 ;//Set year   -------------Change This
    numDays = 365 ;//Number of days to download 
    intSleep = 500 ;//Set sleep ammount in between requests
    
    ;//Get download button position and color
    F10::
    {
    MouseGetPos, MouseX, MouseY
    PixelGetColor, color, %MouseX%,%MouseY%
    dlCoordX = %MouseX% ;//Save these for later
    dlCoordY = %MouseY%
    dlColor = %color%
    
    ;;;;;;MsgBox, %dlCoordX%,+ " "+ %dlCoordY% + " " + %dlColor% ;Optional msgbox
    return
    }
    
    ;//Get text box position to click
    F11::
    MouseGetPos, MouseX, MouseY
    inpCoordX = %MouseX%
    inpCoordY = %MouseY%
    ;;;;;;;;;MsgBox, %inpCoordX%,+ " " + %inpCoordY% ;Optional msgbox
    return
    
    Esc::
    ExitApp
    Exit
    return
    
    ;//Start script
    F12::
    ;//loop
    i = 0
    while (i<numDays) {
        i++  
        y -= 1
    if (y == 0) {
            y = 30
            x -= 1
            if (x == 0) {
                x = 12 ;//Error handling for if month is invalid
            }
        }
    ;//Press enter to clear error messages
    Send, {Enter 2}
    
    ;//Check for download button color at F10 location
    PixelGetColor,Px,Py,%dlCoordX%,%dlCoordY%,%dlCoordX%+2,%dlCoordY%+2,dlColor,5,fast
    if (ErrorLevel = 0) {
    MouseMove,%inpCoordX%,%inpCoordY%, 2
    Click,%inpCoordX%,%inpCoordY% ;//Click
    
    //Mandatory sleep before deleting text
    Sleep,1000 
    
    ;//backspace
    Send, {Backspace 10}
    Sleep, 500
    
    ;//Type date
    Send, %x%
    Sleep,200
    Send, %y%
    Sleep,200
    Send, %z%
    }
    ;//Check for download button color at F10 location
    PixelGetColor,Px,Py,%dlCoordX%,%dlCoordY%,%dlCoordX%+2,%dlCoordY%+2,dlColor,5,fast
    if (ErrorLevel = 0) {
    ;//Click download
        MouseMove, %dlCoordX%,%dlCoordY%,2
        Click, %dlCoordX%,%dlCoordY%
        Click, %dlCoordX%,%dlCoordY%
    } 
    ;//Sleep inbetween
    Sleep, %intSleep%
    }

Latest Posts

Collapse

Topics Statistics Last Post
Started by bortz, 11-06-2023, 08:04 AM
47 responses
1,604 views
0 likes
Last Post aligator  
Started by jaybedreamin, Today, 05:56 PM
0 responses
8 views
0 likes
Last Post jaybedreamin  
Started by DJ888, 04-16-2024, 06:09 PM
6 responses
18 views
0 likes
Last Post DJ888
by DJ888
 
Started by Jon17, Today, 04:33 PM
0 responses
4 views
0 likes
Last Post Jon17
by Jon17
 
Started by Javierw.ok, Today, 04:12 PM
0 responses
13 views
0 likes
Last Post Javierw.ok  
Working...
X