• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Indicator: Ensuring indicator plots are valid before programmatically accessing them

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Indicator: Ensuring indicator plots are valid before programmatically accessing them

    When accessing NinjaScript indicators in other scripts it is important to check if the hosted indicator's plot values are already set prior to use in the hosting script. This check ensures that proper values are always used and that irrelevant values do not throw off the script logic. This reference sample demonstrates how to run these checks in a hosting indicator by checking another hosted indicator for set plot values.

    Another example for when you would want to use this is if you were trying to access the Pivots indicator, but did not have enough days loaded to properly calculate those values yet. Basing logic on the Pivots in such a scenario would yield values that are not useful and can be detrimental if not handled correctly in your code.

    Key concepts in this example:
    • Checking indicator plots for valid values
    • Handling logic for when the indicator plots are not valid


    Attached archive contains two indicator files.
    • SampleEveryNBarTest is the hosting indicator
    • SampleEveryNBar is the hosted indicator


    Note: When hosting an indicator in an Indicator column in the Market Analyzer you will need to manually ensure enough bars back are loaded for the indicator to calculate correctly.

    Important related documentation:

    NinjaTrader 8

    NinjaTrader 7

    Import instructions:

    NinjaTrader 8
    1. Download the file contained in this thread to your PC desktop
    2. From the Control Center window, select the menu Tools > Import > NinjaScript
    3. Select the downloaded file


    NinjaTrader 7
    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 and click Import.
    Attached Files
    Last edited by NinjaTrader_Jesse; 06-25-2015, 10:07 AM.
    Josh P.NinjaTrader Customer Service

Latest Posts

Collapse

Topics Statistics Last Post
Started by johng964, Today, 02:57 PM
1 response
7 views
0 likes
Last Post NinjaTrader_RyanS  
Started by spamula, Today, 03:00 PM
2 responses
9 views
0 likes
Last Post spamula
by spamula
 
Started by MARTIN MARTIN, Today, 01:01 PM
0 responses
10 views
0 likes
Last Post MARTIN MARTIN  
Started by bouncetherubble, Today, 10:21 AM
2 responses
14 views
1 like
Last Post bouncetherubble  
Started by tcbarrow, Today, 10:53 AM
1 response
14 views
0 likes
Last Post NinjaTrader_ChelseaB  
Working...
X