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 1,989 views
    2. thumb_up 5 thanks given
    3. group 3 followers
    1. forum 9 posts
    2. attach_file 1 attachments




 
Search this Thread

Enqueue a variable

  #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?
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
About a successful futures trader who didnt know anythin …
Psychology and Money Management
Cheap historycal L1 data for stocks
Stocks and ETFs
Better Renko Gaps
The Elite Circle
How to apply profiles
Traders Hideout
 
  #3 (permalink)
 
gregid's Avatar
 gregid 
Wrocław, Poland
 
Experience: Intermediate
Platform: NinjaTrader, Racket
Trading: Ockham's razor
Posts: 650 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: 650 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: 650 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: ES / 6E / 6B / CL
Frequency: Every few days
Duration: Minutes
Posts: 1,612 since Aug 2009
Thanks Given: 11,342
Thanks Received: 2,747

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 Twitter 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


© 2024 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 - Privacy Policy - Downloads - Top
no new posts