NexusFi: Find Your Edge


Home Menu

 





Enqueue a variable


Discussion in NinjaTrader

Updated
      Top Posters
    1. looks_one Xav1029 with 5 posts (1 thanks)
    2. looks_two gregid with 3 posts (3 thanks)
    3. looks_3 Quick Summary with 1 posts (0 thanks)
    4. looks_4 DavidHP with 1 posts (1 thanks)
    1. trending_up 2,705 views
    2. thumb_up 5 thanks given
    3. group 3 followers
    1. forum 9 posts
    2. attach_file 1 attachments




 
Search this Thread
  #1 (permalink)
 
Xav1029's Avatar
 Xav1029 
Tampa, FL
 
Experience: Beginner
Platform: NinjaTrader, Sierra Chart
Broker: Mirus Futures/Zen-Fire
Trading: 6E, M6E, 6J
Posts: 1,375 since Dec 2011
Thanks Given: 1,452
Thanks Received: 3,377

Does anyone know how to pass a variable unsing Enqueue??

for example:

double myprofit = 99.75;

myQ.Enqueue(myprofit);


This method does not work for some reason. I am looking for a FIFO structure I can use to store non-continuous data, and am open to other suggestions.


Visit my NexusFi Trade Journal Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
I Have a Thing Called Iran -- Trump Stays in DC as Airsp …
Prediction Markets & Event Contracts
Peace Deal Forward Curve: May 22%, June 51%, December 81 …
Prediction Markets & Event Contracts
Prediction Markets Expiry Day: Trump Eyes War Exit, $230 …
Prediction Markets & Event Contracts
One Wallet Made $200K in Hours: AP Probes Polymarket Cea …
Prediction Markets & Event Contracts
Thursday May 28: GDP + Core PCE + Jobless Claims All at …
Traders Hideout
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Sober Journey With S&P
24 thanks
2026 Jlab journal
10 thanks
Lady Vols Primer: Trading Volatility Journal
7 thanks
Algo automated / semi-automated trading anyone?
6 thanks
Trying to learn Volume and price action correlation
5 thanks
  #3 (permalink)
 
gregid's Avatar
 gregid 
Wrocław, Poland
 
Experience: Intermediate
Platform: NinjaTrader, Racket
Trading: Ockham's razor
Posts: 649 since Aug 2009
Thanks Given: 320
Thanks Received: 623


Do you receive any errors?

Have you initialized your queue beforehand:
 
Code
                            
myQ = new Queue<double>(); 


Reply With Quote
Thanked by:
  #4 (permalink)
 
Xav1029's Avatar
 Xav1029 
Tampa, FL
 
Experience: Beginner
Platform: NinjaTrader, Sierra Chart
Broker: Mirus Futures/Zen-Fire
Trading: 6E, M6E, 6J
Posts: 1,375 since Dec 2011
Thanks Given: 1,452
Thanks Received: 3,377


gregid View Post
Do you receive any errors?

Have you initialized your queue beforehand:
 
Code
                            
myQ = new Queue<double>(); 


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.


Visit my NexusFi Trade Journal Started this thread Reply With Quote
  #5 (permalink)
 
gregid's Avatar
 gregid 
Wrocław, Poland
 
Experience: Intermediate
Platform: NinjaTrader, Racket
Trading: Ockham's razor
Posts: 649 since Aug 2009
Thanks Given: 320
Thanks Received: 623

@Xav1029 I am afraid you will have to post a bit more of your queue/dictionary code (your declared queue, how it is initialized).

Also, are you saying you were able to do:
myQ.Enqueue(99.75);

or was your successful syntax different?


Reply With Quote
Thanked by:
  #6 (permalink)
 
Xav1029's Avatar
 Xav1029 
Tampa, FL
 
Experience: Beginner
Platform: NinjaTrader, Sierra Chart
Broker: Mirus Futures/Zen-Fire
Trading: 6E, M6E, 6J
Posts: 1,375 since Dec 2011
Thanks Given: 1,452
Thanks Received: 3,377

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


Visit my NexusFi Trade Journal Started this thread Reply With Quote
  #7 (permalink)
 
Xav1029's Avatar
 Xav1029 
Tampa, FL
 
Experience: Beginner
Platform: NinjaTrader, Sierra Chart
Broker: Mirus Futures/Zen-Fire
Trading: 6E, M6E, 6J
Posts: 1,375 since Dec 2011
Thanks Given: 1,452
Thanks Received: 3,377

Here is the code that worked:

 
Code
#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


Visit my NexusFi Trade Journal Started this thread Reply With Quote
Thanked by:
  #8 (permalink)
 
gregid's Avatar
 gregid 
Wrocław, Poland
 
Experience: Intermediate
Platform: NinjaTrader, Racket
Trading: Ockham's razor
Posts: 649 since Aug 2009
Thanks Given: 320
Thanks Received: 623

Glad fresh start worked for you - I do it all the time


Reply With Quote
Thanked by:
  #9 (permalink)
 
DavidHP's Avatar
 DavidHP 
Isla Mujeres, MX
Legendary Market Wizard
 
Experience: Advanced
Platform: NinjaTrader
Broker: Ninjatrader / Optimus Futures / AmpFutures
Trading: NQ / ES / 6E / 6B / CL
Frequency: Every few days
Duration: Minutes
Posts: 1,802 since Aug 2009
Thanks Given: 11,742
Thanks Received: 3,018

Here is an indicator that has a routine by jabeztrading that uses enqueue to plot swings.
It is very effective and shows how to set it up.

NinjaTrader Support Forum - View Single Post - Swing indicator edits

I have used the routine in several custom indicators and it works well for me.


Rejoice in the Thunderstorms of Life . . .
Knowing it's not about Clouds or Wind. . .
But Learning to Dance in the Rain ! ! !
Follow me on X Reply With Quote
Thanked by:
  #10 (permalink)
 
Xav1029's Avatar
 Xav1029 
Tampa, FL
 
Experience: Beginner
Platform: NinjaTrader, Sierra Chart
Broker: Mirus Futures/Zen-Fire
Trading: 6E, M6E, 6J
Posts: 1,375 since Dec 2011
Thanks Given: 1,452
Thanks Received: 3,377



DavidHP View Post
Here is an indicator that has a routine by jabeztrading that uses enqueue to plot swings.
It is very effective and shows how to set it up.

NinjaTrader Support Forum - View Single Post - Swing indicator edits

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.


Attached Files
Elite Membership required to download: XavGlassBoxX0.cs
Visit my NexusFi Trade Journal Started this thread Reply With Quote




Last Updated on August 31, 2012


© 2026 NexusFi®, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Downloads - Top
no new posts