'pine script calculating wrong position sizing
i am trying to calculate the size of a trade based on a fixed amount of risk.For example i am trying to take a risk of 10$ on a short position and my stop loss is previous candle high so the code follows size = 10 / (high1 - strategy.position_avg_price)
but to my surprise the strategy tester shows the wrong quantity as shown in the image. The position price is 5.058 and stop loss price(previous candle high) is 5.208, so according the formulae size=10/(5.208-5.058) which equals to 66.66 but the tester shows 50.761. Am i doing anything wrong? Please help me.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
