Enqueue a variable - futures io
futures io futures trading



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




Welcome to futures io: the largest futures trading community on the planet, with well over 125,000 members
  • 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 and simple.

-- Big Mike, Site Administrator

(If you already have an account, login at the top of the page)

 
Search this Thread
 

Enqueue a variable

(login for full post details)
  #1 (permalink)
Tampa, FL
 
Experience: Beginner
Platform: NinjaTrader, Sierra Chart
Broker: Mirus Futures/Zen-Fire
Trading: 6E, M6E, 6J
 
Xav1029's Avatar
 
Posts: 1,375 since Dec 2011
Thanks: 1,452 given, 3,369 received

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 futures io Trade Journal Started this thread Reply With Quote

Journal Challenge February 2021 results (so far):
Competing for $1500 in prizes from Topstep
looks_oneSBtrader82 's Trading Journalby SBtrader82
(167 thanks from 31 posts)
looks_twoJust BEING a Trader: Letting Go!!by iqgod
(116 thanks from 33 posts)
looks_3Wisdom is Emptinessby Mtype
(68 thanks from 25 posts)
looks_4Deetee’s DAX Trading Journal (time based)by Deetee
(31 thanks from 17 posts)
looks_5Journal for peanuts1956by peanuts1956
(23 thanks from 13 posts)
 
 
(login for full post details)
  #3 (permalink)
Wrocław, Poland
 
Experience: Intermediate
Platform: NinjaTrader, Racket
Trading: Ockham's razor
 
gregid's Avatar
 
Posts: 651 since Aug 2009
Thanks: 320 given, 620 received


Do you receive any errors?

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


Reply With Quote
The following user says Thank You to gregid for this post:
 
(login for full post details)
  #4 (permalink)
Tampa, FL
 
Experience: Beginner
Platform: NinjaTrader, Sierra Chart
Broker: Mirus Futures/Zen-Fire
Trading: 6E, M6E, 6J
 
Xav1029's Avatar
 
Posts: 1,375 since Dec 2011
Thanks: 1,452 given, 3,369 received


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 futures io Trade Journal Started this thread Reply With Quote
 
(login for full post details)
  #5 (permalink)
Wrocław, Poland
 
Experience: Intermediate
Platform: NinjaTrader, Racket
Trading: Ockham's razor
 
gregid's Avatar
 
Posts: 651 since Aug 2009
Thanks: 320 given, 620 received

@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
The following user says Thank You to gregid for this post:
 
(login for full post details)
  #6 (permalink)
Tampa, FL
 
Experience: Beginner
Platform: NinjaTrader, Sierra Chart
Broker: Mirus Futures/Zen-Fire
Trading: 6E, M6E, 6J
 
Xav1029's Avatar
 
Posts: 1,375 since Dec 2011
Thanks: 1,452 given, 3,369 received

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 futures io Trade Journal Started this thread Reply With Quote
 
(login for full post details)
  #7 (permalink)
Tampa, FL
 
Experience: Beginner
Platform: NinjaTrader, Sierra Chart
Broker: Mirus Futures/Zen-Fire
Trading: 6E, M6E, 6J
 
Xav1029's Avatar
 
Posts: 1,375 since Dec 2011
Thanks: 1,452 given, 3,369 received

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 futures io Trade Journal Started this thread Reply With Quote
The following user says Thank You to Xav1029 for this post:
 
(login for full post details)
  #8 (permalink)
Wrocław, Poland
 
Experience: Intermediate
Platform: NinjaTrader, Racket
Trading: Ockham's razor
 
gregid's Avatar
 
Posts: 651 since Aug 2009
Thanks: 320 given, 620 received

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

Reply With Quote
The following user says Thank You to gregid for this post:
 
(login for full post details)
  #9 (permalink)
New Orleans, La (Mardi Gras City)
 
Experience: Advanced
Platform: NinjaTrader
Broker: Ninjatrader / Optimus Futures / AmpFutures
Trading: ES / 6E / 6B / CL
 
DavidHP's Avatar
 
Posts: 1,347 since Aug 2009
Thanks: 9,428 given, 2,360 received

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
The following user says Thank You to DavidHP for this post:
 
(login for full post details)
  #10 (permalink)
Tampa, FL
 
Experience: Beginner
Platform: NinjaTrader, Sierra Chart
Broker: Mirus Futures/Zen-Fire
Trading: 6E, M6E, 6J
 
Xav1029's Avatar
 
Posts: 1,375 since Dec 2011
Thanks: 1,452 given, 3,369 received



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
Register to download File Type: cs XavGlassBoxX0.cs (31.7 KB, 8 views)
Visit my futures io Trade Journal Started this thread Reply With Quote


futures io Trading Community Platforms and Indicators NinjaTrader > Enqueue a variable


Last Updated on August 31, 2012


Upcoming Webinars and Events
 

NinjaTrader Indicator Challenge!

Ongoing
 

Journal Challenge w/$1500 prizes from Topstep!

February
 

Battlestations! Show us your trading desk - $1,500 in prizes!

March
 

Call Option Buying: The New Pain Trade? w/Carley Garner

Elite only
     



Copyright © 2021 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432, info@futures.io
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.
no new posts