Define position size as percentage of account

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #131990 quote
    badar80
    Participant
    New

    Hi all,

    I was wondering how to define my contract size to be 0.5 % of my account size, for example my stop loss I’d like to keep defined at 100 pips and then the contract size would be defined as a function of account size and pip value.
    I found the “% max risk exposure” in the ProBacktest manual, but am not sure if this is along the right lines, could anyone please help?

    Thanks!

    #132105 quote
    Nicolas
    Keymaster
    Master

    This small snippet will calculate the lot size according to your account and risk in percentage.

    //MM lot size
    REM Money Management
    Capital = 10000
    Risk = 0.01 // = 1%
    StopLoss = 100 // value of stoploss in pips/points
    REM Calculate contracts
    equity = Capital + StrategyProfit
    maxrisk = round(equity*Risk)
    PositionSize = abs(round((maxrisk/StopLoss)/PointValue)*pipsize)
    #132163 quote
    badar80
    Participant
    New

    Many thanks Nicholas! I’ll give this a try.

    #132172 quote
    badar80
    Participant
    New

    I have also noticed that my live trade was closed on Friay night. This was not supposed to happen; it was nowhere near either the stop loss or take profit, could anyone please advise as to how I could stop this from happening?

    I saw code with ‘lasttime’ and ‘opening time’ stipulated (https://www.prorealcode.com/topic/hold-over-the-weekend-or-not-test/); could these in some ways be used to let open trades carry on over the weekends?

    Thanks again.

    #132174 quote
    Vonasi
    Moderator
    Master

    Trades will only close if you have instructions in your code to do so. Possibly your broker expanded the spread over the weekend that meant that one of your stop prices was met and the trade closed. If you believe that one of your trades was closed when it should not have been then you should contact your broker and ask them why it closed.

    #132176 quote
    badar80
    Participant
    New

    Thanks for the response Vonasi, it was a short trade and there was a gap down over the weekend, but this would still not have resulted in the TP being hit, I’ll ask the broker.

    Thanks again,

    Badar.

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.

Define position size as percentage of account


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
badar80 @badar80 Participant
Summary

This topic contains 5 replies,
has 3 voices, and was last updated by badar80
5 years, 9 months ago.

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