NexusFi: Find Your Edge


Home Menu

 





Kelly criterion on Portfolio!


Discussion in MultiCharts

Updated
    1. trending_up 1,934 views
    2. thumb_up 0 thanks given
    3. group 1 followers
    1. forum 0 posts
    2. attach_file 0 attachments




 
Search this Thread

Kelly criterion on Portfolio!

  #1 (permalink)
 Gabriel123 
Stockholm
 
Experience: Intermediate
Platform: ProRealTime
Trading: DAX
Posts: 40 since Jul 2015
Thanks Given: 6
Thanks Received: 5

Hi!

I have the code below for Kelly criterion position sizing. However I want to use Kelly criterion for a portfolio, not for a single instrument. When using this code on the instruments in a portfolio the Kelly criterion sizing is counted for, for every instrument separately.

Meaning, if the latest trades on AAPL har been doing great, the position size on that might be 10000 stocks, while the portfolios next trade in, let's say, MCD only takes 500 stocks since the latest trades in that instrument have been loosers.

How do I change this code to make it treat the whole portfolio as a instrument - meaning that it takes bigger position size after winning trades regardless of which instruments they were made on?

Is it necessary to add a money management code?

This is my code:

 
Code
                            
InputsInitialCapital100000 ), Margincapital5000 ), KellyPercent.45 {Half-Kelly}); 
  
Vars:   TradeSize), Equity), GL), GP), NWT), TT), 
        
ProfitFactor), WTP), KellyCriterion), Kelly);

var: 
ATR(0);
ATR AvgTrueRange(10);

Equity    Round((InitialCapital NetProfit OpenPositionProfit),0);//Equity

//Kelly Criterion Variables
GL        Average(Absvalue(Grossloss),30);     
GP        Average(Grossprofit,30);
NWT     Numwintrades;
TT      Totaltrades;
 
//Kelly Criterion Calculation
If GL <> 0 then  
ProfitFactor   
GP/GL;
If 
TT <> 0 then 
WTP 
= (NWT TT); 
If 
ProfitFactor <> 0 then 
KellyCriterion 
WTP - ((WTP)/(ProfitFactor));
Kelly = (KellyCriterion KellyPercent) * Equity
If 
Margincapital <> 0 then 
TradeSize 
Kelly /  Margincapital;
TradeSize MaxList(1Round(TradeSize,0));

//RSI Strategy - Buy
If Marketposition 0 then 
begin
    
    
If RSI(c,2) < and Average(C,200then 
    
    begin
            
    buy 
(TradeSize*50000/Cshares next bar at L limit;    
    
Value1 TradeSize*50000/C;
    
    
end
     
end;   

//RSI Strategy - Sell 
If Marketposition 1 then 
begin
    
    
If RSI(c,2) > 70 then
    
    begin
    
    sell value1 shares next bar at market
;
    
Value1 0;    

    
end;
    
end;
    
if 
TradeSize 0 then TradeSize 0

Started this thread Reply With Quote




Last Updated on August 5, 2016


© 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