Relative Content

Tag Archive for pine-scriptwebhookspine-script-v5tradingview-api

PineScript is exiting strategy and opening a double sized order on the same bar (sending webhook with double the quantity to the broker)

Using the pine script editor in TradingView, I’ve noticed a strange occurrence. When there are triggers to exit a long trade and a trigger to enter a short trade on the same bar, the position has 2x the position size than I would expect. It does not have effect on the Profit/loss calculations but send webhook request to my broker with 2x the intended quantity. Any strategy using strategy.entry(“ID1”,streategy.long) then strategy.entry(“ID2”,streategy.short) produces these results. So the question I have is how do I prevent strategy for displaying this behavior and sending 2x the intended quantity to the broker. Here is an example: