NinjaTrader Support Forum  
X

Attention!

This website will be down for maintenance from Friday May 24th at 6PM MDT until Saturday May 25th at 11AM 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 03-24-2005, 05:08 AM   #1
Zardoz
Junior Member
 
Join Date: Mar 2005
Location: , ,
Posts: 20
Thanks: 0
Thanked 0 times in 0 posts
Post imported post

Questions:

To the traders using TradeStation, are you using the "Signal" file to code your buy and sell orders?

I've just started this and the problem I'm having is that when I add the Strategy (which contains the Signal) to the chart, TS marks all the past buy/sell signals on the chart and of course each time issending a file with a OIF orderto Ninja.

I'm I just missingsome code to stop it from looking atpast signals?

Also on the Ninja website it states in "The Basics". "Once NinjaTrader has processed the Passthrough OIF, it will delete the file. You can use this event to determine when it is safe to send the next Passthrough OIF. Has anyone figured out how check for this event?


Any ideas would be much appreciated.
Any simple examples that someone might have wouldbe also good.

Thanks, Happy Easter


Zardoz
Zardoz is offline  
Reply With Quote
Old 03-27-2005, 06:00 AM   #2
scjohn
Senior Member
 
Join Date: Dec 2004
Location: , ,
Posts: 224
Thanks: 0
Thanked 11 times in 8 posts
Post imported post

I do not use TS but your problems occur in all software.

For your problem of sending orders on historical data, you will need to add some code that tells you if you are, now running in real-time. In other words, you are finished with the historical data.

As to whether or not the OIF file has been deleted, hopefully there is FileExists() command in TS.

You may want to look atthe TS example on the main web site. http://www.ninjatrader.com/doc_autom...adestation.htm
scjohn is offline  
Reply With Quote
Old 03-27-2005, 01:35 PM   #3
aspTrader
 
Join Date: Mar 2005
Location: Walnut Creek, California, USA
Posts: 74
Thanks: 0
Thanked 0 times in 0 posts
Post imported post

Regarding whether a bar is an historical bar or a realtime bar, use the TS boolean condition "LastBarOnChart" as in:

Code:
IF LastBarOnChart

THEN BEGIN

 // some code statement

 // OIF file output statement

END;
scjohn wrote:
Quote:
As to whether or not the OIF file has been deleted, hopefully there is FileExists() command in TS.
The best statement to use for file manipulation procedures including FileExists() in TS can be found in the EL Collections DLL package provided by the user named "Bamboo". I would also look for Bamboo's code contribution in the thread called "FastFileAppend".
aspTrader is offline  
Reply With Quote
Old 03-28-2005, 08:22 AM   #4
Zardoz
Junior Member
 
Join Date: Mar 2005
Location: , ,
Posts: 20
Thanks: 0
Thanked 0 times in 0 posts
Post imported post

Thanks a lot guys,

aspTrader

I had got a workaround but the "if lastBarOnChart" is better. My workaround was just to bring up NinjaTrader after I activated my Strategy and delete the file manually.

As for the "FileExist", I'm not sure. Bamboo seems to have a different TradeStation then myself, probably the new edition. His EL Collections isan ELD file. TS 2000i supports ELA and ELS files.There is no FileExists command with TradeStation 2000i

scjohn

The example on the main website is more confusing than anything, but then I'm just a rookie at this. He uses a lot of fileappend commands when I thought one had to create a new file for each command to be sent to Ninja. I don't think there was one file create or PrintFile command in the whole thing.

Anyway I got the basic Strategy working minus a few extras that I had to take out.

Thanks again for you help!!!

Zardoz







Zardoz is offline  
Reply With Quote
Old 03-29-2005, 02:17 AM   #5
aspTrader
 
Join Date: Mar 2005
Location: Walnut Creek, California, USA
Posts: 74
Thanks: 0
Thanked 0 times in 0 posts
Post imported post

Zardoz wrote:
Quote:
I had got a workaround but the "if lastBarOnChart" is better. My workaround was just to bring up NinjaTrader after I activated my Strategy and delete the file manually.

As for the "FileExist", I'm not sure. Bamboo seems to have a different TradeStation then myself, probably the new edition. His EL Collections isan ELD file. TS 2000i supports ELA and ELS files.There is no FileExists command with TradeStation 2000i
Hi,

The LastBarOnChart is the standard way in TS to only activate an order in realtime. If your NT strategy related code is in a TS indicator AND you have "Update Every Tick" turned on then you'll need to do something in addition to that.

Bamboo's code contributions run with the new Tradestation. I'm not sure of their status vis-a-vis TS 2000i.
aspTrader is offline  
Reply With Quote
Old 03-29-2005, 04:48 AM   #6
Zardoz
Junior Member
 
Join Date: Mar 2005
Location: , ,
Posts: 20
Thanks: 0
Thanked 0 times in 0 posts
Post imported post

asp Trader, Hi

I do use update-every-tick and I am using a signal off a 52 tick bar chart. As far as I can tell this has not been a problem so far. Maybe because I don't get multiple signals within one bar.

The problem I'm having now it that every now and then I'm getting a "runtime Error" on my signal with the message "Error opening file". Iassume that is the order.txt filethat I'mcreating to send the command to Ninja. Was wondering if I'm getting this message because I'm trying to create the file the same time Ninja is polling for it?

Has anyone else had this problem?

This is frustrating.



Zardoz







Zardoz is offline  
Reply With Quote
Old 03-31-2005, 02:11 AM   #7
Zardoz
Junior Member
 
Join Date: Mar 2005
Location: , ,
Posts: 20
Thanks: 0
Thanked 0 times in 0 posts
Post imported post

Vincent help me please.

This is crazy. I took out basically all my code and only left one file create statement and I'm still getting the error. Here is the code. Still getting "Error opening file"most of the time the singal is activated. Someone must have also had this problem?

Thought that maybe Ninja was trying to create a file in the same directory at the same time like the updateor position.txt file that Ninja creates. Or maybe the polling is the problem.


If KBLshortterm < OverSold
then TabLong = 1
else TabLong = 0;


If TabLong = 1 Then Begin

If Price > High of 1 bar ago and KBLMedterm > KBLMedterm of 1 bar ago
Then Begin

Print(File("c:\program files\ninjatrader 4\AT\order.txt"),"YM 06-05,,DAY,BUY,MKT,,,,,,,YM One,SIM-101,");

End;


End;


Zardoz is offline  
Reply With Quote
Old 03-31-2005, 02:41 AM   #8
Merv
 
Join Date: Nov 2004
Location: Sarasota, Florida, USA
Posts: 15
Thanks: 0
Thanked 0 times in 0 posts
Post imported post

Zardoz,

You seem to be printing to a file that does not allow access. In TS8, the syntax for writing a file is the command FileAppend

Here is a line in my TS strategy that writes my file to NT V3.027 to enter a strategy order on the ER.

FileAppend("C:\Program Files\NinjaTrader\Ninja V3.027 Cash\AT\order.txt",
"ER2,1,GTC,BUY,LMT,"+numtostr(Close,2)+",,,,,,FALS E,ER 2C 3.0T 4.0T,,");

The numtostr command inserts the closing price of the bar into the file prior to it being written.

Hope this helps.

Merv



Merv is offline  
Reply With Quote
Old 03-31-2005, 02:54 AM   #9
NinjaTrader_Ray
Administrator
 
NinjaTrader_Ray's Avatar
 
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
Post imported post

We do not have any TS Easy Language experience here and would not know what the issue is with your ability to write out files. Hopefully Merv's comments will be of value. Thanks for that Merv.

On another note, a tip for anyone accessing any NT AT update files. They should be copied to another folder then read. This can avoid any potential file locking issues.

Ray
NinjaTrader_Ray is offline  
Reply With Quote
Old 03-31-2005, 03:02 AM   #10
Zardoz
Junior Member
 
Join Date: Mar 2005
Location: , ,
Posts: 20
Thanks: 0
Thanked 0 times in 0 posts
Post imported post

Thanks Merv,

I'm using TS 2000i. It states the FileAppend command is not to create a file as one has to do for NinjaTrader but to add info into a file that already exists. As Ninja deletes the file after it reads it I need to create a new file. The Print command does work sometimes, just not consistently. I will however give it a go and see what happens. I have nothing to lose at this point.

Thanks Again

Zardoz
Zardoz is offline  
Reply With Quote
Old 04-14-2005, 01:31 PM   #11
Zardoz
Junior Member
 
Join Date: Mar 2005
Location: , ,
Posts: 20
Thanks: 0
Thanked 0 times in 0 posts
Post imported post

Solved my problem. thx
Zardoz 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


All times are GMT -6. The time now is 08:46 PM.