You'll love it if you use Ninja

Discussion in 'Trading Software' started by TraderSU, Oct 29, 2009.

  1. This is a very handy AHK (AutoHotKey) script for creating charts. This is better than Window's default "Tile Windows" functionality because it overlaps those charts to make maximum use of screen real-estate. Hope you all like it.

    Just install AHK from http://www.autohotkey.com/ ; and save attachment, rename to .ahk, customize for your need and run it (after establishing the Ninja connection). It assumes that you have a saved template that starts with 'S' for monitoring stocks and other saved template that starts with 'I' for monitoring indexes.

    Enjoy,
    - SU

    Code:
    ; Fix following variables for your screen setup
    CountX := 4
    CountY := 2
    ; Screen used for chart is 1440x900
    ScreenX := 1440
    ScreenY := 900
    ; Show it on primary screen 
    ;OffsetX := 0
    ;OffsetY := 0
    ; Show it on secondary screen 
    ; 	with primary screen 1280x800
    OffsetX := 1280
    OffsetY := 0
    
    ; Open following 8 charts in  given sequence
    
    MyCharts()
    {
    	OpenChart("SP500", "5 Min", "Index")
    	OpenChart("DJIA", "5 Min", "Index")
    	OpenChart("VIX", "5 Min", "Index")
    	OpenChart("GS", "5 Min")
    
    	OpenChart("SSO", "5 Min")
    	OpenChart("SDS", "5 Min")
    	OpenChart("FAZ", "5 Min")
    	OpenChart("SRS", "5 Min")
    }
    
    ; No edit required below this line
    
    ; Calculate dimentions
    WidthX := ScreenX / CountX
    HeightY := ScreenY / CountY
    
    WinWait, Control Center
    WinActivate, Control Center
    
    WinGetPos,,, Width, Height, Control Center
    WinMove, Control Center,, (A_ScreenWidth/2)-(Width/2), (A_ScreenHeight/2)-(Height/2)
    
    MyCharts()
    
    WinMinimize, Control Center
    
    OpenChart(Symb, Period = "5 Min", SType = "Stock") 
    {
    	; Define globals
    	global CountX, CountY, OffsetX, OffsetY, WidthX, HeightY
    
    	static ChartCount = 0 
    	
    	WinActivate, Control Center
    
    	MouseClick, left, 25, 40
    	MouseClick, left, 190, 64
    	MouseClick, left, 220, 110
    
    	WinWait, Format Data Series
    	WinActivate, Format Data Series
    
    	if (SType = "Stock") 
    	{
    		MouseClick, left, 215, 80
    		MouseClick, left, 105, 188
    		MouseClick, left, 40, 236
    		Send S
    		MouseClick, left, 40, 236
    	}
    	
    	if (SType = "Index") 
    	{
    		MouseClick, left, 215, 80
    		MouseClick, left, 105, 175
    		MouseClick, left, 40, 236
    		Send I
    		MouseClick, left, 40, 236
    	}
    
    	MouseClick, left, 105, 100, 2
    	Send %Symb%
    	Sleep 20
    	
    	StringSplit, PeriodArray, Period, " "
    	PeriodNumber = %PeriodArray1%
    	PeriodTimeframe = %PeriodArray2%
    	
    	MouseClick, left, 75, 180, 2
    	Send %PeriodNumber%
    	Sleep 20
    
    	MouseClick, left, 160, 310
    	
    	SetTitleMatchMode RegEx
    	WinWait %Symb%.*\(%Period%\)
    	Sleep 200
    	
    	ChartX := Mod(ChartCount, CountX) * WidthX
    	ChartY := (ChartCount // CountX) * HeightY - 25
    	WinMove, %Symb%.*\(%Period%\),, OffsetX + ChartX, OffsetY + ChartY, (WidthX + 20), (HeightY + 25)
    		
    	++ChartCount
    	
    	SetTitleMatchMode 1
    	Sleep 20
    
    }
    
     
  2. multicharts?

    ninja?

    which platform?, or are these the command codes to open new chart windows in ninja?

    interesting, please confirm
     
  3. Q: Which platform?

    Ninja, but can be easily ported for any program.

    Q: Are these the command codes to open new chart windows in ninja?

    Exactly! The whole process will be automated (u just watch and script will do the job magically).

    Q: What's wrong with default save workspace and "tile windows"?

    Just try it and see the difference :-D Workspace screws up time to time and that is why I wrote this script.

    In fact, I also have another script optimized for 1920x1080 screen that opens 16 charts in 2 layers. Very handy and I love it... I can happily share it if I see interest in community...

    Cheers,
     
  4. dc101

    dc101

    Thanks for sharing. Could you upload that script as txt? Thanks.
     
  5. Here you go. Just tweak it for your watch-list.

    Make following changes as per your primary monitor width and secondary monitor size. (OffsetX will go zero if your chart target screen is a primary monitor).

    Code:
    WidthX := 1920 / 4
    HeightY := (1080 + 20) / 2
    OffsetX := 1280
    OffsetY := 0
    
    I'll try to package the code in better way and re-post sometime latter.
     
  6. lol. I guess cut and paste isn't taught in school these days.
     
  7. dc101

    dc101

    Ignorance is bliss - you should know that some forum software doesn't properly escape certain characters, not to mention word wrapping that may be significant.
     
  8. very esoteric excuse. It was clear that there were no word wrap issues, all short lines, and as for characters not 'displaying', that is quite rare for a script.
     
  9. demarcog

    demarcog

    Will that utility work for Multicharts?
     
  10. Nah - I'm sure that it won't even work with Ninja 7. The code is pixel level sensitive to the program and screens. But good news is that I'll keep it updated for Ninja (what I use).

    It can be easily ported to any platform if you know (or learn) AHK.

    What is great in Multichart? Ninja charting is working great for me (with IB feed) and it is FREE.
     
    #10     Nov 15, 2009