Michał Wittig
Michał Wittig

Reputation: 1

Opening a position after exceeding the price level - without closing the candle

I would like to open a position immediately after exceeding the price level, and not only after the candle closes. In the screenshot - in place of the green arrow, not the red one. I try strategy (title = "Calculate on every tick example", overlay = true, calc_on_every_tick = true) but it doesn't work. Can someone help me? enter image description here

Upvotes: 0

Views: 50

Answers (1)

vitruvius
vitruvius

Reputation: 21342

You need to use limit orders for that.

//@version=5
strategy("My script", overlay=true)

sma = ta.sma(close, 50)
plot(sma)
strategy.entry("Long", strategy.long, stop=sma)

if (close < sma)
    strategy.close("Long")

enter image description here

Upvotes: 0

Related Questions