How to make my strategy trade a percentage of account equity instead of fixed co

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #252652 quote
    SQUARED2
    Participant
    New

    Hi everyone,

    I’m trying to adjust my strategy so that it trades a percentage of my account equity instead of using a fixed number of contracts.

    Ideally, I’d like the strategy to automatically calculate position size based on my current equity — for example, allocate 2% of the account equity per trade. That way, the position size scales up as the account grows, and decreases after losses.

    Has anyone implemented this before in ProBuilder code?
    I’d really appreciate an example or some guidance on how to calculate and set the position size dynamically.

    Thanks a lot in advance!
    /Osca

    #252653 quote
    PeterSt
    Participant
    Master
    Hi Osca, It is not possible to obtain your portfolio amount by means of ProBuilder. It *is* of course possible to enter that amount yourself as a parameter to the program code. But you would need change the parameter in/to the code and  restart that strategy code  in ProOrder to let the latest value come through. In other words : what you functionally want is not possible.
    #252676 quote
    robertogozzi
    Moderator
    Master
    What PeterSt said is correct. But, since when you start a strategy you for sure KNOW how much of your balance is assigned to that strategy, simply code that value in your code and add to it the STRATEGYPROFIT, then you have to calculate thge risk for the trade and divide the result by the price to determine the number of contracts:
    ONCE myCapital    = 20000
    ONCE myRisk       = 2            //2%
    myEquity          = myCapital + StrategyProfit
    tempRisk          = myEquity * myRisk / 100
    LotSize           = tempRisk * 100 / close
    myLongConditions  = Not OnMarket AND close CROSSES OVER  average[20,0](close)
    myShortConditions = Not OnMarket AND close CROSSES UNDER average[20,0](close)
    IF myLongConditions THEN
       BUY LotSize Contracts at Market
    ELSIF myLongConditions THEN
       BUY LotSize Contracts at Market
    ENDIF
    SET STOP   %LOSS   0.5    //0.5%
    SET TARGET %PROFIT 1      //1%
    graph myEquity
    graph tempRisk
Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.

How to make my strategy trade a percentage of account equity instead of fixed co


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
SQUARED2 @squared2 Participant
Summary

This topic contains 2 replies,
has 3 voices, and was last updated by robertogozzi
4 months ago.

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