Money managment
Forums › ProRealTime English forum › ProBuilder support › Money managment
- This topic has 4 replies, 2 voices, and was last updated 5 years ago by Vonasi.
-
-
09/04/2019 at 5:37 PM #106518
Hi i was wondering how to create a code for money managment.
Eksample: you start with 500$ with one lot size. When money doubles it will double the lot size to 2 and then when you double again it will add 4 lot sizes.
It would be nice to have on the autotrading so i dont need to stop it to adjust my position.
Thanks for the help 🙂 Stay green
09/04/2019 at 6:53 PM #106521123456789101112131415161718capital = 500equity = capital + strategyprofitonce lastchange = capitalonce positionsize = 1if equity > lastchange * 2 thenpositionsize = positionsize * 2lastchange = lastchange * 2elseif equity < lastchange / 2 thenpositionsize = max(1,positionsize / 2)lastchange = lastchange / 2endifendifif (your conditions) thenbuy positionsize contracts at marketendifNot tested. This code also reduces the size if you lose. Delete lines 9 to 13 if you don’t want to do that.
1 user thanked author for this post.
09/04/2019 at 7:12 PM #106527Thanks i will try it out. Just one quick question. If im adding this to a strategy what do i den add in the (your conditions)?
Im not a good programer 🙁
09/04/2019 at 8:19 PM #106528A slightly better way to do it in my mind is like this:
12capital = 500positionsize = max(1,1 +(round((strategyprofit/capital)-0.5)))This does not double the position size but increments or decrements it by 1 for every 500 won or lost by a strategy down to a minimum stake size of 1.
1 user thanked author for this post.
09/05/2019 at 9:22 AM #106558If im adding this to a strategy what do i den add in the (your conditions)?
Where ever you like above or below the money management code as long as it is below any DEFPARAM line.
I had a chance to test my first example and there is a minor issue that if your strategy profit jumps from 500 to 1500 then you will have to wait for two bars before the position size is doubled twice. This might not be an issue on a strategy that makes small wins but on a long term buy and hold strategy that takes big profits or big losses then it might be.
1 user thanked author for this post.
-
AuthorPosts