Compounding interest – increase position size automatically
Forums › ProRealTime English forum › ProOrder support › Compounding interest – increase position size automatically
- This topic has 8 replies, 4 voices, and was last updated 5 years ago by Leo.
-
-
05/06/2018 at 1:50 PM #69891
Everyone sooner or later everyone get in touch with the “holy grail” of trading, the compound interest.
Far from a philosophical discussion, I would like to share and discuss available codes in PRT to develope it in automatic trading.
At the moment I only know this:
1234n= 1+(ROUND((strategyprofit)/2500)) //every 2500 add a contract//wherebuy n contracts at marketIs it possible to make a percentage version? When equity reaches 3% profit it adds n contracts? Do you know other alternatives?
05/06/2018 at 3:17 PM #69892First you have to set up your initial equity and number of lots, later, when NOT OnMarket check if strategyprofit is > 3% of your equity and act accordingly:
12345678ONCE MyEquity = 10000ONCE nLots = 1IF Not OnMarket THENIF Strategyprofit >= (MyEquiti * 1.03) THENMyEquity = StrategyprofitnLots = nLots + 1ENDIFENDIFYou must be aware that after increasing 3%, your equity could fall by 5% and you might want to decrease the number of lots you are trading.
1 user thanked author for this post.
05/06/2018 at 5:43 PM #6990105/06/2018 at 11:26 PM #69905There you go
123456789101112ONCE MyEquity = 10000ONCE nLots = 1IF Not OnMarket THENIF Strategyprofit >= (MyEquity * 1.03) THENMyEquity = StrategyprofitnLots = nLots + 1ELSIF Strategyprofit <= (MyEquity * 0.97) THENMyEquity = StrategyprofitnLots = nLots - 1nLots = max(1, nLots) //do not allow nLots to fall below 1ENDIFENDIF1 user thanked author for this post.
05/07/2018 at 9:35 AM #69913Above added to
Thank You Roberto
1 user thanked author for this post.
05/07/2018 at 5:45 PM #69954I use this
123456// RISK CONTROL IF THINGS ARE GOING WONDERFULLn = 1 + (strategyprofit / (17*pipvalue))n=SQRT(n)n = round(n * 100)n = n / 100n = max(1,n)When the code wins 17*4=68 pips then it duplicate the size of lot.
1 user thanked author for this post.
05/07/2018 at 7:09 PM #69963Above added to
I can’t see where the *4 comes from, but maybe I need to think about it more do I? 🙂
05/07/2018 at 7:47 PM #69968I tried to figure out what 4 stands for, as well, since I’m not a fan of maths.
I guess it has to do with the square root. If you are trading 4 contracts and want to double that number, if you take the square root if, which is two, then you’ll have to multiply it by 4 to get the correct number. Maybe GRAPH (or Leo) could help!
1 user thanked author for this post.
05/08/2018 at 7:34 AM #69981Hi all,
welll actually is not a 4, haha sorry.
Look, the code is based in the strategy profit. Therefore I do not want something linear because when it wins the next trade is quite high. Which I choose and works well is the root fuction. Normally a trade quite small amount and very short period of times.
Lets say, in this example (with strategyprift/17), when the code wins 17 pips then the next trade is 1+17/7=2 then root of 2 is 1.41… the next trade opens 1.41 lots
next trade win another 17 pips, then 1+34/17=3, root of 3 equal 1.73. Next trade will open with 1.73 lots
next trade win another 17 pips, it means that the strategy profit is 3 times 17 so, 1+51/17=4, root of 4 is 2 then
when the strategy is 3 times the 17 then it opens 2 lots.
in summary if the initial n=1 and you want to duplicate the number of lot after certain number of pips winning, then take the number of pips you desire divided by 3 and remplace the 17 in the code. For example. My initial lot is 1, after 100 winning pips I want to duplicate the number of lot by 2 then, the fist line of the code will be
N=1+(strategyprofit/(33*pipvalue))
hope I clarify the code.
2 users thanked author for this post.
-
AuthorPosts