Moneymangement again
Calculating the position size
My account is 3.2% in the minus of 100% (100% = 10.000 Euro).
There is only 1 trading system running.
Position size = 1.
TP of the trading system is 2%.
Tradingsystem example
If close > highest [20] then
buy at market
Endif
set target %profit 2
How do I calculate the position size so that when the trade runs in the TP my account grows to 101%,
You will have to make these calculations:
- A = initial Capital (10000 in this case,which is 100%)
- B = current Capital which is 9580 (10000 – 3.2%)
- C = current target profit with 1 lot (2% of the entry price)
- D = A+1% – B (which is the target profit to reach A + 1%, i.e. 10100)
- LotSize = D / C
If your entry price is, say, 16000, the above calculations will be:
- A = 10000
- B = 9580
- C = 320 (2% target profit, with 1 lot)
- D = 420 (A+1% – B)
- LotSize = 420 / 320 which yields 1.3125 lots (you may round it)
So, if you BUY 1.3125 lots at 16000 and your planned Target Profit is reached, your current Capital at that time will be 10100 (the initial Capital + 1%).
Only post in the language of the forum that you are posting in. For example English only in the English speaking forums and French only in the French speaking forums. Thank you 🙂
I moved it from the German forum.
Also a thanks for the reminder with the wrong forum. It happened me too from time to time that I ended up in the wrong forum. I try very hard to keep it, sometimes it still does not work. I am sorry for that.
First a very big thank you for doing this for me. For me, it will be a difficult ride to squeeze the calculation into the PRT code. I would like to be allowed to put it in here and you look over it again that fits? Will take 1,2 weeks, maybe more. I would like to come back to you.
Ok, take your time, I will read and test your code when available.
Hello Roberto.
Here I am back and I would like to use your help again.
I have created the code as below. I think it could work like this, but please, can you check once or twice if the code is correct?
defparam cumulateorders= false
once lotsize = 1
once capital = 10000 // A
actualCapital = capital + strategyprofit // B
tpTrade = close/100 * 0.2 // C
tpCapital = (capital + capital*0.01) - actualCapital // D
lotsize = round(tpCapital/tpTrade,2) // lotsize
If longcond then
IF actualcapital < capital then
buy lotsize contracts at market
elsif actualCapital >= capital then
buy 1 contract at market
endif
Endif
set target profit tpTrade
I changed the code a little bit, adding the variable named maxcapital and the Stop Loss, then I moved boith SL and TP inside the IF…ENDIF block. I also made the calculation of C, D and lotsize only when Not OnM arket.
This code seems to be working fine:
defparam cumulateorders= false
once lotsize = 1
once capital = 10000 // A
actualCapital = capital + strategyprofit // B
maxcapital = max(capital,actualcapital)
IF Not OnMarket THEN
tpTrade = close/100 * 0.2 // C
tpCapital = (maxcapital + maxcapital*0.01) - actualCapital // D
lotsize = round(tpCapital/tpTrade,2) // lotsize
ENDIF
longcond = Not Onmarket AND average[10] CROSSES OVER average[20]
If longcond then
IF actualcapital < maxcapital then
buy lotsize contracts at market
elsif actualCapital >= maxcapital then
buy 1 contract at market
endif
set target profit tpTrade
set stop loss tpTrade
Endif
graph tpCapital coloured("Green")
graph tpTrade coloured("Red")
Hello Roberto.
I see we have the same thing here as here.
I suggest we merge the discussion and continue here.
Capital curve as an indicator?
I have tested your code above. It does not work properly. I am sorry. The maxcapital curve cannot point downwards, the highest capital ever reached cannot decrease as it is always the highest ever reached.
If I test your code and bring in “graph maxcapital”, you can see that maxcapital is decreasing, and is not in the spirit of the thing
defparam cumulateorders= false
once lotsize = 1
once capital = 10000 // A
actualCapital = capital + strategyprofit // B
maxcapital = max(capital,actualcapital)
IF Not OnMarket THEN
tpTrade = close/100 * 0.2 // C
tpCapital = (maxcapital + maxcapital*0.01) - actualCapital // D
lotsize = round(tpCapital/tpTrade,2) // lotsize
ENDIF
longcond = Not Onmarket AND average[10] CROSSES OVER average[20]
If longcond then
IF actualcapital < maxcapital then
buy lotsize contracts at market
elsif actualCapital >= maxcapital then
buy 1 contract at market
endif
set target profit tpTrade
set stop loss tpTrade
Endif
//graph tpCapital coloured("Green")
//graph tpTrade coloured("Red")
graph maxcapital