Need Help Plotting the average of a queue - futures io

# Need Help Plotting the average of a queue

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)

# Need Help Plotting the average of a queue

Xav1029
Tampa, FL

Experience: Beginner
Broker: Mirus Futures/Zen-Fire

Posts: 1,375 since Dec 2011

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

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 OHLEmini 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 MetastockPlatforms and Indicators

in the last 7 days on futures io
 Webinar: Happy Hour w/Cem Karsan35 thanks Avoiding Account Killing Freight Trains26 thanks QG mini Natural Gas ( Position size ) calculation19 thanks The Beast Slayer, Lances NQ Trading Journal15 thanks Want your NinjaTrader indicator created, free?13 thanks

gregid
Wrocław, Poland

Experience: Intermediate

Posts: 651 since Aug 2009

@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 }```

 The following 2 users say Thank You to gregid for this post:

 (login for full post details) #4 (permalink) Xav1029  Elite Member Tampa, FL   Experience: Beginner Platform: NinjaTrader, Sierra Chart Broker: Mirus Futures/Zen-Fire Trading: 6E, M6E, 6J     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

gregid
Wrocław, Poland

Experience: Intermediate

Posts: 651 since Aug 2009

@Xav1029

ToList is an extension method of IEnumerable and since Queue:

Code
 ``` ``` public class Queue : IEnumerable, ICollection, IEnumerable  ``` ```
You are able to use extension method of IEnumerables for the Queue as well

 The following 2 users say Thank You to gregid for this post:

Xav1029
Tampa, FL

Experience: Beginner
Broker: Mirus Futures/Zen-Fire

Posts: 1,375 since Dec 2011

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

 futures io > Need Help Plotting the average of a queue

Last Updated on September 1, 2012

Upcoming Webinars and Events

Ongoing

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