Need Help Plotting the average of a queue - futures io
futures io



Need Help Plotting the average of a queue


Discussion in NinjaTrader

Updated
    1. trending_up 1,437 views
    2. thumb_up 4 thanks given
    3. group 2 followers
    1. forum 5 posts
    2. attach_file 3 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
 

Need Help Plotting the average of a queue

(login for full post details)
  #1 (permalink)
 Xav1029 
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,372 received

I have a project I have been working on that I just got stuck on. My goal is to track multiple automated strategies inside an indicator and to plot the average profit of the last trades stored in memory(queues). The goal is to track 24 strategies based on 8 indicators (8 based on one indy, 16 based on two indy combos). Right now I think I have most of the information being stored correctly for the single indicator strategies (MAE, MFE, Profit), but can't figure out how to plot the average of the profit queue. All strategies are broken into Long Trades - L at the end- and Short trades-S at the end. I have attached what I have so far, and here is the method I am using:

 
Code
for(int i = 0; i < 8; i++)
			{
				if(LongCount[i] < 20)
				{
					double tp=0;
					double[] profitArray = new double[LongProfit[i].Count];
					LongProfit[i].CopyTo(profitArray,0);
					
					for(int j = 0; j < LongCount[i]; j++)
					{
						//Print(profitArray[0]);
						tp+= profitArray[0];
					}
					myPlotLd[i][0] = tp / (double)LongCount[i];
					Print("Plot"+i+":"+Values[i][0]);
				}
			}
			myStrategy0L.Set(myPlotLd[0][0]);
Any help would be appreciated. There are 48 plots because I plan on splitting everything into Long and short.

Attached Files
Register to download File Type: zip XavGlassBoxX0.zip (8.1 KB, 4 views)
Visit my futures io Trade Journal Started this thread Reply With Quote

Can you help answer these questions
from other members on futures io?
Experience with AGN (Introducing Broker)
Brokers
CME removal of 16:15-30 trading halt/effect on OHL
Emini and Emicro Index
TD Sequential for NT or MW?
Platforms and Indicators
MacdBB V402 NT804 + gradient + pullback not working on N …
NinjaTrader
For the experts of Metastock
Platforms and Indicators
 
 
(login for full post details)
  #3 (permalink)
 gregid 
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

In your loop you have fixed 0 index for the profitArray. Change it to j:

 
Code
for(int j = 0; j < LongCount[i]; j++)
{
	//Print(profitArray[j]);
	tp+= profitArray[j];
}

Alternatively you could also use foreach loop, something like this:

 
Code
foreach (var q in LongProfit[i].ToList())
{
	tp += q
}

Reply With Quote
The following 2 users say Thank You to gregid for this post:
 
(login for full post details)
  #4 (permalink)
 Xav1029 
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,372 received

Once again THANK YOU @gregid. You know its time to get some sleep when you miss something so simple. LongProfit[i] is actually a queue, so I don't know if you can do do tolist()??
I plan on removing the max and min values values before finding the average, so I will be using linq. Thanks again

Visit my futures io Trade Journal Started this thread Reply With Quote
 
(login for full post details)
  #5 (permalink)
 gregid 
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

ToList is an extension method of IEnumerable and since Queue:

 
Code
                            
public class Queue<T> : IEnumerable<T>, ICollectionIEnumerable 

You are able to use extension method of IEnumerables for the Queue as well

Reply With Quote
The following 2 users say Thank You to gregid for this post:
 
(login for full post details)
  #6 (permalink)
 Xav1029 
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,372 received

So I got all the single indicator strategies to track correctly. Since this will be a discretionary indicator based on MFE/MAE for PT/SL targets, the plots are Average MFE/Average MAE stored in memory, excluding the minimum and maximums (I don't want a homerun to skew targets). Also if avg MFE is less than MinMFE, the plots are transparent (Minimum PT).

The dash style and color combinations will allow you to distinguish the strategies.

Here is what I have so far with a picture of default indicators, MinMFE 20, and TradeMemory 15.

Now its time to drive up to Gainesville for the Gators Football Game.
GO GATORS!!!


Attached Files
Register to download File Type: zip XavGlassBoxX0v1.zip (8.7 KB, 10 views)
Visit my futures io Trade Journal Started this thread Reply With Quote


futures io Trading Community Platforms and Indicators NinjaTrader > Need Help Plotting the average of a queue


Last Updated on September 1, 2012


Upcoming Webinars and Events
 

NinjaTrader Indicator Challenge!

Ongoing

Your Charts Should Speak To You w/Bob Cometta

Elite only
 

Our 12-year anniversary w/ $$,$$$ prizes (check soon)

August
     



Copyright © 2021 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada), 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