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
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Ranking
Collapse
X
-
Ranking
How can I rank nzd_pl,aud_pl etc. In other words, if nzd_PL is the highest value in comparison to others, I'd like to give it rank 1 and if aud_PL is the lowest value, I'd like to give it rank of 5. This way, I can allocate funds to the best performing strategy and allocate the least amount to the underperforming strategy.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.
-
Percentage 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: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%.
maybe I have to do something like above, but the problem with that is that there are so many combinations that i'd have to include in the code and that would cause the length of the code to get big. I have no idea how to do arrays etc.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
-
The most inefficient code ever writtenOriginally 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%.
maybe I have to do something like above, but the problem with that is that there are so many combinations that i'd have to include in the code and that would cause the length of the code to get big. I have no idea how to do arrays etc.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 }
Basically I made ranking for the 1st and last stop for each one of the instruments. Just posting it, in the case someone else needs to use it. Besides, hoping someone feels bad for me and posts a more efficient codeCode:#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 NullPointStrategies, Yesterday, 05:17 AM
|
0 responses
59 views
0 likes
|
Last Post
|
||
|
Started by argusthome, 03-08-2026, 10:06 AM
|
0 responses
133 views
0 likes
|
Last Post
by argusthome
03-08-2026, 10:06 AM
|
||
|
Started by NabilKhattabi, 03-06-2026, 11:18 AM
|
0 responses
73 views
0 likes
|
Last Post
|
||
|
Started by Deep42, 03-06-2026, 12:28 AM
|
0 responses
45 views
0 likes
|
Last Post
by Deep42
03-06-2026, 12:28 AM
|
||
|
Started by TheRealMorford, 03-05-2026, 06:15 PM
|
0 responses
50 views
0 likes
|
Last Post
|

Comment