Pine Script breakout

Viewed 24

what am I trying to achieve

  • take the High and low of the 1st 5 minute candle
  • make and entry when a candle close above/below the 1st 5 minute candle with Stop loss of opposite high/low of the 1st 5 minute candle

I have tried the code below, not the result I want

//@version=4
strategy("Session hi/lo", "", true)

timeAllowed = input("0915-0920", "Allowed hours", input.session)

var hi = 10e-10
var lo = 10e10

timeIsAllowed = time(timeframe.period, timeAllowed + ":1234567")

if timeIsAllowed
    hi := high
    lo := low
clos = close
Buy = hi < clos

if Buy
    strategy.entry("buy", strategy.long, 1, when=strategy.position_size <= 0)

plot(clos)
plot(hi, color=color.green, style=plot.style_circles)
plot(lo, color=color.red, style=plot.style_circles)


Thanks in advance

0 Answers
Related