I’m creating a strategy in Pine Editor and it’s working pretty well. Only issue is there’s a little bit of odd behaviour happening that I don’t even know where to start to diagnose and any point in the right direction would be a massive help.
What’s happening?
I have created an input field that works out the risk percentage based on the balance in the account. Below is the properties where it can be edited.
The strangest thing happens when I change from 1% to say 3%. The trade enters at a completely different time.
The image below shows the entry on 1%
The image below shows the entry on 3%
As you can see there is a trade that executes around the 15th of Jan on the 1% settings. But on the 3% setting the first trade doesn’t execute till mid February. “What the ….?”
The code is as per below
The input code
risk_percent = input(1, title="Risk %") // User input for risk percentage
Position size is calculated with the following line of code
position_size := ((strategy.equity * risk_percent / 100) / (basis - lower_bar) * lots)
Basis is just a 20 moving average, and lower_bar is just 3 standard deviation Bollinger Band. And below is the code that enters the position and closes it.
strategy.entry("Long", strategy.long ,qty = position_size , limit = basis )
strategy.exit("Exit", "Long", limit = take_profit, stop = stop_loss )
Anyone come across this phenomena or have any guesses on what could be causing this?