Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Dataseries or Array not linked to bars

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

    Dataseries or Array not linked to bars

    Hi,

    Is there a way to create an array or dataseries that is not linked to the bars object, ie needs to have a value for every bar.

    I only want a value to be set when an event occurs then be able to look back at the last X number of events.

    Thanks,

    Tim

    #2
    Originally posted by tchapman View Post
    Hi,

    Is there a way to create an array or dataseries that is not linked to the bars object, ie needs to have a value for every bar.

    I only want a value to be set when an event occurs then be able to look back at the last X number of events.

    Thanks,

    Tim
    I can not vouch for a data series, but arrays are generated in "NinjaScript" he same way they are in C# - it is possible, and the C# documentation can explain you the language

    Comment


      #3
      Thanks for the reply NetTecture.

      I got this working. So for the benefit of anyone else reading this here is how i did it.

      The only caveat i'll put on this is that i'm not a c# programmer so there may be a more correct or efficient way of doing this. However problem solved none the less.

      Declarations:
      //Added the following
      using System.Collections;

      Variables
      private int[] biasarray;
      private Queue biasqueue;

      Initialize
      // Initialize a queue of size 5 and array of size 6and type integer
      biasqueue = new Queue(5);
      biasarray = new int[6] {0,0,0,0,0,0};

      OnBarUpdate
      // Added the value to the queue using
      biasqueue.Enqueue(somevalue)

      // The QueueName.TrimtoSize() funtion is supposed to trim the queue to the initilised length however i couldnt get it to work so I used the following to trim the queue to the correct length

      if (biasqueue.Count > 5)
      {
      biasqueue.Dequeue();
      }

      // I then moved the queue to an array so I could read each of the values. I was essentially looking for bias change patterns by assigning HH HL LH LL each a value and matching the pattern using a case statement and displaying an alert.

      // To move the queue to an array i used this statement

      biasqueue.CopyTo(biasarray, 0);

      Cheers,

      Tim

      Comment


        #4
        Thanks I was having the same problem !

        Can you explain why you needed to fill the queue and then copy to an array instead of filling the array directly ? because of the size limit on the array and no dequeue function to trim it down ?

        Thanks

        Comment


          #5
          Reading a bit more

          I think one could have used a dataseries class as well to store the values that is being stored in the array ?

          Has anyone tried that ?

          Comment

          Latest Posts

          Collapse

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