Welcome to NexusFi: the best trading community on the planet, with over 150,000 members Sign Up Now for Free
Genuine reviews from real traders, not fake reviews from stealth vendors
Quality education from leading professional traders
We are a friendly, helpful, and positive community
We do not tolerate rude behavior, trolling, or vendors advertising in posts
We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community. It's free for basic access, or support us by becoming an Elite Member -- see if you qualify for a discount below.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
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
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.
Elite Membership required to download: XavGlassBoxX0.cs