Hey @gregid I had initialized the Queue beforehand. Actually I used the dictionary method you helped me with, but a Queue dictionary. I was able to pass a value directly into the queue, but when I tried to pass a variable, it would not work.
I deleted all the code and gave it another try, and it worked this time. I don't know what I had done wrong before, but had looked over the code 20 times and could not find anything wrong. Time to get some rest now, this project is going to take a while
#region Variables
double test = .9898;
private Dictionary<int, DataSeries>indicatorD; //Used to store the indicator values
private Dictionary<int, DataSeries>EPLd; //Used to store short term expected profit for long trades
private Dictionary<int, DataSeries>EPSd; //Used to store short term expected profit for short trades
private Dictionary<int, DataSeries>MFE_Ld; //
private Dictionary<int, DataSeries>MAE_Ld;
private Dictionary<int, DataSeries>MFE_Sd;
private Dictionary<int, DataSeries>MAE_Sd;
private Dictionary<int, Queue<double>>Qtest;
#endregion
protected override void Initialize()
{
Overlay = false;
//-------------------Eight Data Series for the indicators------------------------------
indicatorD = new Dictionary<int, DataSeries>();
//---------------------Twenty Four of the following-----------------------------------
EPLd = new Dictionary<int, DataSeries>();
EPSd = new Dictionary<int, DataSeries>();
MFE_Ld = new Dictionary<int, DataSeries>();
MAE_Ld = new Dictionary<int, DataSeries>();
MFE_Sd = new Dictionary<int, DataSeries>();
MAE_Sd = new Dictionary<int, DataSeries>();
Qtest = new Dictionary<int, Queue<double>>();
}
protected override void OnStartUp()
{
for(int i = 0; i < 8; i++)
{
indicatorD[i] = new DataSeries(this);
}
for (int i = 0; i < 24; i++)
{
EPLd[i] = new DataSeries(this);
EPSd[i] = new DataSeries(this);
MFE_Ld[i] = new DataSeries(this);
MAE_Ld[i] = new DataSeries(this);
MFE_Sd[i] = new DataSeries(this);
MAE_Sd[i] = new DataSeries(this);
}
for(int i = 0; i < 8; i++)
{
Qtest[i] = new Queue<double>();
}
}
protected override void OnBarUpdate()
{
Qtest[0].Enqueue(test);
//test+=1;
Print(Qtest[0].Peek());
}
My previous try was an int Queue, and I could not pass CurrentBar to it or an int variable. Don't know why, but a fresh start worked
The following user says Thank You to Xav1029 for this post:
I have used the routine in several custom indicators and it works well for me.
Thanks for the response. I am still building the foundation for the tool I am working on, and for some reason Peek is not returning the same values as Dequeue. Please see attatched file and what gets printed in the output window.
EDIT: Disregard this post. I had the beginning and end of the queue mixed up in my head. I thought the beginning was the last item added, but that is actually the end due to the FIFO structure that I am trying to achieve.