Position size relative to account size

Viewing 15 posts - 1 through 15 (of 16 total)
  • Author
    Posts
  • #232331 quote
    OMXet
    Participant
    Junior

    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😁

    #232335 quote
    OMXet
    Participant
    Junior

    PS: I meant if anyone on this forum can help me to code that I described above  ;>)

    #232336 quote
    PeterSt
    Participant
    Master

    That is not possible with PRT because the total account size (or gain in it) is not available to the program code. Sorry …

    #232337 quote
    GraHal
    Participant
    Master

    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.

    #232338 quote
    OMXet
    Participant
    Junior

    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

    #232339 quote
    PeterSt
    Participant
    Master

    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. 🙂

    #232340 quote
    GraHal
    Participant
    Master

    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! 😀

    #232341 quote
    JC_Bywan
    Moderator
    Master

    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

    #232342 quote
    GraHal
    Participant
    Master

    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.

    #232346 quote
    OMXet
    Participant
    Junior

    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.

    #232347 quote
    GraHal
    Participant
    Master

    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?

    #232348 quote
    OMXet
    Participant
    Junior

    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

    #232349 quote
    GraHal
    Participant
    Master

    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
    #232519 quote
    Niklas87
    Participant
    New

    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.

    #237734 quote
    pabo_swe
    Participant
    Junior

    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
Viewing 15 posts - 1 through 15 (of 16 total)
  • You must be logged in to reply to this topic.

Position size relative to account size


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
OMXet @omxet Participant
Summary

This topic contains 15 replies,
has 6 voices, and was last updated by pabo_swe
1 year, 5 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 05/05/2024
Status: Active
Attachments: No files
Logo Logo
Loading...