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!
See more
See less

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.
    JimNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by DavidHP, Today, 07:56 AM
    0 responses
    0 views
    0 likes
    Last Post DavidHP
    by DavidHP
     
    Started by Aviram Y, 08-09-2023, 09:04 AM
    10 responses
    298 views
    0 likes
    Last Post MrHump
    by MrHump
     
    Started by jpapa, Today, 07:22 AM
    1 response
    5 views
    0 likes
    Last Post NinjaTrader_Gaby  
    Started by kevinenergy, 02-17-2023, 12:42 PM
    116 responses
    2,758 views
    1 like
    Last Post kevinenergy  
    Started by franatas, 12-04-2023, 03:43 AM
    7 responses
    106 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Working...
    X