Position sizing discrepancies between calculation, backtest and realtime

Forums ProRealTime English forum ProOrder support Position sizing discrepancies between calculation, backtest and realtime

Viewing 6 posts - 1 through 6 (of 6 total)
  • #105709

    Hi all,

    I wonder if anyone can help me understand how PRT deals with position size calculation and execution. I recently posted a strategy (https://www.prorealcode.com/topic/is-this-system-too-good-to-be-true/) that uses Nicolas’ dynamic position sizing function to calculate the position size based on the distance to the stop loss and the percent of equity at risk.

    Here’s a snippet of the position size function

    In the attachment you find a screenshot of the strategy implemented in realtime trading and also the backtest overlaid with the PositionSizeL variable graphed. You can see that:

    1. PositionSizeL calculated by the above function = 3
    2. The position size implemented in the backtest = 10
    3. The position size implemented in realtime = 10
    4. The initial equity was £5000 and the PositionSizeL function only permits positions to be opened with a max risk of 1% of the account equity, which in this example is £50. You can see from the screenshot that the amount that would be lost of the stop is hit is £176, more than double the max risk.

    Can anyone explain the discrepancy between the graphed value of PositionSizeL = 3 and the position size implemented in the backtest and realtime trading? Does it have something to do with the ‘BUY … PERPOINT’ command? How does PRT pass the PositionSizeL number to the engine that actually implements the executed position size?

     

    #105712

    Minimal size of contracts for that specific instrument? Did you try with CONTRACTS in backtests instead of PERPOINT?

    #105714

    Hi Nicolas, thank you for the quick response. The minimum position size with IG for USDJPY is 0.5 per point. I have not tried with contracts in the backtest because IG operate CFDs and spread bets (which is what I trade) on a per point basis. Would this work in realtime if I had a code to buy say 2 contracts but IG execute in per point?

    #105716

    StopLossL is calculated after the position size calculation, you should invert it otherwise you are still using a previous StopLoss size when you compute the position size.

    #105718

    I think that’s it you can see from the attached screenshot that if I iterate 1 bar back the graphed PositionSizeL = 10 which is the same as the executed value – i.e. as you say the calculation is using the previous value. I am going to adjust the positions of the Stoploss and position size calculations and see if that solves this issue. Thank you for your help Nicolas.

    #105719

    That solved the issue. I am very grateful for your help here Nicolas. I have posted variants fo this issue here and to the PRT and IG help desk on several occasions with no success. Thanks and all the best.

Viewing 6 posts - 1 through 6 (of 6 total)

Create your free account now and post your request to benefit from the help of the community
Register or Login