if (SystemPerformance.AllTrades.Count >1) { nzd_PL =0; aud_PL =0; audnzd_PL =0; eur_PL =0; cad_PL =0; foreach (Trade myTrade in SystemPerformance.AllTrades) { if(myTrade.Entry.Instrument.MasterInstrument.Name.Equals("NZDUSD")) nzd_PL+=myTrade.ProfitCurrency; if(myTrade.Entry.Instrument.MasterInstrument.Name.Equals("AUDUSD")) aud_PL+=myTrade.ProfitCurrency; if(myTrade.Entry.Instrument.MasterInstrument.Name.Equals("AUDNZD")) audnzd_PL+=myTrade.ProfitCurrency; if(myTrade.Entry.Instrument.MasterInstrument.Name.Equals("EURUSD")) eur_PL+=myTrade.ProfitCurrency; if(myTrade.Entry.Instrument.MasterInstrument.Name.Equals("USDCAD")) cad_PL+=myTrade.ProfitCurrency; } cum_tickerPL = nzd_PL+aud_PL+audnzd_PL+eur_PL+cad_PL; }
Announcement
Collapse
Looking for a User App or Add-On built by the NinjaTrader community?
Visit NinjaTrader EcoSystem and our free User App Share!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less
Partner 728x90
Collapse
NinjaTrader
Ranking
Collapse
X
-
Ranking
Code:Tags: None
-
Hello calhawk01,
Thanks for your post.
This is not a Ninjascript question but more of a processing question.
One idea would be to put the values in an array and then sort the array to provide the ranking. You can find array sorting info on the internet. Here is one reference: https://www.dotnetperls.com/array-sort
Another idea may be to use the totaled values as 100% and then take each input as x% and apply your funds in that manner. So if nzd_PL is 27.5% of cum_tickerPL then you could allocate 27.5% to nzd.Paul H.NinjaTrader Customer Service
-
Originally posted by NinjaTrader_Paul View PostHello calhawk01,
Thanks for your post.
This is not a Ninjascript question but more of a processing question.
One idea would be to put the values in an array and then sort the array to provide the ranking. You can find array sorting info on the internet. Here is one reference: https://www.dotnetperls.com/array-sort
Another idea may be to use the totaled values as 100% and then take each input as x% and apply your funds in that manner. So if nzd_PL is 27.5% of cum_tickerPL then you could allocate 27.5% to nzd.
rank1= 30%
rank2=20%
rank3=20%
rank4=20%
rank5=10%
So If i can specify rank1 and rank5, I can do their appropriate allocations, everything else can get 20%.
Code:if((nzd_PL> aud_PL &nzd_PL> audnzd_PL &nzd_PL> eur_PL &nzd_PL> cad_PL) (&aud_PL < audnzd_PL & aud_PL< eur_PL & aud_PL< cad_PL)) { //nzd_pl rank =1 //aud_pl rank =5 } if((aud_PL> nzd_PL &aud_PL> audnzd_PL &aud_PL> eur_PL &aud_PL> cad_PL) (&nzd_PL < audnzd_PL & nzd_PL< eur_PL & nzd_PL< cad_PL)) { //aud_pl rank =1 //nzd_pl rank =5 }
Comment
-
Originally posted by calhawk01 View PostPercentage allocation is a good idea but not practical. I'm going to be doing daily or weekly allocation. So for example, if nzd_PL for a given day had zero trades, and aud_PL had 10 trades and most of the PL (even if it was 1 cent) came from aud_PL, then aud_PL would get, for example, 90% of the allocation.. which isn't practical. I'm really concerned about the 1st and last rank and based on those I can do the following allocations:
rank1= 30%
rank2=20%
rank3=20%
rank4=20%
rank5=10%
So If i can specify rank1 and rank5, I can do their appropriate allocations, everything else can get 20%.
Code:if((nzd_PL> aud_PL &nzd_PL> audnzd_PL &nzd_PL> eur_PL &nzd_PL> cad_PL) (&aud_PL < audnzd_PL & aud_PL< eur_PL & aud_PL< cad_PL)) { //nzd_pl rank =1 //aud_pl rank =5 } if((aud_PL> nzd_PL &aud_PL> audnzd_PL &aud_PL> eur_PL &aud_PL> cad_PL) (&nzd_PL < audnzd_PL & nzd_PL< eur_PL & nzd_PL< cad_PL)) { //aud_pl rank =1 //nzd_pl rank =5 }
Code:#region nzdrank1 if((nzd_PL> aud_PL &nzd_PL> audnzd_PL &nzd_PL> eur_PL &nzd_PL> cad_PL) (&aud_PL < audnzd_PL & aud_PL< eur_PL & aud_PL< cad_PL)) { //nzd_pl rank =1 //aud_pl rank =5 } if((nzd_PL> aud_PL &nzd_PL> audnzd_PL &nzd_PL> eur_PL &nzd_PL> cad_PL) (&audnzd_PL < aud_PL & audnzd_PL< eur_PL & audnzd_PL< cad_PL)) { //nzd_pl rank =1 //audnzd_pl rank =5 } if((nzd_PL> aud_PL &nzd_PL> audnzd_PL &nzd_PL> eur_PL &nzd_PL> cad_PL) (&eur_PL < aud_PL & eur_PL< audnzd_PL & eur_PL< cad_PL)) { //nzd_pl rank =1 //eur_pl rank =5 } if((nzd_PL> aud_PL &nzd_PL> audnzd_PL &nzd_PL> eur_PL &nzd_PL> cad_PL) (&cad_PL < audnzd_PL & cad_PL< eur_PL & cad_PL< aud_PL)) { //nzd_pl rank =1 //cad_pl rank =5 } #endregion #region audrank1 if((aud_PL> nzd_PL &aud_PL> audnzd_PL &aud_PL> eur_PL &aud_PL> cad_PL) (&nzd_PL < audnzd_PL & nzd_PL < eur_PL & nzd_PL < cad_PL)) { //aud_pl rank =1 //nzd_pl rank =5 } if((aud_PL> nzd_PL &aud_PL> audnzd_PL &aud_PL> eur_PL &aud_PL> cad_PL) (&audnzd_PL < nzd_PL & audnzd_PL< eur_PL & audnzd_PL< cad_PL)) { //aud_pl rank =1 //audnzd_pl rank =5 } if((aud_PL> nzd_PL &aud_PL> audnzd_PL &aud_PL> eur_PL &aud_PL> cad_PL) (&eur_PL < nzd_PL & eur_PL< audnzd_PL & eur_PL< cad_PL)) { //aud_pl rank =1 //eur_pl rank =5 } if((aud_PL> nzd_PL &aud_PL> audnzd_PL &aud_PL> eur_PL &aud_PL> cad_PL) (&cad_PL < audnzd_PL & cad_PL< eur_PL & cad_PL< nzd_PL)) { //aud_pl rank =1 //cad_pl rank =5 } #endregion #region audnzdrank1 if((audnzd_PL> aud_PL &audnzd_PL> audnzd_PL &audnzd_PL> eur_PL &audnzd_PL> cad_PL) (&aud_PL < nzd_PL & aud_PL< eur_PL & aud_PL< cad_PL)) { //audnzd_pl rank =1 //aud_pl rank =5 } if((audnzd_PL> aud_PL &audnzd_PL> audnzd_PL &audnzd_PL> eur_PL &audnzd_PL> cad_PL) (&nzd_PL < aud_PL & nzd_PL< eur_PL & nzd_PL< cad_PL)) { //audnzd_pl rank =1 //audnzd_pl rank =5 } if((audnzd_PL> aud_PL &audnzd_PL> audnzd_PL &audnzd_PL> eur_PL &audnzd_PL> cad_PL) (&eur_PL< aud_PL & eur_PL< nzd_PL & eur_PL< cad_PL)) { //audnzd_pl rank =1 //eur_pl rank =5 } if((audnzd_PL> aud_PL &audnzd_PL> audnzd_PL &audnzd_PL> eur_PL &audnzd_PL> cad_PL) (&cad_PL < nzd_PL & cad_PL< eur_PL & cad_PL< aud_PL)) { //nzd_pl rank =1 //cad_pl rank =5 } #endregion #region eurrank1 if((eur_PL> aud_PL &eur_PL> audnzd_PL &eur_PL> nzd_PL &eur_PL> cad_PL) (&aud_PL < audnzd_PL & aud_PL< nzd_PL & aud_PL< cad_PL)) { //eur_pl rank =1 //aud_pl rank =5 } if((eur_PL> aud_PL &eur_PL> audnzd_PL &eur_PL> nzd_PL &eur_PL> cad_PL) (&audnzd_PL < aud_PL & audnzd_PL< nzd_PL & audnzd_PL< cad_PL)) { //eur_pl rank =1 //audnzd_pl rank =5 } if((eur_PL> aud_PL &eur_PL> audnzd_PL &eur_PL> nzd_PL &eur_PL> cad_PL) (&nzd_PL < aud_PL & nzd_PL< audnzd_PL & nzd_PL< cad_PL)) { //eur_pl rank =1 //nzd_pl rank =5 } if((eur_PL> aud_PL &eur_PL> audnzd_PL &eur_PL> nzd_PL &eur_PL> cad_PL) (&cad_PL < audnzd_PL & cad_PL< nzd_PL & cad_PL< aud_PL)) { //eur_pl rank =1 //cad_pl rank =5 } #endregion #region cadrank1 if((cad_PL> aud_PL &cad_PL> audnzd_PL &cad_PL> eur_PL &cad_PL> cad_PL) (&aud_PL < audnzd_PL & aud_PL< eur_PL & aud_PL< nzd_PL)) { //cad_pl rank =1 //aud_pl rank =5 } if((cad_PL> aud_PL &cad_PL> audnzd_PL &cad_PL> eur_PL &cad_PL> cad_PL) (&audnzd_PL < aud_PL & audnzd_PL< eur_PL & audnzd_PL< nzd_PL)) { //cad_pl rank =1 //audnzd_pl rank =5 } if((cad_PL> aud_PL &cad_PL> audnzd_PL &cad_PL> eur_PL &cad_PL> cad_PL) (&eur_PL < aud_PL & eur_PL< audnzd_PL & eur_PL< nzd_PL)) { //cad_pl rank =1 //eur_pl rank =5 } if((cad_PL> aud_PL &cad_PL> audnzd_PL &cad_PL> eur_PL &cad_PL> cad_PL) (&nzd_PL < audnzd_PL & nzd_PL< eur_PL & nzd_PL< aud_PL)) { //cad_pl rank =1 //nzd_pl rank =5 } #endregion
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by arvidvanstaey, Today, 02:19 PM
|
3 responses
8 views
0 likes
|
Last Post Today, 03:23 PM | ||
Started by jordanq2, Today, 03:10 PM
|
2 responses
7 views
0 likes
|
Last Post
by jordanq2
Today, 03:23 PM
|
||
Started by traderqz, Today, 12:06 AM
|
10 responses
18 views
0 likes
|
Last Post
by traderqz
Today, 02:49 PM
|
||
Started by algospoke, 04-17-2024, 06:40 PM
|
5 responses
47 views
0 likes
|
Last Post Today, 02:36 PM | ||
Started by mmckinnm, Today, 01:34 PM
|
3 responses
7 views
0 likes
|
Last Post Today, 02:12 PM |
Comment