Go Back   NinjaTrader Support Forum > NinjaTrader 7 > Indicator Development

Indicator Development Support for the development of custom indicators using NinjaScript.

NinjaTrader
Reply
 
Thread Tools Display Modes
Old 02-16-2017, 05:58 PM   #1
Griesha_uk
Junior Member
 
Join Date: Nov 2015
Posts: 7
Thanks: 3
Thanked 0 times in 0 posts
Default Indicator "Executing" when not loaded

I have been developing a pair of indicators. (1) to read many days of 1 Minute data, analyse it, and save results to a file (R). This summary information is to be read by a second (2) indicator to combine with real-time data and plot on a specific chart.

There is a third (3) indicator relevent here, though it is only a test indicator used to explore various constructs like array and string methods.

The Problem

I kept getting a message saying that (R) could not be accessed because it was being used by another process. I stripped everything back so that (1) was the only custom indicator loaded. I deleted the file (R), restarted NT.

On the Output panel I got the same message but the "cannot access.." was associated with (2), even though it was not loaded on any chart. Moreover, I also noticed a "Print" message that I had coded into (3) that was being output despite it not being loaded either.

I cannot make any progress until I can resolve this.

Ideas/solutions please.

Thanks G.
Griesha_uk is offline  
Reply With Quote
Old 02-17-2017, 08:07 AM   #2
NinjaTrader_JessicaP
NinjaTrader Customer Service
 
NinjaTrader_JessicaP's Avatar
 
Join Date: Dec 2015
Location: Denver, CO
Posts: 2,403
Thanks: 206
Thanked 504 times in 496 posts
Default

Hello Griesha_uk, and thank you for your question.

NinjaTrader 8 is a multithreaded application, and tasks such as file access will most easily avoid these kinds of race conditions if they are restricted to the main UI thread. While you will need to add your own file I/O code, the attached educational reference sample add-on should help you get started. It will run a daemon once a microsecond which will check a public static string to see if it is non-empty, and if it is, it will call your code to print this message to a file. Please let us know if there are any other ways we can help.
Attached Files
File Type: cs PrintDaemon.cs (3.7 KB, 2 views)
NinjaTrader_JessicaP is offline  
Reply With Quote
Old 02-17-2017, 08:53 AM   #3
Griesha_uk
Junior Member
 
Join Date: Nov 2015
Posts: 7
Thanks: 3
Thanked 0 times in 0 posts
Default Indicator "Eexcuting" when not loaded

Thanks, JessicaP, the information you sent may be useful in the future, but I am using NT7 and have no real intention of going to NT8 in the near future. I’d prefer to see NT8 settle down for a few more month first, then I can justify the full weekend or so to do the conversion from NT7.

Unfortunately, in relation to NT7, I don’t think the question was answered. I understand how file usage can cause contention problems when 2 or more studies are writing/reading (potentially) at the same time. I think I can probably code around that, but need a clean starting point. Hence:

1/ How can an indicator be executing when not being used/loaded on any chart? (in any Workspace).

2/ If there is a known issue, is there a workaround?

3/ Could my “NT code package” be corrupted? Should I simply reinstall? (How would I safely do this without losing my Template and Workspace setup, and of course, all the Indicators I have coded).

Many Thanks,

G

[PS. I have a lot of experience around procedural languages, but struggle with object-orientated languages. So, please assume I am a novice]

PPS. I just noticed another anomaly. Having removed the indicators I mentioned from all charts, and having cleared the Output window, I was about to add an indicator (std 30 period EMA). Immediately I clicked on the Indicator selection in the drop-down list, the Output window populated with the same problem info: "...cannot access.." etc. Strange?

Please see attached...
Attached Images
File Type: jpg Output Window Screenshot.JPG (90.3 KB, 2 views)
Last edited by Griesha_uk; 02-17-2017 at 09:19 AM. Reason: Noticed an additional phenomenon, which is relevent
Griesha_uk is offline  
Reply With Quote
Old 02-17-2017, 09:54 AM   #4
NinjaTrader_JessicaP
NinjaTrader Customer Service
 
NinjaTrader_JessicaP's Avatar
 
Join Date: Dec 2015
Location: Denver, CO
Posts: 2,403
Thanks: 206
Thanked 504 times in 496 posts
Default

Thank you for this additional information. Please note that NinjaTrader 7 is no longer under active development, and so our goal will be to find a work-around solution. Fully debugging user code is also beyond the scope of the support we may provide, however, we will be happy to put you in touch with this kind of help should you desire it.

This said, the easiest approach as far as debugging would be to save your workspace, close Ninja, and delete your (My) Documents\NinjaTrader 7\workspaces\_Workspaces.xml file . This will cause Ninja to load a single, blank workspace on its next start-up. From here, please apply just one or the other of your indicators, to ensure these are individually able to use your code which writes to a file. Finally, try these together in the same workspace.

To avoid this entirely, I would also like to recommend the built-in MSDN C# Path.GetTempFileName method, publicly available documentation here,

https://msdn.microsoft.com/en-us/lib...pfilename.aspx

This method was developed with this exact situation in mind. This way each of your indicators will have a unique filename only that indicator instance has access to.
NinjaTrader_JessicaP is offline  
Reply With Quote
Reply

Tags
loading file access

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
Sim Account - "Buying Power", "Cash Value", "Initial Margin" don't seem quite right cgeorgan Strategy Development 10 06-10-2016 12:40 PM
Looking for a "countdown-like" or "distance-from" indicator Prov1322 Indicator Development 6 07-22-2013 10:17 AM
summary of "strategy realized" is not equal "account performance, total net profit"" Fragolino Platform Technical Support 1 02-19-2009 05:12 AM
executing code after indicator has been loaded? NinjaCustomer Indicator Development 1 02-05-2009 10:59 PM
Line "names" in Indicator Box change to "Line" after modification higler Platform Technical Support 3 05-02-2007 06:05 AM


All times are GMT -6. The time now is 04:29 PM.

Futures, foreign currency and options trading contains substantial risk and is not for every investor. An investor could potentially lose all or more than the initial investment. Risk capital is money that can be lost without jeopardizing ones financial security or lifestyle. Only risk capital should be used for trading and only those with sufficient risk capital should consider trading. Past performance is not necessarily indicative of future results. View Full Risk Disclosure.

CFTC Rules 4.41 - Hypothetical or Simulated performance results have certain limitations, unlike an actual performance record, simulated results do not represent actual trading. Also, since the trades have not been executed, the results may have under-or-over compensated for the impact, if any, of certain market factors, such as lack of liquidity. Simulated trading programs in general are also subject to the fact that they are designed with the benefit of hindsight. No representation is being made that any account will or is likely to achieve profit or losses similar to those shown.

This website is hosted and operated by NinjaTrader, LLC (“NT”), a software development company which owns and supports all proprietary technology relating to and including the NinjaTrader trading platform. NT is an affiliated company to NinjaTrader Brokerage (“NTB”), which is a NFA registered introducing broker (NFA #0339976) providing brokerage services to traders of futures and foreign exchange products. This website is intended for educational and informational purposes only and should not be viewed as a solicitation or recommendation of any product, service or trading strategy. No offer or solicitation to buy or sell securities, securities derivative or futures products of any kind, or any type of trading or investment advice, recommendation or strategy, is made, given, or in any manner endorsed by any NT affiliate and the information made available on this Web site is not an offer or solicitation of any kind. Specific questions related to a brokerage account should be sent to your broker directly. The content and opinions expressed on this website are those of the authors and do not necessarily reflect the official policy or position of NT or any of its affiliates. 

Vendors along with their websites, products and services, collectively referred to as (“Vendor Content”), are independent persons or companies that are in no manner affiliated with NT or any if its affiliates. NT or any of its affiliates are not responsible for, do not approve, recommend or endorse any Vendor Content referenced on this website and it’s your sole responsibility to evaluate Vendor Content. Please be aware that any performance information provided by a vendor should be considered hypothetical and must contain the disclosures required by NFA Rule 2-29(c). If you are interested in learning more about, or investigating the quality of, any such Vendor Content you must contact the vendor, provider or seller of such Vendor Content. No person employed by, or associated with, NT or any of its affiliates is authorized to provide any information about any such Vendor Content. Visit the CFTC resources for education regarding the industry and signs of fraud.