Go Back   NinjaTrader Support Forum > NinjaTrader 8 > Strategy Development

Strategy Development Support for the development of custom automated trading strategies using NinjaScript.

NinjaTrader
Reply
 
Thread Tools Display Modes
Old 03-19-2017, 07:13 AM   #1
RiversideDude
Senior Member
 
Join Date: Aug 2014
Posts: 128
Thanks: 0
Thanked 4 times in 4 posts
Default NT Ninjascript General Questions

When do these events get created?

OnFundamentalData()
OnMarketDepth()
OnAccountItemUpdate()
OnExecutionUpdate()
OnOrderTrace()
OnOrderUpdate()
OnPositionUpdate()

What causes the green bar to show up on the left side in the Ninjascript editor?

Where is the default quantity set?
EnterShort(Convert.ToInt32(DefaultQuantity), "");

Thanks in advance!!
RiversideDude is offline  
Reply With Quote
Old 03-19-2017, 06:19 PM   #2
NinjaTrader_ChelseaB
NinjaTrader Customer Service
 
NinjaTrader_ChelseaB's Avatar
 
Join Date: Dec 2012
Location: Denver, CO
Posts: 6,881
Thanks: 113
Thanked 1,458 times in 1,384 posts
Default

Hello RiversideDude,

I'm unsure of your first question.

Are you asking about the internal code of NinjaTrader of where these methods are declared behind the scenes? (Where these are created?)

Or are you asking when these methods are triggered?
If you are asking when these are triggered, I would recommend looking each method up in the help guide which will state when each method is triggered. For example OnFundamentalData() is triggered when fundamental data is received. OnMarketDepth is triggered when there is a change in Level II data. etc.
OnFundamentalData() - http://ninjatrader.com/support/helpG...mentaldata.htm
OnMarketDepth() - http://ninjatrader.com/support/helpG...arketdepth.htm
OnAccountItemUpdate() - http://ninjatrader.com/support/helpG...itemupdate.htm
OnExecutionUpdate() - http://ninjatrader.com/support/helpG...tionupdate.htm
OnOrderTrace() - http://ninjatrader.com/support/helpG...ordertrace.htm
OnOrderUpdate() - http://ninjatrader.com/support/helpG...rderupdate.htm
OnPositionUpdate() - http://ninjatrader.com/support/helpG...tionupdate.htm

The green line highlighter on the left of the NinjaScript Editor will appear on lines with changes after the changes have been compiled.

The Default quantity is set in the Strategy Parameters by the user running the script. See 'Set order quantity' on the Running a NinjaScript Strategy page of the help guide.
http://ninjatrader.com/support/helpG...tegyProperties
NinjaTrader_ChelseaB is offline  
Reply With Quote
Old 03-19-2017, 08:25 PM   #3
RiversideDude
Senior Member
 
Join Date: Aug 2014
Posts: 128
Thanks: 0
Thanked 4 times in 4 posts
Default

So right now I only have two event procedures in my strategy. I read the documentation and it says what they are and what they do, but what it doesn't say is when the code snippet gets added. Do I need to manually add them?

Thanks!!
Last edited by RiversideDude; 03-19-2017 at 09:49 PM.
RiversideDude is offline  
Reply With Quote
Old 03-20-2017, 04:04 PM   #4
NinjaTrader_ChelseaB
NinjaTrader Customer Service
 
NinjaTrader_ChelseaB's Avatar
 
Join Date: Dec 2012
Location: Denver, CO
Posts: 6,881
Thanks: 113
Thanked 1,458 times in 1,384 posts
Default

Hello RiversideDude,

What you mean by event procedures?

When you want the logic to trigger?

Likely you would add the logic to OnBarUpdate.

If you would like to take on learning NinjaScript, we have a fully documented help guide which will help you get started with Ninja Script. You will find language references to all of the methods and functions you will be using. You will also see a tutorial section which will help you create your first indicator and get you started with some of these concepts.
A link to our Help Guide with set of specific tutorials for creating conditions in the NinjaTrader 8 Strategy Builder in the NinjaTrader 8 help guide:
http://ninjatrader.com/support/helpG...on_builder.htm

The entire Alphabetical Reference can be found with the following link:
http://ninjatrader.com/support/helpG..._reference.htm

The best way to begin learning NinjaScript is to use the Strategy Builder. With the Strategy Builder you can setup conditions and variables and then see the generated code in the NinjaScript Editor by clicking the View Code button.

I'm also proving a link to a pre-recorded set of videos 'Strategy Builder 301' and 'NinjaScript Editor 401' for you to view at your own convenience.
Strategy Builder 301 - https://www.youtube.com/watch?v=HCyt...We0Nf&index=10
NinjaScript Editor 401 - https://www.youtube.com/watch?v=BA0W...ZmVnauWXkWe0Nf

If you are new to C#, to get a basic foundation for the concepts and syntax used in NinjaScript I would recommend this section of articles in our help guide first:
http://ninjatrader.com/support/helpG...g_concepts.htm

I am also linking you to the Educational Resources section of the Help Guide to help you get started with NinjaScript:
http://ninjatrader.com/support/helpG..._resources.htm

We also have a few tutorials in our NinjaTrader 7 help guide for both Indicators and Strategies.
http://www.ninjatrader.com/support/h...ndicators2.htm
http://www.ninjatrader.com/support/h...strategies.htm
You will find Reference Samples online as well as some Tips and Tricks for both indicators and strategies:
Click here to see our NinjaScript Reference Samples: http://www.ninjatrader.com/support/f...splay.php?f=30
Click here to see our NinjaScript Tips: http://www.ninjatrader.com/support/f...ead.php?t=3229

These samples can be downloaded, installed and modified from NinjaTrader and hopefully serve as a good base for your custom works.

There is a also a growing library of user submitted custom indicators (100+) that can be downloaded from our support form. Please look in the NinjaScript File Sharing section of our support forum as you may find what you are looking for there: http://www.ninjatrader.com/support/f...splay.php?f=37
NinjaTrader_ChelseaB is offline  
Reply With Quote
Old 03-20-2017, 04:29 PM   #5
RiversideDude
Senior Member
 
Join Date: Aug 2014
Posts: 128
Thanks: 0
Thanked 4 times in 4 posts
Default

Whenever you have an event driven environment like Ninjatrader, the code that fires when the event triggers is called an event procedure, like OnBarUpdate; When an OnBarUpdate event happens, the code, often called a procedure in Microsoft IDEs, executes.

To simplify the question, why do I only have OnBarUpdate and OnStateChange in my strategy?

Thanks!!
RiversideDude is offline  
Reply With Quote
Old 03-21-2017, 11:36 AM   #6
NinjaTrader_ChelseaB
NinjaTrader Customer Service
 
NinjaTrader_ChelseaB's Avatar
 
Join Date: Dec 2012
Location: Denver, CO
Posts: 6,881
Thanks: 113
Thanked 1,458 times in 1,384 posts
Default

Hello RiversideDude,

Thank you for clarification with this.

In C# these are called methods.

Below are links to 3rd party educational sites that detail.
https://msdn.microsoft.com/en-us/library/ms173114.aspx
https://www.dotnetperls.com/overload

The Wizard will automatically add OnStateChange and OnBarUpdate because these are both required to be in the script. The other methods are optional and would be added by the developer if the developer would like to use them.
There are some methods already created in NinjaScript that you can overload. You can also create your own methods.

http://ninjatrader.com/support/helpG...marketdata.htm
http://ninjatrader.com/support/helpG...arketdepth.htm
http://ninjatrader.com/support/helpG...rderupdate.htm
http://ninjatrader.com/support/helpG...tionupdate.htm
Last edited by NinjaTrader_ChelseaB; 03-22-2017 at 09:26 AM.
NinjaTrader_ChelseaB is offline  
Reply With Quote
Old 03-21-2017, 10:19 PM   #7
RiversideDude
Senior Member
 
Join Date: Aug 2014
Posts: 128
Thanks: 0
Thanked 4 times in 4 posts
Default

Thanks ChelseaB.
RiversideDude 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
General questions RiversideDude Strategy Development 3 04-16-2016 09:21 AM
General questions safetrading Platform Technical Support 3 09-24-2009 11:03 AM
General questions about NT BrianNC Platform Technical Support 5 09-06-2009 04:38 AM
A few general questions Rhyshaelkan Platform Technical Support 1 07-30-2009 03:21 AM
Two general questions coolmoss Platform Technical Support 1 03-17-2008 02:36 PM


All times are GMT -6. The time now is 02:49 AM.

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.