Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Multi Instrument Equally weighted optimization

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Multi Instrument Equally weighted optimization

    hello

    does anyone in the community/nt support have any thoughts on equally weighted optimization solutions for a strategy with 10 instruments that are long and short?

    problem I am facing is that when running the optimizer for a variable A; it ends up finding the best solution but most of the time this solution is the best for one or two or maybe three of the instruments, hence, net returns are great, but the other instruments have horrible returns, hence, my solution is not good enough.

    there are too many dynamics in the strategy and i want to find the best solution as a portfolio rather than one instrument so i can't run the optimizer on a single instrument by instrument.

    i've thought about:

    weighing the returns by long short for each instrument and then weighing the net returns from of the weighted long/short by each instrument for the portfolio.

    so:

    audusd_long =net profit
    audusd_short = net profit

    aud_long*.5 + aud_short*.5

    aud_usd portfolio weighted = 1/10; //1 instrument out of 10 instruments

    aud_usd portfolio weighted = (aud_long*.5)+(aud_short*.5)*1/10

    any thoughts? i still feel that even if I try the above, the optimizer will just keep finding the same solution as the initial solution.

    part of the problem is that the variable ends up giving too many long trades for a particular instrument and not enough short trades hence the net profits are not weighted properly in my opinion. i wish there was a optimization for a portfolio :/

    thank you in advance.

    this is what i've got so far;

    Code:
    			if (Bars.IsLastBarOfSession)
    		 	{
    			 aud_long		=0;
    			 nzd_long		=0;
    			 cad_long		=0;
    			 chf_long		=0;
    			 audjpy_long	=0;
    			 eurjpy_long	=0;
    			 jpy_long		=0;
    			 
    		      foreach (Trade myTradea in SystemPerformance.LongTrades)
    		      {
    				  if(myTradea.Entry.Instrument.MasterInstrument.Name.Equals("AUDUSD"))
    				   aud_long+=myTradea.ProfitCurrency;		
    				  if(myTradea.Entry.Instrument.MasterInstrument.Name.Equals("NZDUSD"))
    				 	 nzd_long+=myTradea.ProfitCurrency;	
    				  if(myTradea.Entry.Instrument.MasterInstrument.Name.Equals("USDCAD"))
    				   cad_long+=myTradea.ProfitCurrency;			  
    				  if(myTradea.Entry.Instrument.MasterInstrument.Name.Equals("AUDJPY"))
    				 	 audjpy_long+=myTradea.ProfitCurrency;	
    				  if(myTradea.Entry.Instrument.MasterInstrument.Name.Equals("USDCHF"))
    				   chf_long+=myTradea.ProfitCurrency;			  
    				  if(myTradea.Entry.Instrument.MasterInstrument.Name.Equals("EURJPY"))
    				 	 eurjpy_long+=myTradea.ProfitCurrency;	
    				  if(myTradea.Entry.Instrument.MasterInstrument.Name.Equals("USDJPY"))
    				 	 jpy_long+=myTradea.ProfitCurrency;	
    			  }
    			}
    			
    			if (Bars.IsLastBarOfSession)
    		 	{
    			 aud_short		=0;
    			 nzd_short		=0;
    			 cad_short		=0;
    			 chf_short		=0;
    			 audjpy_short	=0;
    			 eurjpy_short	=0;
    			 jpy_short		=0;
    			 
    		      foreach (Trade myTrade_a in SystemPerformance.ShortTrades)
    		      {
    				  if(myTrade_a.Entry.Instrument.MasterInstrument.Name.Equals("AUDUSD"))
    				   aud_long+=myTrade_a.ProfitCurrency;		
    				  if(myTrade_a.Entry.Instrument.MasterInstrument.Name.Equals("NZDUSD"))
    				 	 nzd_long+=myTrade_a.ProfitCurrency;	
    				  if(myTrade_a.Entry.Instrument.MasterInstrument.Name.Equals("USDCAD"))
    				   cad_long+=myTrade_a.ProfitCurrency;			  
    				  if(myTrade_a.Entry.Instrument.MasterInstrument.Name.Equals("AUDJPY"))
    				 	 audjpy_long+=myTrade_a.ProfitCurrency;	
    				  if(myTrade_a.Entry.Instrument.MasterInstrument.Name.Equals("USDCHF"))
    				   chf_long+=myTrade_a.ProfitCurrency;			  
    				  if(myTrade_a.Entry.Instrument.MasterInstrument.Name.Equals("EURJPY"))
    				 	 eurjpy_long+=myTrade_a.ProfitCurrency;	
    				  if(myTrade_a.Entry.Instrument.MasterInstrument.Name.Equals("USDJPY"))
    				 	 jpy_long+=myTrade_a.ProfitCurrency;	
    			  }
    			}
    			
    			weighted_net = 
    				(((aud_long*.5)+(aud_short*.5))*(1/7))
    				+(((nzd_long*.5)+(nzd_short*.5))*(1/7))
    				+(((cad_long*.5)+(cad_short*.5))*(1/7))
    				+(((chf_long*.5)+(chf_short*.5))*(1/7))
    				+(((jpy_long*.5)+(jpy_short*.5))*(1/7))
    				+(((audjpy_long*.5)+(audjpy_short*.5))*(1/7))
    				+(((eurjpy_long*.5)+(eurjpy_short*.5))*(1/7));
    Last edited by staycool3_a; 10-02-2018, 02:31 AM.

    #2
    Hello staycool3_a,

    Thanks for your post.

    You may perform your own calculations to measure weighted returns. Your proposal sounds like it could be used in practice. As far as making use of this information, I may suggest looking into making an Optimization Fitness Metric so you can present a particular weighted value and use that when running basket optimizations.

    Optimization Fitness Metric documentation can be found below. Source code for our Optimization Fitness Metrics can be referenced in the NinjaScript Editor as well.

    Optimization Fitness Metrics - https://ninjatrader.com/support/help...on_fitness.htm

    I could not give further input or advise for developing a solution for your needs and I will leave this thread open for any community members to share their input.

    If you have another inquiry surrounding the NinjaTrader platform or NinjaScript, please feel free to open a new thread.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by NullPointStrategies, Yesterday, 05:17 AM
    0 responses
    61 views
    0 likes
    Last Post NullPointStrategies  
    Started by argusthome, 03-08-2026, 10:06 AM
    0 responses
    134 views
    0 likes
    Last Post argusthome  
    Started by NabilKhattabi, 03-06-2026, 11:18 AM
    0 responses
    75 views
    0 likes
    Last Post NabilKhattabi  
    Started by Deep42, 03-06-2026, 12:28 AM
    0 responses
    45 views
    0 likes
    Last Post Deep42
    by Deep42
     
    Started by TheRealMorford, 03-05-2026, 06:15 PM
    0 responses
    50 views
    0 likes
    Last Post TheRealMorford  
    Working...
    X