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 > NinjaScript Development Support > General Programming

General Programming General NinjaScript programming questions.

Reply
 
Thread Tools Display Modes
Old 06-14-2012, 12:24 PM   #16
Atomic
Member
 
Join Date: Jan 2010
Posts: 85
Thanks: 4
Thanked 5 times in 4 posts
Default

Sorry, I just now saw your post. Orchart is charting part of TradeStation. In any case, whatever the problem was I believe I have taken care of it by installing a couple of utilities which I will link to here in case anyone is interested.
The first (4Gb patch) allows a 32 bit app like TradeStation to utilize 4Gb of ram if you have a 64 bit system.
http://ntcore.com/4gb_patch.php

The second semi-continuously frees up memory which some programs may have taken up but not returned to the system.
http://majorgeeks.com/CleanMem_d5993.html
Atomic is offline  
Reply With Quote
Old 06-14-2012, 12:27 PM   #17
NinjaTrader_Brett
NinjaTrader Customer Service
 
NinjaTrader_Brett's Avatar
 
Join Date: Dec 2009
Location: Denver, CO, USA
Posts: 6,498
Thanks: 109
Thanked 291 times in 280 posts
Default

Very good thanks for the information. Wish you happy trading.

-Brett
NinjaTrader_Brett is offline  
Reply With Quote
Old 06-28-2012, 09:37 AM   #18
Atomic
Member
 
Join Date: Jan 2010
Posts: 85
Thanks: 4
Thanked 5 times in 4 posts
Default

Something is continuing to happen. When I run process explorer, the amount of private bytes used by the orchart process just keep clocking up. A short time ago it was up to 1.5 Gb. I disabled the three things that are using the NtDirect dll and the private bytes dropped down about 0.4 Gb. I did not close anything other than disabling the three ELD's that were communicating with NT platform using the NtDirect. As soon as I turn them back on, the memory use starts to clock up. The amount of memory use in and of itself is not such a concern, but I know that eventually this will cause TS platform to crash. Please advise.
Attached Images
File Type: jpg NTDirect Memory Use.JPG (83.7 KB, 8 views)
Atomic is offline  
Reply With Quote
Old 06-28-2012, 10:00 AM   #19
NinjaTrader_Brett
NinjaTrader Customer Service
 
NinjaTrader_Brett's Avatar
 
Join Date: Dec 2009
Location: Denver, CO, USA
Posts: 6,498
Thanks: 109
Thanked 291 times in 280 posts
Default

Hello,

Thanks for the follow up.

You have custom code written for NTDirect.dll? I suspect that your custom code is opening the DLL and not cleaning up its resources or is doing some repetitive action over and over that is causing the memory to increase? Any idea what in your custom code would cause this? What specific strategy do you enable that causes the memory to increase?

Also when is the last time you reimported the NTDirect.dll?

Thank You.

-Brett
NinjaTrader_Brett is offline  
Reply With Quote
Old 06-28-2012, 02:58 PM   #20
Atomic
Member
 
Join Date: Jan 2010
Posts: 85
Thanks: 4
Thanked 5 times in 4 posts
Default

Quote:
Originally Posted by NinjaTrader_Brett View Post
Hello,

Thanks for the follow up.

You have custom code written for NTDirect.dll? I suspect that your custom code is opening the DLL and not cleaning up its resources or is doing some repetitive action over and over that is causing the memory to increase? Any idea what in your custom code would cause this? What specific strategy do you enable that causes the memory to increase?

Also when is the last time you reimported the NTDirect.dll?

Thank You.

-Brett
Yes, but it is only EasyLanguage, which is just using the NtDirect dll functions to send orders from TS to NT and to check order status back from NT. I'm also using the external data feed to get market data to NT. I have no way mange memory within EasyLanguage. I feel that the problem lies with frequent use of the NTOrderStatus and NTFilled functions. I've never noticed the problem using just the external data feed before and I've used it quite a long time. It's only been recently that I have been doing more intensive order management using the NtDirect dll method. I guess my question is, where does the memory management (assuming that's what's needed) have to take place. In the programming of the dll or would it be something with TradeStation. I have some ability to regulate the frequency of the function calls, so I will try to slow those down in the meantime.

Thanks for your help.
Atomic is offline  
Reply With Quote
Old 06-29-2012, 06:25 AM   #21
NinjaTrader_Brett
NinjaTrader Customer Service
 
NinjaTrader_Brett's Avatar
 
Join Date: Dec 2009
Location: Denver, CO, USA
Posts: 6,498
Thanks: 109
Thanked 291 times in 280 posts
Default

Hello,

Do you have the ability to create a test copy of this code and strategy and remove the NTFilled call as a first step. Does this remove the problem? Basically we would need to remove items one by one until we identify the problem area then we can analyze it further.

-Brett
NinjaTrader_Brett is offline  
Reply With Quote
Old 06-29-2012, 06:38 AM   #22
Atomic
Member
 
Join Date: Jan 2010
Posts: 85
Thanks: 4
Thanked 5 times in 4 posts
Default

Quote:
Originally Posted by NinjaTrader_Brett View Post
Hello,

Do you have the ability to create a test copy of this code and strategy and remove the NTFilled call as a first step. Does this remove the problem? Basically we would need to remove items one by one until we identify the problem area then we can analyze it further.

-Brett
I have created some test code which I am running now. When I get it to the point where I can demonstrate the problem in a controlled fashion, I'll send you the code. To some extent, it seems to depend on the higher data rates you get during market hours. I've been running it in the overnight market for the past few hours and I'm getting some growth in the Private Byte number, but not as much as during the day. I may have something by day end to send you.

Tom
Atomic is offline  
Reply With Quote
Old 06-29-2012, 06:48 AM   #23
NinjaTrader_Brett
NinjaTrader Customer Service
 
NinjaTrader_Brett's Avatar
 
Join Date: Dec 2009
Location: Denver, CO, USA
Posts: 6,498
Thanks: 109
Thanked 291 times in 280 posts
Default

Sounds great.

When we test samples, make sure you restart NinjaTrader to insure no issues exist prior to you testing a sample and then thinking the sample also has issue.

-Brett
NinjaTrader_Brett is offline  
Reply With Quote
Old 07-05-2012, 08:52 PM   #24
Atomic
Member
 
Join Date: Jan 2010
Posts: 85
Thanks: 4
Thanked 5 times in 4 posts
Default

Here is a little piece of code you can run to demonstrate the memory leak:
var:
intrabarpersist CurrentNtOrderID("");



once (getappinfo(airealtimecalc) = 1) begin
CurrentNTOrderID = "sell"+numtostr(barnumber,0);
value1 = NTCommand("PLACE","Sim101","sell",100,"Limit",clos e,0,"Day","",CurrentNTOrderID,"","");
print(formattime("hh:mm:ss tt",computerdatetime)," ",CurrentNTOrderID);
end;

while (NTOrderStatus(CurrentNTOrderID) = "Working" or NTOrderStatus(CurrentNTOrderID) = "PartFilled") and value1 < 20000 begin
print(formattime("hh:mm:ss tt",computerdatetime)," ",CurrentNTOrderID," ",NTOrderStatus(CurrentNTOrderID)," ",value1," ",NTFilled(CurrentNTOrderID));
value1 = value1 + 1;
end;
print(formattime("hh:mm:ss tt",computerdatetime)," ",CurrentNTOrderID," ",NTOrderStatus(CurrentNTOrderID)," ",value1," ",NTFilled(CurrentNTOrderID));

value1 = 0;

I run this on a 1 minute @ES chart. You may want to vary the number of contracts depending on how fast the market is. It will place a limit order on the first live tick. Once you get a return order status, the loop will generate a large number of function calls. When this begins, have Process Explorer open and watch the private bytes for Orchart.exe. They will just keep clocking up until TradeStation crashes. I can clear the private bytes in Orchart.exe only if I close all of the ELD's that have been communicating with the dll.

I hope this will be of some use.

Thanks.
Tom
Atomic is offline  
Reply With Quote
Old 07-06-2012, 06:16 AM   #25
NinjaTrader_Brett
NinjaTrader Customer Service
 
NinjaTrader_Brett's Avatar
 
Join Date: Dec 2009
Location: Denver, CO, USA
Posts: 6,498
Thanks: 109
Thanked 291 times in 280 posts
Default

Hello,

Thanks for taking the time to post this.

Unfortunately with this looping like that I actually would expect memory to increase. This type of looping is not something that can just be blanket tested like that would be the equivalent of testing a standard road car out to see how it drives out in the amazon jungle. Its a scenario where it is expected to fail.

Would not expect any issue in a real market scenario here with that. Could you provide any more specifics as to the scenario you are in that are running into issue with? Would recommend not making so many calls will have extreamly high overhead as you have found. Might make sure to space these calls out with some method.

-Brett
Last edited by NinjaTrader_Brett; 07-06-2012 at 06:24 AM.
NinjaTrader_Brett is offline  
Reply With Quote
Old 07-06-2012, 06:38 AM   #26
Atomic
Member
 
Join Date: Jan 2010
Posts: 85
Thanks: 4
Thanked 5 times in 4 posts
Default

Quote:
Originally Posted by NinjaTrader_Brett View Post
Hello,

Thanks for taking the time to post this.

Unfortunately with this looping like that I actually would expect memory to increase. This type of looping is not something that can just be blanket tested like that would be the equivalent of testing a standard road car out to see how it drives out in the amazon jungle. Its a scenario where it is expected to fail.

Would not expect any issue in a real market scenario here with that. Could you provide any more specifics as to the scenario you are in that are running into issue with? Would recommend not making so many calls will have extreamly high overhead as you have found. Might make sure to space these calls out with some method.

-Brett
This is what I have done for now. All the function calls for NTFilled and NTOrderStatus have been put on a timer to limit their frequency. This will probably make it manageable. I guess it will have to. Thanks for you help.

Tom
Atomic is offline  
Reply With Quote
Old 07-06-2012, 07:06 AM   #27
NinjaTrader_Brett
NinjaTrader Customer Service
 
NinjaTrader_Brett's Avatar
 
Join Date: Dec 2009
Location: Denver, CO, USA
Posts: 6,498
Thanks: 109
Thanked 291 times in 280 posts
Default

Right,

Thanks for taking the time to post that.

Biggest thing is just reducing the checks as you have seen since this adds extreme overhead.

-Brett
NinjaTrader_Brett is offline  
Reply With Quote
The following user says thank you to NinjaTrader_Brett for this post:
Old 07-10-2012, 03:47 PM   #28
Atomic
Member
 
Join Date: Jan 2010
Posts: 85
Thanks: 4
Thanked 5 times in 4 posts
Default

I have one more question, if you don't mind. I'm able to control the function calls so I don't approach the memory limit during a trading day. What I see is that the private bytes for orchart will go from 0.5Gb up to about 1.5Gb. then at the end of the day, I can reset this value by closing all of the ELD's that use the dll. It seems like there should be a simpler way to clear out the allocated memory which is not being used. If you know of anything I'd like to hear about it. Thanks.

Tom
Atomic is offline  
Reply With Quote
Old 07-11-2012, 06:11 AM   #29
NinjaTrader_Brett
NinjaTrader Customer Service
 
NinjaTrader_Brett's Avatar
 
Join Date: Dec 2009
Location: Denver, CO, USA
Posts: 6,498
Thanks: 109
Thanked 291 times in 280 posts
Default

Hello,

I am unaware of another method to clear this out, I would expect though if you didn't restart it would be no harm no foul though. Dont think you would just continue to see RAM usage go up day after day.

-Brett
NinjaTrader_Brett 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
NT performance and resource utilization boaza Automated Trading 1 12-19-2011 09:12 AM
NTDirect Interface mrlogik Automated Trading 2 06-17-2011 05:12 AM
NtDirect setup Atomic Automated Trading 3 04-21-2011 01:02 PM
Memory returned by NTDIRECT.DLL Orders, and use of SetAllocReturnString arguments douggreen Automated Trading 1 04-05-2011 04:21 PM
CPU utilization spenbm01 Automated Trading 11 06-19-2006 04:56 PM


All times are GMT -6. The time now is 12:55 AM.