NinjaTrader Support Forum  
X

Attention!

This website will be down for maintenance from Friday May 24th at 6PM MDT until Sunday May 26th at 12PM MDT. We apologize for the inconvenience. If you need assistance during this time, please email sales@ninjatrader.com


Go Back   NinjaTrader Support Forum > Application Technical Support > Automated Trading

Automated Trading Support for automated trading systems using NinjaScript. Support for our ATI (Automated Trading Interface) used to link an external application such as TradeStation and eSignal to NinjaTrader.

Reply
 
Thread Tools Display Modes
Old 02-20-2009, 04:08 PM   #1
r2kTrader
Senior Member
 
Join Date: Sep 2008
Posts: 483
Thanks: 0
Thanked 2 times in 2 posts
Default Reconnect PATS BARCHART Etc.

I recently posted a reply to an irate user who was upset that you couldn't reconnect a broken feed/connection without manually disconnecting and reconnecting. Barchart has this issue, while Zen-Fire does not (Zen-Fire seems to auto reconnect, but Barchart is not as reliable in this regard, nor is PATS). Anyway, just wanted to start a thread about this.

Idea:

Create a small service that could run on XP/Vista that would poll a file that is written to on the local machine or would poll an IMAP account or something of the like. If NT fires an email or writes to a file that a connection is broken, the service could fire up and then run a keyboard macro routine.

If anyone is up for writing the utility, I would beta test.


Thank you,


R2Ktrader
r2kTrader is offline  
Reply With Quote
Old 02-20-2009, 04:12 PM   #2
NinjaTrader_Kyle
NinjaTrader Customer Service
 
NinjaTrader_Kyle's Avatar
 
Join Date: Dec 2008
Location: Denver, CO, USA
Posts: 7,355
Thanks: 146
Thanked 253 times in 249 posts
Default

Hello r2kTrader,

Thank you for your post.

I will forward this on to development for further consideration.
NinjaTrader_Kyle is offline  
Reply With Quote
Old 02-22-2009, 08:02 AM   #3
r2kTrader
Senior Member
 
Join Date: Sep 2008
Posts: 483
Thanks: 0
Thanked 2 times in 2 posts
Default Keyboard Mouse Macro Program - Auto Re-Connect Automatically Reconnect Data Feed

I have not tried this program, but this seems to be something that may be of use for re-connecting broken connections.

http://www.autohotkey.com/docs/Tutorial.htm

NOTE: This program supports loops like checking a file every x number of seconds. This would be ideal because you could have NT write to a local file if connect is lost and then when autohotkey reads the file and finds the appropriate command or whatever, it would take action and do as you commanded it. It could also do things which may be helpful. For example, it could take a screenshot of your account and connection status etc. so you could get VISUAL picture of what is actually going on, and then email it to you periodical as trades fire, etc.

This explains the file read loop feature:
http://www.autohotkey.com/docs/comma...opReadFile.htm

This way you are getting a view from the outside looking in, verses from the inside out. This helps to provide a human perspective of the situation and help to avoid a programmatic mistake as it relates to information being sent from the very program that you are trying to watch.

It can read and write from files, so if a connection breaks and needs to be disconnected/reconnected, you could have this program poll a file and then run a keyboard macro that will reconnect the data feed.

The other reason I like this as opposed to email notification, is because it may be the internet circuit that went down. If this were the case and you needed to be notified, then you could have your computer's modem dial your cellphone relentlessly or something like that. Some of the new modems would allow you to play a recorded message or again, you could just have your modem page your phone and put in a certain number meaning you better call your broker.

I thought this thread would garner more interest due to the importance of this issue. I for one have had issues with PATS and Barchart reconnecting automatically. It seems I was only able to reconnect most of the time by doing so manually. :-(

Looking forward to feedback.


r2kTrader
Last edited by r2kTrader; 02-22-2009 at 08:19 AM.
r2kTrader is offline  
Reply With Quote
Old 02-22-2009, 08:07 AM   #4
r2kTrader
Senior Member
 
Join Date: Sep 2008
Posts: 483
Thanks: 0
Thanked 2 times in 2 posts
Red face NT - We need more hot key support

Dear Support,

[UPDATE]
For those of you who want to use the AutoHotKey dilio, please know that NT does indeed support hot keys. You will only see the hotkey sequences though, if you use your keyboard to navigate. For example, if you click your mouse on the control panel and select file, both Connect and Disconnect do not show the C and D letters with an underline as it detects you are using the mouse. If however, you use Alt+F to drop down the file menu, you will see the Connect and Disconnect do indeed support hot keying. Well done NT. Is there an option to leave hotkey navigation always on? Perhaps that setting / bool should be added.


Until such time as we have a way to programmatically reconnect a broken data feed, we could use some help with hot keys for this work around I am proposing.

As it stands, ( I just checked the menus on Control ) and there is no hot key support for the connection/disconnect menu items, thus I would have to send an arrow key up/down sequence, etc. in order to macro a disconnect/reconnect script.

It might make more sense to just provide a function to disconnect and reconnect in the time it would take to add menu hot keys, but I have no idea which is faster or if this thread is even a good idea.

But as other members have mentioned, I can't have a system auto trading if I can't be assured that the connection is being monitored and managed using all the technology that is available to us in this day and age.

The even bigger concern is the fact that I don't want to stare at my system, as I am trying to set and forget, not set and stare , lol.



Thanks,


r2kTrader
Last edited by r2kTrader; 02-22-2009 at 08:23 AM.
r2kTrader is offline  
Reply With Quote
Old 02-22-2009, 09:45 AM   #5
r2kTrader
Senior Member
 
Join Date: Sep 2008
Posts: 483
Thanks: 0
Thanked 2 times in 2 posts
Default Re-Posted for this Forum - AutoHotKey - Trial Results

I have good news regarding the reconnect issue. I downloaded and played with HotAutoKey. It is amazingly simple.

I just did my first script and saved it to a file. It worked FLAWLESSLY.

This is the code it auto generated for me and it worked straight away even when control was minimized:

IfWinNotActive, Control Center - Default, Limit Price:, WinActivate, Control Center - Default, Limit Price:
WinWaitActive, Control Center - Default, Limit Price:
Send, {ALTDOWN}f{ALTUP}db{ALTDOWN}f{ALTUP}cb


The db is the first letter for Disconnect and b is the first letter for Barcharts (my connection). So I did a disconnect/reconnect. WORKED PERFECT! So now I just need to setup a loop in HotKey to poll a file religiously and then I can streamwrite to that file in the event I want to trigger a reconnect.

One thing I can say right off the bat is this. If you are a serious trader who is using NT with real money, you will probably want a dedicated box running and as such I would recommend renting a windows based server from a hosting provider. You get bullet proof connectivity and all the benefits of a power reliability and backups. You then have your box setup so that NOTHING runs except Ninja and your AutoHotKey program. This way you can be assured less complications when you need your macro to run. You can get a dedicated box as a VPS for like 39.00 per month and that includes huge bandwidth, etc. This also assures you don't have to have that system used for anything other than NT. And finally, you can access your box from anywhere and do so conveniently. I would have it set to close all ports and then use a port-knocking sequence to open the remote port for access (this if you want to know about port knocking, let me know. What it does is close your box to the outside world unless a certain sequence is dialed. I recommend this as I would not leave money hanging by my front window just because the door is locked. Rather I would only let the money hang by the window if I was the only one who could see the window, copy??).


This will be a big help for you. Please join us in the thread and share your scripts.
r2kTrader is offline  
Reply With Quote
Old 02-23-2009, 10:11 AM   #6
michaelangela
Junior Member
 
Join Date: Nov 2008
Posts: 11
Thanks: 0
Thanked 0 times in 0 posts
Default

Quote:
Originally Posted by r2kTrader View Post
For those of you who want to use the AutoHotKey dilio, please know that NT does indeed support hot keys. You will only see the hotkey sequences though, if you use your keyboard to navigate. For example, if you click your mouse on the control panel and select file, both Connect and Disconnect do not show the C and D letters with an underline as it detects you are using the mouse. If however, you use Alt+F to drop down the file menu, you will see the Connect and Disconnect do indeed support hot keying. Well done NT. Is there an option to leave hotkey navigation always on? Perhaps that setting / bool should be added.
I believe this is a Windows thing in general. In XP you can right click on the desktop and go to Properties, then Appearance, then Effects and uncheck "Hide underlined letters for keyboard navigation until I press the Alt key".
michaelangela is offline  
Reply With Quote
Old 02-24-2009, 04:43 AM   #7
r2kTrader
Senior Member
 
Join Date: Sep 2008
Posts: 483
Thanks: 0
Thanked 2 times in 2 posts
Default

You're right! Thank you for clearing that up.

Quote:
Originally Posted by michaelangela View Post
I believe this is a Windows thing in general. In XP you can right click on the desktop and go to Properties, then Appearance, then Effects and uncheck "Hide underlined letters for keyboard navigation until I press the Alt key".
r2kTrader is offline  
Reply With Quote
Old 02-24-2009, 06:15 AM   #8
skynetman
Senior Member
 
Join Date: Mar 2008
Posts: 138
Thanks: 0
Thanked 0 times in 0 posts
Default

What about a script to:
shut down NT, confirmation on NT exit window, check process not in memory, start it up again, connect?
skynetman is offline  
Reply With Quote
Old 02-24-2009, 07:00 AM   #9
r2kTrader
Senior Member
 
Join Date: Sep 2008
Posts: 483
Thanks: 0
Thanked 2 times in 2 posts
Default

Yes, that could be done quite easily.

1. You would need a vbscript to check for running threads and then set it to scrub that thread (look for it by name presumably)

Here is an example as taken from:
http://www.computerperformance.co.uk...ocess_stop.htm


' ProcessKillRemote.vbs
' Sample VBScript to kill a program
' Author Guy Thomas http://computerperformance.co.uk/
' Version 2.9 - December 2005
' ------------------------ -------------------------------'
Option Explicit
Dim objWMIService, objProcess, colProcess
Dim strComputer, strProcessKill, strInput
strProcessKill = "'NinjaTrader.exe'"

' Input Box to get name of machine to run the process
Do
strComputer = (InputBox(" ComputerName to Run Script",_
"Computer Name"))
If strComputer <> "" Then
strInput = True
End if
Loop until strInput = True


Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" _
& strComputer & "\root\cimv2")

Set colProcess = objWMIService.ExecQuery _
("Select * from Win32_Process Where Name = " & strProcessKill )
For Each objProcess in colProcess
objProcess.Terminate()
Next
WSCript.Echo "Just killed process " & strProcessKill _
& " on " & strComputer
WScript.Quit
' End of WMI Example of a Kill Process

2. Then your HotKeyScript would call that script during it's process. Not a big deal. You would probably want your vbs script to write to the file you are polling from your autoKeyScript so it knows when the thread has been terminated. So your script would go into a loop until it confirms the thread NinjaTrader.exe is completely down. I think with about 3 hours of time invested, you could have a fairly tight solution that will bring you a long way closer to your vision, but alas, not perfect. I would include screenshots to be sent to an IMAP or web based account, etc. so you can see what the screen actually looks like if the hotkeyscript is called due to a malfunction of NT or the like. A picture could be worth 1,000.00 in this case ;-0

Ugly? heck yeah. Ridiculous? heck yeah. Better than nothing? absolutely.



Quote:
Originally Posted by skynetman View Post
What about a script to:
shut down NT, confirmation on NT exit window, check process not in memory, start it up again, connect?
Last edited by r2kTrader; 02-24-2009 at 07:11 AM.
r2kTrader is offline  
Reply With Quote
Old 02-24-2009, 07:07 AM   #10
r2kTrader
Senior Member
 
Join Date: Sep 2008
Posts: 483
Thanks: 0
Thanked 2 times in 2 posts
Default

Also, I would recommend doing this all on the machine you intended on using it on. This way screen size, etc. will all be consistent. That may come into play if you have to use mouse moves to make thing happen (like start a strategy.)



Quote:
Originally Posted by skynetman View Post
What about a script to:
shut down NT, confirmation on NT exit window, check process not in memory, start it up again, connect?
r2kTrader is offline  
Reply With Quote
Old 05-15-2009, 02:39 PM   #11
Poze97
Junior Member
 
Join Date: Apr 2009
Posts: 3
Thanks: 0
Thanked 0 times in 0 posts
Default

Thanks for the great work on this. I'm attempting to migrate from Tradestation to Ninjatrader and am looking at using MF Global with Pats. It looks like setting up a nightly job to bounce Ninjatrader will be needed, and reconnecting to Pats looks fairly straightforward using Autohotkey and the great tips provided here. However, I'm unclear if it will be possible to also automate the opening and starting of a strategy (for live trading) using Autohotkey (or any other method) after bouncing Ninjatrader.

Has anyone been able to also automate starting a strategy after bouncing Ninjatrader? In the tradestation world, strategies are saved with charts, and automatically open and start when the process is restarted. I'm new to Ninjatrader, but from what I"ve seen, strategies are not saved with charts, and it doesn't appear possible to automatically have them open when restarting Ninjatrader. Further complicating this is the fact that some strategy input parameters don't appear to be able to be set through Ninjascript - such as Data series type. So there would have to be a way to not only open and start a strategy, but also ensure that strategy input parameters are set correctly.

Any suggestions would be greatly appreciated,
Thanks,
Poze97
Poze97 is offline  
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
NTDirect reconnect? moscu Automated Trading 1 08-12-2008 01:46 PM
Reconnect from TS to NT aslane Automated Trading 2 01-20-2008 09:04 PM
Charts not updating on reconnect pdawg Charting 4 10-21-2007 02:18 AM
Can't reconnect to Patsystem - have working orders on dwight Connecting 5 05-16-2006 03:15 AM
Cannot reconnect to PATS - getting following error steve0617 Connecting 4 04-25-2006 07:13 AM


All times are GMT -6. The time now is 10:06 PM.