Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Accessing indicator plot data within a strategy

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

    #31
    Originally posted by dynoweb View Post
    I have an update on this, I got it working when I changed the indicator code from using a DataSeries to the Plot DataSeries.

    If you can tell me what I did wrong, I think it might help everyone.

    from
    if (CurrentBar % 5 == 0)
    lower.Set(2, CurrentBar);

    to
    if (CurrentBar % 5 == 0)
    Values[1][2] = CurrentBar;
    By default, a DataSeries holds only 256 values: a Plot holds all values. You can make a DataSeries hold all values, either when you initialize it specifically, or you can make all the DataSeries in the indicator hold all values by using a directive (in reality, just setting an enum property of the class) in the Initialize() method.

    ref: http://www.ninjatrader.com/support/h...rslookback.htm
    Last edited by koganam; 01-18-2015, 03:00 PM.

    Comment


      #32
      Thanks koganam, adding MaximumBarsLookBack.Infinite to the strategy fixed the overwrite issue.

      The second part of this still exists, which is if I only use the Plot, I have to access [0] plot instance before I can use [2] instance.

      // Doesn't work when these next two lines are commented out
      // if (FiveBarPattern().Plot1.ContainsValue(0))
      // Print(Time + " 0 - FiveBarLower: " + FiveBarPattern().Plot1[0]);

      if (FiveBarPattern().Plot1.ContainsValue(2))
      Print(Time + " 2 - FiveBarLower: " + FiveBarPattern().Plot1[2]);

      Why do I need to access element [0], is there a refresh that happens to element[2] when I try to read element[0]?

      I have attached the sample strategy and the sample indicator which illustrates this problem. Look at the console out to see what I'm talking about with and without comments on those lines above.
      Attached Files

      Comment


        #33
        Originally posted by dynoweb View Post
        Thanks koganam, adding MaximumBarsLookBack.Infinite to the strategy fixed the overwrite issue.

        The second part of this still exists, which is if I only use the Plot, I have to access [0] plot instance before I can use [2] instance.

        // Doesn't work when these next two lines are commented out
        // if (FiveBarPattern().Plot1.ContainsValue(0))
        // Print(Time + " 0 - FiveBarLower: " + FiveBarPattern().Plot1[0]);

        if (FiveBarPattern().Plot1.ContainsValue(2))
        Print(Time + " 2 - FiveBarLower: " + FiveBarPattern().Plot1[2]);

        Why do I need to access element [0], is there a refresh that happens to element[2] when I try to read element[0]?

        I have attached the sample strategy and the sample indicator which illustrates this problem. Look at the console out to see what I'm talking about with and without comments on those lines above.
        You will have to investigate your indicator. It is highly restricted, setting values only on a highly restrictive circumstance.

        Are there any errors in your log?

        Comment


          #34
          Originally posted by dynoweb View Post
          Thanks koganam, adding MaximumBarsLookBack.Infinite to the strategy fixed the overwrite issue.

          The second part of this still exists, which is if I only use the Plot, I have to access [0] plot instance before I can use [2] instance.

          // Doesn't work when these next two lines are commented out
          // if (FiveBarPattern().Plot1.ContainsValue(0))
          // Print(Time + " 0 - FiveBarLower: " + FiveBarPattern().Plot1[0]);

          if (FiveBarPattern().Plot1.ContainsValue(2))
          Print(Time + " 2 - FiveBarLower: " + FiveBarPattern().Plot1[2]);

          Why do I need to access element [0], is there a refresh that happens to element[2] when I try to read element[0]?

          I have attached the sample strategy and the sample indicator which illustrates this problem. Look at the console out to see what I'm talking about with and without comments on those lines above.
          Please try:
          if (FiveBarPattern().Plot1.ContainsValue(2) && CurrentBar >= 2)
          Print(Time + " 2 - FiveBarLower: " + FiveBarPattern().Plot1[2]);
          ninZa
          NinjaTrader Ecosystem Vendor - ninZa.co

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          672 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          379 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          111 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          575 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          582 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X