NexusFi: Find Your Edge


Home Menu

 





Need Help Plotting the average of a queue


Discussion in NinjaTrader

Updated
    1. trending_up 1,948 views
    2. thumb_up 4 thanks given
    3. group 2 followers
    1. forum 5 posts
    2. attach_file 3 attachments




 
Search this Thread

Need Help Plotting the average of a queue

  #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

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
Elite Membership required to download: XavGlassBoxX0.zip
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
NexusFi Journal Challenge - May 2024
Feedback and Announcements
Better Renko Gaps
The Elite Circle
Trade idea based off three indicators.
Traders Hideout
Exit Strategy
NinjaTrader
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Spoo-nalysis ES e-mini futures S&P 500
48 thanks
Just another trading journal: PA, Wyckoff & Trends
35 thanks
Bigger Wins or Fewer Losses?
24 thanks
Tao te Trade: way of the WLD
24 thanks
GFIs1 1 DAX trade per day journal
22 thanks
  #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


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

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

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

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
Elite Membership required to download: XavGlassBoxX0v1.zip
Visit my NexusFi Trade Journal Started this thread Reply With Quote




Last Updated on September 1, 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