View Full Version : Dataseries or Array not linked to bars
tchapman
07-16-2009, 10:15 PM
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
NetTecture
07-16-2009, 11:21 PM
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 ;)
tchapman
07-23-2009, 08:44 PM
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
qewcool
12-27-2009, 11:04 PM
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
qewcool
12-28-2009, 02:34 AM
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 ?