Go Back   NinjaTrader Support Forum > NinjaScript Educational Resources > Tips

Tips Official NinjaScript tips and tricks

NinjaTrader
Closed Thread
 
Thread Tools Display Modes
Old 12-24-2007, 09:46 AM   #1
NinjaTrader_Ray
Founder and CEO
 
NinjaTrader_Ray's Avatar
 
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,164
Thanks: 37
Thanked 341 times in 131 posts
Default How do I resolve NinjaScript Programming Errors?

Applies to NinjaTrader 7

You may come across various situations where your NinjaScript files will not compile. This can include situations such as:
  • You are trying to import a NinjaScript Archive File and you receive an error such as "You have custom NinjaScript files on your PC that have programming errors..."
  • You are new to NinjaScript development and somehow your files will no longer compile
Because importing NinjaScript files requires compilation of your entire NinjaScript library you will first need to resolve the errors to allow for a successful compilation.

1st Step in Resolving Errors:
  1. Backup NinjaScript files (File > Utilities > Backup, ensure that "NinjaScript Files" is checked and then press the "Run Backup" button) in version 6.5 or later
  2. Open any indicator via the menu Tools > Edit NinjaScript > Indicator
  3. Press the "F5" key on your keyboard to compile your NinjaScript library. A list of errors will appear at the bottom of the NinjaScript Editor along with the file name where each error is located.
  4. Determine if you no longer need the NinjaScript file with the errors. If you no longer need it, skip to step 9.
  5. Double click on the error message to open the NinjaScript with the errors. Try to resolve the error and recompile by pressing the "F5" key.
  6. If the error still exists in this file, "comment out" some or all of the content in the OnBarUpdate() method and recompile by pressing the "F5" key
  7. If errors still exist in this file, "comment out" some or all of the content in the Initialize() method and recompile by pressing the "F5" key
  8. If errors still exist in this file, "comment out" any properties that in the "Properties" region that may be causing the problems and recompile by pressing the "F5" key
  9. If errors still exist in this file, try to delete the indicator/strategy (See "To delete the erroneous file" instructions below)
  10. If another NinjaScript file references a file you wish to delete, open the file that references the file you wish to delete and "comment out" or delete the reference
  11. Repeat steps 2 through 10 for every NinjaScript that still has errors
To delete the erroneous file:
  1. Tools > Edit NinjaScript > "Select either Indicator or Strategy depending on what type of file you want to delete
  2. Highlight the NinjaScript file you wish to delete and press the "Delete" button
  3. If another NinjaScript file references the file you wish to delete, you must first remove the reference to the file you wish to delete, see step 10 above
  4. Press the "Cancel" button to close the NinjaScript file dialog window
How to "comment out" code:
Commenting out code simply means to identify code which will be treated as a comment (not processed) as opposed to actual program code. This can be done by adding "//" in front of each line of code. Below is an example.

Code:
double myDouble = 5;
// double myDouble = 5;
2nd Step in Resolving Errors:
If the above procedure does not resolve all errors, you may need to reinstall NinjaTrader.
  1. Backup any files you wish to back up (File > Utilities > Backup version 6.5 or later)
  2. Shut down NinjaTrader
  3. Uninstall NinjaTrader from the windows Control Panel Add/Remove Programs
  4. Manually delete the folder My Documents\<NinjaTrader Installation Folder>
  5. Clear you temporary internet files in your internet browser (browser cache)
  6. Reinstall the latest version of NinjaTrader from our website
Last edited by NinjaTrader_Jesse; 06-03-2015 at 12:59 PM.
NinjaTrader_Ray is offline  
The following 3 users say thank you to NinjaTrader_Ray for this post:
Old 06-03-2015, 01:12 PM   #2
NinjaTrader_Jesse
NinjaTrader Customer Service
 
NinjaTrader_Jesse's Avatar
 
Join Date: Mar 2014
Location: Denver, CO
Posts: 4,940
Thanks: 30
Thanked 1,263 times in 1,181 posts
Default

Applies to NinjaTrader 8

You may come across various situations where your NinjaScript files will not compile. This can include situations such as:
  • You are trying to import a NinjaScript Archive File and you receive an error such as "You have custom NinjaScript files on your PC that have programming errors..."
  • You are new to NinjaScript development and somehow your files will no longer compile

Because importing NinjaScript files requires compilation of your entire NinjaScript library you will first need to resolve the errors to allow for a successful compilation.

1st Step in Resolving Errors:
  1. Backup NinjaScript files (Tools > Export > Backup File, ensure that "NinjaScript Files" is checked and then press the "Export" button) .
  2. Open the NinjaScript Editor via the menu New > NinjaScript Editor
  3. Press the "F5" key on your keyboard to compile your NinjaScript library or right click in the window and click "Compile". A list of errors will appear at the bottom of the NinjaScript Editor along with the file name where each error is located.
  4. Determine if you no longer need the NinjaScript file with the errors. If you no longer need it, skip to step 9.
  5. Double click on the error message to open the NinjaScript with the errors. Try to resolve the error and recompile by pressing the "F5" key.
  6. If the error still exists in this file, "comment out" some or all of the content in the OnBarUpdate() method and recompile by pressing the "F5" key
  7. If errors still exist in this file, "comment out" some or all of the content in the OnStateChange() method and recompile by pressing the "F5" key
  8. If errors still exist in this file, "comment out" any properties that in the "Properties" region that may be causing the problems and recompile by pressing the "F5" key
  9. If errors still exist in this file, try to remove the file from compilation or delete the file (See "To remove or delete the erroneous file" instructions below)
  10. If another NinjaScript file references a file you wish to delete, open the file that references the file you wish to delete and "comment out" or delete the reference
  11. Repeat steps 2 through 10 for every NinjaScript that still has errors


To remove or delete the erroneous file:
With NinjaTrader 8, we now have the option to remove a file from compilation but not delete it.
This means all your code is intact but is not compiled so it will not produce errors. This also means the item is not available for use until you add it back into compilation.
  1. Open the NinjaScript Editor via the menu New > NinjaScript Editor
  2. Highlight the NinjaScript file you wish to prevent from being compiled, Right click on it and click "Exclude from Compilation".
  3. If another NinjaScript file references the file you wish to delete, you must first remove the reference to the file you wish to delete, see step 10 above
  4. You also have the option to completely delete the file as well, this is the same process as above except you would select "Remove" instead.

2nd Step in Resolving Errors:
If the above procedure does not resolve all errors, you may need to reinstall NinjaTrader.
  1. Backup NinjaScript files (Tools > Export > Backup File, ensure that "NinjaScript Files" is checked and then press the "Export" button) .
  2. Shut down NinjaTrader
  3. Uninstall NinjaTrader from the windows Control Panel Add/Remove Programs
  4. Manually delete or move the folder My Documents\NinjaTrader 8
  5. Reinstall the latest version of NinjaTrader from our website
Last edited by NinjaTrader_Jesse; 06-11-2015 at 12:10 PM.
NinjaTrader_Jesse is offline  
The following user says thank you to NinjaTrader_Jesse for this post:
Closed Thread

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
Programming connections Gumphrie Platform Technical Support 6 12-11-2009 04:09 AM
NinjaTrader programming services Raditz Indicator Development 4 06-25-2009 05:37 PM
NinjaScript export/import function related errors Rollins Platform Technical Support 7 10-31-2007 07:17 AM
Advanced Programming sbtrader General Development 3 10-26-2007 10:11 AM
Need Help Programming Custom Indicator from TS to NT stevestrading Indicator Development 4 06-20-2007 04:31 PM


All times are GMT -6. The time now is 11:19 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.