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

Hosted Script with AddDataSeries()

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

    Hosted Script with AddDataSeries()

    Hello All,
    I use an indicator hosted in a Stretegy. The scheme is as follows:
    -The indicator has 10 AddDataSerires() based on 15 minutes, calculated on bar close. The indicator calculates some parameters from the prices of these 10 series regardless of the Primary (BarsArray[0]) Instrument. This works fine, whenever I load this indicator on a chart produces the expected output.
    -The strategy works at much higher frequency, calculated on each tick from 1 minute bars, and needs some variables from the indicator above as they become accesible. However, the strategy does not need the 10 dataseries at all, but following the Hosted recommendation of the documentation, I added them too.

    The weird thing is (Debugged with VS):
    When I load the Strategy on Strategy Analyzer, this is what happens:
    1) Strategy State.Configure is hitted
    2) Strategy State.DataLoaded is hitted
    3) Indicator State.Configure is hitted
    4) Indicator State.DataLoaded is hitted
    5) Strategy OnBarUpdate is executed for all the ticks and never produces any entry. this is because the indicator never computed anything since its OnBarUpdate Method never was called
    6) When Strategy ends, the indicator starts to compute its bars, inside OnBarUpdate but it is too late because The strategy has already ended.

    What I would like is to have step 5) and 6) in parallel. I can achieve this if I change the referenced Indicator. If the Strategy used for example another indicator that does not call AddDataSerires(), then I can see step 5) and 6) in parallel

    Of course 1 solution would be writting the Indicator's code in the Strategy but I would like to solve it in another way.
    Thanks in advance!

    #2
    Hello Julio,

    Thank you for your post.

    You would use myIndicatorName.Update() in the strategy to force the indicator update. For example:
    Code:
    SMA(14).Update();
    For information on Update() please visit the following link: https://ninjatrader.com/support/help...-us/update.htm

    Please let me know if you have any questions.

    Comment


      #3
      Hello Patrick,
      Yes, problem solved. The documentation is clear about it.
      Thanks!

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by rtwave, 04-12-2024, 09:30 AM
      4 responses
      31 views
      0 likes
      Last Post rtwave
      by rtwave
       
      Started by yertle, Yesterday, 08:38 AM
      7 responses
      29 views
      0 likes
      Last Post yertle
      by yertle
       
      Started by bmartz, 03-12-2024, 06:12 AM
      2 responses
      22 views
      0 likes
      Last Post bmartz
      by bmartz
       
      Started by funk10101, Today, 12:02 AM
      0 responses
      7 views
      0 likes
      Last Post funk10101  
      Started by gravdigaz6, Yesterday, 11:40 PM
      1 response
      9 views
      0 likes
      Last Post NinjaTrader_Manfred  
      Working...
      X