NinjaTrader Support Forum  

Go Back   NinjaTrader Support Forum > NinjaScript Educational Resources > Reference Samples

Reference Samples Official NinjaScript reference code samples

Reply
 
Thread Tools Display Modes
Old 08-05-2009, 03:51 PM   #1
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
Default Strategy: Separating logic to either calculate once on bar close or on every tick

Reference sample for NinjaTrader 6.5.xxxx.x or greater.

Depending on your trade ideas, the timing of entries and exits could be crucial. Sometimes waiting 30 seconds for a bar to close is too long when you are trying to exit a position. To address this you could select your strategy to calculate on every single tick, but this may impact your entry timings. For example, crossover entries could flip back and forth making it difficult to place entry orders. If you are facing this issue, it is possible to separate out parts of your strategy logic to calculate on every single tick and other parts to calculate once at the end of each bar.

This reference sample demonstrates the following concepts:
  • Running some logic once per bar
  • Running other logic on every single tick
Important methods and properties used include:Other methods and properties of interest include:Import instructions for NinjaTrader 6.5.XXXX.X or greater:
  1. Download the file contained in this thread to your PC desktop
  2. From the Control Center window, select the menu File > Utilities > Import NinjaScript
  3. Select the downloaded file
Attached Files
File Type: zip SampleCalcOnBarClose.zip (6.4 KB, 1889 views)
NinjaTrader_Josh is offline  
Reply With Quote
The following 2 users say thank you to NinjaTrader_Josh for this post:
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
Calculate on bar close VS. NOT CRCatNinja General Programming 3 06-15-2009 08:56 AM
Partial Calculate On Bar Close TrendTracker General Programming 2 06-04-2009 07:35 AM
Calculate on bar close unclelou Charting 1 03-25-2009 05:43 PM
Calculate on Bar Close or not? Hugo1 Strategy Development 3 03-09-2009 07:53 AM
Question about Calculate on Bar close slowhand Strategy Development 8 02-13-2009 11:24 AM


All times are GMT -6. The time now is 02:38 PM.