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

problem returning correct values from a Data Series variable in a multi-series envr

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

    problem returning correct values from a Data Series variable in a multi-series envr

    Ninja Trader Support,
    I have a problem returning correct values from a Data Series variable in a multi-series environment.
    I have 4 charts in my workspace: 1, 3, 9 minute charts and a 144 tick chart. I created a custom indicator that determines the trend with CalculateOnBarClose(COBC) = true. In this indicator I created a public Data Series variable that contains the trend status; up or down. I applied this indicator to the minute charts.
    I created another custom indicator that determines the trend agreement among the minute charts also with COBC = true. I added 3 objects to this indicator: 1, 3, and 9 minute charts creating a multi-series environment. This indicator accesses the public Data Series trend status variable from the trend indicator to build a trend agreement condition in order to plot a bar graph for the trend agreement among the 1, 3, and 9 minute charts. I apply this indicator to the tick chart. The trend agreement plot correctly plots the trend agreement as confirmed by visually comparing the trend status on the 1, 3, and 9 minute charts against the trend agreement plot.
    So far so good, but a problem arises in my third custom indicator. I created another custom indicator to detect trade setup conditions to provide a setup alert. This indicator has COBC = false because my alerts need to detect intra-bar any valid setup conditions to be timely enough to respond and place an order. I apply this indicator to the tick chart. One of the conditions for this setup alert is the trend agreement status. But, this is where the problem occurs. The values returned from the same public Data Series trend status variable from the trend indicator are incorrect. If I set COBC = true then the values returned are correct. However, with COBC = true, the setup alerts will be too late since they will occur when the bar closes.
    To troubleshoot this problem, I added Print statements to print out the values of the public Data Series trend status variable in both custom indicators, one with COBC = true and one with COBC = false. The public Data Series trend status variable comes from an indicator with COBC = true. The values printed with the same time stamp are different. The values printed from the indicator with COBC = true were correct. The values from the indicator with COBC = false were incorrect. But, once again, if I change COBC = true in the second indicator, then the values printed now are also correct.
    Is it possible to access a public Data Series variable in a custom indicator with COBC = true from another custom indicator with COBC = false and get correct values returned? If so, what must I do to get correct values returned?
    Thanks in advance for any assistance with this issue.
    Steve

    #2
    Hello Steve,
    You can separate the logic of the indicator to either calculate once or tick by tick. Please refer to this sample code which further demonstrates it.
    JoydeepNinjaTrader Customer Service

    Comment


      #3
      NT_Joydeep,
      Wow, this works great now. I knew about FirstTickOfBar but did not know that I had to set BarsAgo to "1" to get the correct value for the public Data Series variable.
      Thank you so much. The NT "A Team" to the rescue again.
      Steve

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by RDTrader16, Today, 10:19 PM
      0 responses
      2 views
      0 likes
      Last Post RDTrader16  
      Started by gemify, 03-08-2023, 08:02 AM
      9 responses
      148 views
      0 likes
      Last Post culpepper  
      Started by elirion, Today, 10:03 PM
      0 responses
      1 view
      0 likes
      Last Post elirion
      by elirion
       
      Started by RaddiFX, Today, 09:55 PM
      0 responses
      6 views
      0 likes
      Last Post RaddiFX
      by RaddiFX
       
      Started by Trader146, 03-29-2024, 01:22 PM
      4 responses
      25 views
      0 likes
      Last Post Trader146  
      Working...
      X