I have a question regarding my PRT Code. I wanted to define the position size so that the same risk in terms of $ value applies for each trade. Once I perform a backtest the position size varies and most of the time it is doing what it should. But there is also a significant number of exceptions where the result deviates too much from the original intention with 1:1 Risk/Reward.
Please find below the code and attached also a picture of the results with yellow marked deviations.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
SL=(High-Low)
R=500
Tickvalue=2
OrderQty=Round((R/SL)/Tickvalue),0)
//Conditions for Direction Short
IF....THEN
Direction=-1
ENDIF
IFNOTOnMarketANDDirection=-1THEN
SELLSHORTOrderQtyCONTRACTAT(Low-0.25*pipsize)Stop
SET STOPPLOSS(SL)*pipsize
InitialSL=SL
ENDIF
//Exit Short 1:1
IFShortOnMarketTHEN
SET STOPPLOSS(1*InitialSL)
SET TARGETPPROFIT(1*InitialSL)
ENDIF
The average position size is like 10-15 contracts, so it is not the problem that it is only 1 contract.
What is wrong in my code and what can I do better in order to have a proper position size for risk/reward calculation?
A lot has already been written on the forum about money/risk management, and if you check the library or search for “money management,” you’ll find plenty of useful information…
We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.Ok