Help with position size calculation
Forums › ProRealTime English forum › ProOrder support › Help with position size calculation
- This topic has 7 replies, 3 voices, and was last updated 5 years ago by Derek.
-
-
08/12/2019 at 2:59 PM #104609
Ok, so in the previous post I though I had resolved the issue, but I hadn’t.
Im trying to understand how PRT calculate position size based on the following code. This is an example with a recent trade take on SP500.
here are the parameters:
123456789equity = 41908maxrisk = round(equity*0.01)PointValue = 1pipsize = 0.01StopLossS = abs(2898.64 - 2903.59) + 1Here is the position size function with Nicolas wrote in his blog
1PositionSizeS = abs(round((maxrisk/StopLossS)/PointValue)*pipsize)This gives me a value of 0.7
which is then passed to the Buy command
1BUY PositionSizeS PERPOINT AT MARKETIn the backtest given the above parameters this opens a position of 224 per point which is insanely large! I have no idea where it is getting this number from. The value should actually be 70 = 70 * StopLossS (5.95) = 419 = 1% of equity.
Can anyone explain to me what Im doing wrong here and why PRT is opening such large positions with the above code?
08/12/2019 at 6:26 PM #104631How could that work? You cannot assign values to PointValue and pipsize, since they are system constants.
Moreover pipsize is 1, not 0.01.
08/12/2019 at 6:35 PM #104633With this code:
123456789101112equity = 41908maxrisk = round(equity*0.01)//PointValue = 1//pipsize = 0.01StopLossS = abs(2898.64 - 2903.59) + 1PositionSizeS = abs(round((maxrisk/StopLossS)/PointValue)*pipsize)buy PositionSizeS perpoint at -close limitgraph PositionSizeSgraph maxriskgraph StopLossSgraph (maxrisk/StopLossS)graph round(maxrisk/StopLossS)you can see the values retained, using GRAPH.
1 user thanked author for this post.
08/13/2019 at 9:15 AM #104655Thanks Roberto. I was not aware that I couldn’t assign values to the constants. I used to programming in R where you can do just that and have a console that allows you to check each calculation the the code is making. For the S&P500 I used the information in the attached screen shot – where ‘tick size = 0.01’ (which I assumed to be equivalent to ‘pip size’) and ‘point size = 1’ which I assumed to be equal to ‘PointValue’ in the code.
The screenshot you put up show the position size function is calculating the correct position size – so I cannot understand why in some instances I get positions being opened with up to 3x the designated max risk. Attached also is a screenshot from yesterday of the code opening a position on the DAX – note the Stoploss implies a risk of the £1500 with an account size of £36000 – this is a lot more than 1% risk. Obviously its not possible to trade this outside of demo until these kinds of glitches can be understood. In your experience with trading with algos on PRT are these kinds of inconsistencies typical?
08/13/2019 at 9:33 AM #104659Well… in the past there were more errors/inconsistencies using DEMO accounts with IG. Recently some have been worked out but still some reamain.
You’d better address PRT/IG typing Ctrl+M from the platform.
08/13/2019 at 6:49 PM #104696Hi Rodger Dodger,
your code and your sample calculation do not match, I think.
The value should actually be 70 = 70 * StopLossS (5.95) = 419 = 1% of equity.
So, 70 = 419 and how does this match your code?
1PositionSizeS = abs(round((maxrisk/StopLossS)/PointValue)*pipsize)08/13/2019 at 9:56 PM #104710Im not sure I follow Derek.
If I have a stop of 5.95 points then I should be opening a position of 70 per point which would lead to 419 loss which is equal to 1% of total equity. If you remove the pipsize multiplier at the end of the position size function you get 70.
I thin that the position size function is working correctly and the problem is with either PRT or IG as on rare occasions I will get a position opened that has >3x the designated max risk. I have contacted IG and they in conjunction with PRT are looking into it. I will update on here when/if a solution is reached.
08/15/2019 at 11:10 AM #104783 -
AuthorPosts
Find exclusive trading pro-tools on