Money management & control risk
Forums › ProRealTime English forum › ProOrder support › Money management & control risk
- This topic has 23 replies, 4 voices, and was last updated 5 years ago by Vonasi.
Tagged: Kelly’s optimal F, money management
-
-
08/20/2019 at 4:24 PM #105117
I found this EasyLanguage calculator of F in the September 26 2018 post of this blog:
http://georgepruitt.com/category/easylanguage/must-know/
I know nothing of EasyLanguage coding but I see that it uses arrays which may make conversion to PRT either impossible or very difficult.
Perhaps Nicolas could comment on whether it could be converted?
Note: DO NOT try to use the code posted here in PRT as it is – it is EasyLanguage code!
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071//OptimalFGeo by George Pruitt//My interpretation Sept. 2018//www.georgepruitt.com//georgeppruitt@gmail.cominput: minNumTrades(numericSimple);vars: totalTradesCount(0),tradeCnt(0);array: tradesArray[500](0);vars: iCnt(00),jCnt(00),grandTot(0),highI(0);vars: optF(0.0),gMean(0.0),fVal(0.0),HPR(0.0),TWR(0.0),hiTWR(0.0);vars: biggestLoser(0.0),gat(0.0);totalTradesCount = totalTrades;If totalTradesCount > totalTradesCount[1] thenbegintradeCnt = tradeCnt + 1;tradesArray[tradeCnt] = positionProfit(1);end;// Taken from my Fortran library - GPP and Vince Book PMFoptF = 0.0;gMean = 1.00;gat = 0.00;//Only calculate if new tradeIF(tradeCnt>minNumTrades and totalTradesCount > totalTradesCount[1]) thenBeginbiggestLoser = 0;grandTot = 0;For iCnt = 1 to tradeCnt //get the biggest loserbegingrandTot = grandTot + tradesArray[iCnt];IF(tradesArray[iCnt]<biggestLoser) then biggestLoser = tradesArray[iCnt];end;// print(grandTot," ",biggestLoser);IF({grandTot > 0 and} biggestLoser <0) thenbegin// print("Inside TWR Calculations");highI = 0;hiTWR = 0.0;for iCnt = 1 to 100beginfVal = .01 * iCnt;TWR = 1.0;for jCnt = 1 to tradeCnt // calculate the Terminal Wealth RelativebeginHPR = 1. + (fVal * (-1*tradesArray[jCnt]) / biggestLoser);TWR = TWR * HPR;// print(fVal," ",iCnt," " ,jCnt," Trades ",tradesArray[jCnt]," HPR ",HPR:6:4," TWR : ",TWR:6:4," hiTWR",hiTWR:6:4," bl ",biggestLoser);end;// print(iCnt," ",TWR," ",hiTWR);IF(TWR>hiTWR) THENbeginhiTWR = TWR;optF = fVal; // assign optF to fVal in case its the correct oneendelsebreak; //highest f found - stop loopingend;If (TWR <= hiTWR or optF >= 0.999999) thenbeginTWR = hiTWR;OptimalFGeo = optF; //assign optF to the name of the functionend;gmean = power(TWR,(1.0 / tradeCnt));if(optF<>0) then GAT = (gMean - 1.0) * (biggestLoser / -(optF));print(d," gmean ",gmean:6:4," ",GAT:6:4); // I calculate the GMEAN and GeoAvgTradeend;end;08/23/2019 at 1:31 PM #105384This is a rough version, it makes the computation but i used a positionprofit in percentage instead of real money.. so I assume the result is not really the one that we need. The problem is to know the position profit in money by using positionperf at a time when we don’t know what was the Close value used to calculate it.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566defparam cumulateorders=false// --- settingsminNumTrades = 10// --- end of settings//dummy strategyirsi = rsi[14]if irsi crosses over 50 thenbuy at markettradeCnt = tradeCnt+1endifset target pprofit 20set stop ploss 10//optF = 0.0gMean = 1.00gat = 0.00IF(tradeCnt>minNumTrades and tradeCnt<>tradeCnt[1]) thenbiggestLoser = 0grandTot = 0For iCnt = 1 to tradeCnt do //get the biggest losergrandTot = grandTot + positionperf(iCnt)IF(positionperf(iCnt)<biggestLoser) thenbiggestLoser = positionperf(iCnt)endifnextIF(grandTot > 0 and biggestLoser <0) then//highI = 0hiTWR = 0.0for iCnt = 1 to 100 dofVal = .01 * iCntTWR = 1.0for jCnt = 1 to tradeCnt do // calculate the Terminal Wealth RelativeHPR = 1.0 + (fVal * (-1*positionperf(jCnt) / biggestLoser))TWR = TWR * HPRIF(TWR>hiTWR) THENhiTWR = TWRoptF = fVal // assign optF to fVal in case its the correct oneelsebreakendifnextnext //highest f found - stop loopingIf (TWR <= hiTWR or optF >= 0.999999) thenTWR = hiTWROptimalFGeo = optF //assign optF to the name of the functionendif//gmean = power(TWR,(1.0 / tradeCnt))//y = x^p = e^(p*LN(x))//This could then be coded as: y = EXP(p*LOG(x)) This works fine.gmean = exp((1.0/tradeCnt)*log(TWR))if(optF<>0) thenGAT = (gMean - 1.0) * (biggestLoser / -(optF))//print(d," gmean ",gmean:6:4," ",GAT:6:4); // I calculate the GMEAN and GeoAvgTradeendifendifendifgraph gatgraph OptimalFGeo//graph tradeCnt//graph positionperf1 user thanked author for this post.
08/23/2019 at 3:26 PM #10540008/24/2019 at 5:30 PM #105454No, I can’t … the code is yet to be completed.
A few days ago I asked how to enter Kelly’s F or Kelly’s Secure F as money management in the code and I still haven’t got an answer.
In addition, I want to get a couple of things for the code:
- For each successful operation add 10% more risk than in the previous operation for the next operation, and for each failed operation remove 10% less risk than in the previous operation.
- If the total benefit of the system is for example between € 10,000 or € 12,000, operate with € 5 / pip. If the total benefit of the system falls, and is between € 8,000 or € 10,000 operate with € 4 / pip. But if then the total benefit of the system is once again between € 8,000 or € 10,000, then re-operate with € 5 / pip. With these ideas the code would be complete and could upload it.
08/24/2019 at 5:39 PM #105456do NOT use Insert PRT code for TEXT, it doesn’t work!
In you last request did you refer to the current discussion or to Kelly’s Secure F?
08/24/2019 at 7:47 PM #10546512345678<span lang="en" tabindex="0">Let's see, all I say is that the code is unfinished and I need help.Also in September I will have 200k of backtest and I will have to update it very probably.Until then it is nonsense to upload a half-programmed code.I don't force anyone to "work for me" ... I've only asked for help just like others like me do.Im referred F of Kelly and actually discusión.</span>08/24/2019 at 9:22 PM #105468do NOT use Insert PRT code for TEXT, it doesn’t work!
08/24/2019 at 9:27 PM #105471- don’t mix post from different topics
- try not to urge help, IF someone is able AND willing to answer… he will, provided you have posted all details and answered any question may have been asked
urging people to work for you when you want them to… does not work as intended!
08/24/2019 at 10:17 PM #105479sdesergio – no one is working here. No one is employed or paid by anyone else to provide free coding solutions to anyone else. This is a forum set up by someone who is not employed by PRT just to provide a community for those who use PRT. It is moderated by volunteers.
The Optimal F calculation that you request has been discussed in the past and no one was able to provide the code then. We are now a tiny step closer thanks to the Easylanguage code that I found and thanks to Nicolas’s conversion of it- all this despite a lack of actual information on how exactly Optimal F is calculated from yourself or from any sources found by anyone else and yet you are complaining that no one has provided you with an answer. Then you throw in a whole bunch of new demands on top!
As moderators we have had to constantly remind you of basic forum etiquette and to tidy up your posts after you and as volunteers giving our time for free we would appreciate it if you took up slightly less of our time doing this.
At the moment your posts are likely to get you less help rather than more help. 🙂
-
AuthorPosts
Find exclusive trading pro-tools on