Hi you all good programers.
I want to buy n contracts that will require x % of my account in security.
As every trade will change my account up/down then I still want next trade to require X % of that new account size as security.
By doing this I hopefully get my account growing even faster😁
PS: I meant if anyone on this forum can help me to code that I described above ;>)
That is not possible with PRT because the total account size (or gain in it) is not available to the program code. Sorry …
buy n contracts that will require x % of my account
Could work if use xamount allocated to any particular Algo then use strategyprofit (after each trade) to increase or decrease this xamount accordingly.
Hi
I’ve got this far but I want to take it a step further but I need some help!!
STARTINGCAPITAL = 1000 //1k €
SIZE = 1 / STARTINGCAPITAL //divide your initial contract size by startingcapital
CAPITAL = STARTINGCAPITAL + STRATEGYPROFIT //current capital
K = CAPITAL * SIZE //calculate position size
positionsize=K
Could work if use xamount allocated to any particular Algo then use strategyprofit (after each trade) to increase or decrease this xamount accordingly.
Plus a lot of coffee to restart each of those algos at the moment it finishes a trade, put the new total accumulated value in that xamount variable and …
Can’t work.
Better buy and sell coffee and have it too ? … that also can’t work. 🙂
There are codes on here that do what I suggest … no stopping of Algo required.
A coding wizard may be along shortly as I’m off out to play tennis, but also low on coffee! 😀
Hi,
Assuming you’re not trying to find a way around getting access to other codes gains/losses to include in contracts size calculation (can’t see any to this day), then when using only gains/losses of considered code, maybe Roberto’s lines 1-16 in following post might be what you’re after?
Réinvestissement des gains
Anyway what Instrument are you trading OMXet?
All my codes buy x Contracts not a cash amount so surely you need, for example, 0.2 £1 Contracts on DJI = £8K.
Or do you want code working at required margin cost (not full contract price)?
Few things to think about before a kind helpful coder spots this thread.
Hi
I trade NASDAQ Tech100.
My intention was to trade each trade at a level X contracts that will require 50% of my account for security. That will generate a nice leverage. I have done that manually this year and it has really worked nice ;>))) As some days I hit 0.5% movement then it generats 5 % to my account!
All of your answers are of interest but somehow I feel you don’t quite understand what I mean. Or maybe I’m just not good enough for programming = I’ll have to stick to the manuel trading.
Is it corect to say that you autotrade using 1 System / Algo only and therefore your Acount balance does not to be split across > 1 Algo?
Hi GraHal
Yep, my mistake. I obviously took that for granted. I have two accounts at IG, one for autotrading/only 1 algo, and the second for manual trading.
BTW: This year algo going down and manuel +xxx% ;>))….e.i. much work/time spent but rewarding
A few more thoughts …
Capital = 10000
Equity = Capital/2 + StrategyProfit // 5000+500 for example
Positionsize = Max(1,Equity/(Capital/2)) // so 'next' positionsize = max(1,5500/5000 = 1.1
Ther is no way to use you total account, but you can use the command stratergyprofit so incresee your positions. I made a code for just this some time ago 🙂
IF STRATEGYPROFIT[1] < 100 THEN
XX = 10
ELSE
XX = ROUND(STRATEGYPROFIT[1] / 100)
ENDIF
IF XX < 10 THEN
XX = 10
ENDIF
XX is number off contract and 100 is the amount off profit needed before it adds to XX, and do so by devide the total profit and round it to closes even number.
I trade on IG markets and in this case 100$ is just over the margin i need for 1 contract.
A while back I wanted a MM method that was more risk based, and if you ask me I ended up with this smart little script 😉
The thesis was that I only wanted to risk 1% of portfolio per trade, (if account is not too small and minimum trading size makes the risk higher). So based on my StopLoss, the script decide position size…
and when position size is bigger than 10 contract, I stick to full contracts.
enjoy!
// STRATEGY SETTINGS
MMactivate = 1
MMstartCapital = 3000 // Account size in asset currency, during start of algo
MMriskPercent = 2.0
MMminPosSize = 1
mySL = 0.360 // in percent
// MONEY MANAGEMENT
IF MMactivate THEN
positionSizeMM = ((MMriskPercent / 100) * (MMstartCapital + strategyProfit)) / (MySL/100*close) / pointsize
IF positionSizeMM < MMminPosSize THEN
positionSizeMM = MMminPosSize
ENDIF
IF positionSizeMM > 10 THEN
positionSize = ROUND(positionSizeMM,0)
ELSE
positionSize = ROUND(positionSizeMM,1)
ENDIF
ENDIF