Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

referenced Indicator and fresh values

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

    referenced Indicator and fresh values

    hi, lets say I use:

    if( State== State.DataLoaded){

    kn = Keltner(12);
    }


    OnBarUpdate(){
    kn.Update();
    if (kn.Upper... > ...)

    }


    should we call "Update()" on included indicator instances, to get the fresh values at first?
    ( because, as i see many NT indicators, doesnt expose dataseries with "Update()", like this:


    public Series<double> Upper
    {
    //Update(); //< -- - this is missing from NT built-in indicators, that's why i thought we should call it manually in our indis while calling NT indis
    get upper;
    }

    #2
    Hello TazoTodua,

    Thanks for opening the thread.

    When creating a Series<T> we sync it to the the underlying data series that the indicator is running off of with new Series<T>(this); Since the data series that the indicator runs on must be supplied by the hosting NinjaScript, these types should be current.

    When using public variables of different types, these are not synchronized to the data series, so they may not be current. This is when calling Update() would be advised.

    This is noted in the NT7 DataSeries documentation page, and I've requested to have this noted in the NT8 Series<T> documentation page.

    NT7 DataSeries - https://ninjatrader.com/support/help...ries_class.htm

    NT8 Series<T> - https://ninjatrader.com/support/help...s/?seriest.htm

    Please let us know if you have any additional questions.
    JimNinjaTrader Customer Service

    Comment


      #3
      thanks!
      so, can you tell me the example i.e. for ketlen channel (or any indi),
      How should I call those (Series<> public exposed variables of KeltnerChannels, like "Upper" series)

      we should add the instance in DataLoaded state or Configure? and when to Update() ?

      are there examples for Series and for different types (not **this** synced).

      Comment


        #4
        Hello TazoTodua,

        If you are calling the indicator, you can use the following syntax:

        KeltnerChannel(Close, 1.5, 10).Upper[0]

        If you are adding an instance of an indicator to the NinjaScript, you can use the syntax below:

        MyKeltnerChannel.Upper[0]

        As a tip, the Strategy Builder can be used to create condition that checks this plot, and then clicking View Code will show the generated syntax. You can use this to see how the Strategy Builder creates instances of indicators as well.

        Since the indicator uses a data series from the hosting NinjaScript, it will be synchronized and you would not need to call Update() in the getter of the child indicator for that plot's Series.

        As for additional examples with different types, I have one other example I could share that demonstrates this process with a dictionary. This is the only other example that I have prepared to share. The same concept can be applied to other types.

        That thread/example can be found here: https://ninjatrader.com/support/foru...d.php?t=108778
        Last edited by NinjaTrader_Jim; 04-12-2018, 03:53 PM.
        JimNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by bmartz, 03-12-2024, 06:12 AM
        4 responses
        32 views
        0 likes
        Last Post bmartz
        by bmartz
         
        Started by Aviram Y, Today, 05:29 AM
        4 responses
        12 views
        0 likes
        Last Post Aviram Y  
        Started by algospoke, 04-17-2024, 06:40 PM
        3 responses
        28 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Started by gentlebenthebear, Today, 01:30 AM
        1 response
        8 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Started by cls71, Today, 04:45 AM
        1 response
        7 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Working...
        X