//@version=5
strategy("Supply and Demand", overlay=true)
// Input untuk menentukan periode
period = input(14, title="Period")
// Menghitung titik tertinggi dan terendah dalam periode
supplyHigh = security(syminfo.tickerid, "D", high, gaps=barmerge.gaps_off, lookahead=barmerge.lookahead_on)
demandLow = security(syminfo.tickerid, "D", low, gaps=barmerge.gaps_off, lookahead=barmerge.lookahead_on)
// Menggambar zona Supply dan Demand
plot(supplyHigh, color=color.red, linewidth=2, title="Supply Zone")
plot(demandLow, color=color.green, linewidth=2, title="Demand Zone")
// Logika untuk sinyal beli dan jual berdasarkan Supply dan Demand
buySignal = close > demandLow
sellSignal = close < supplyHigh
// Menandai titik beli dan jual pada grafik
plotshape(series=buySignal, title="Buy Signal", color=color.green, style=shape.labelup, location=location.belowbar)
plotshape(series=sellSignal, title="Sell Signal", color=color.red, style=shape.labeldown, location=location.abovebar)
// Logika strategi untuk memasuki dan keluar dari posisi
strategy.entry("Buy", strategy.long, when=buySignal)
strategy.close("Buy", when=sellSignal)
strategy.entry("Sell", strategy.short, when=sellSignal)
strategy.close("Sell", when=buySignal)
strategy("Supply and Demand", overlay=true)
// Input untuk menentukan periode
period = input(14, title="Period")
// Menghitung titik tertinggi dan terendah dalam periode
supplyHigh = security(syminfo.tickerid, "D", high, gaps=barmerge.gaps_off, lookahead=barmerge.lookahead_on)
demandLow = security(syminfo.tickerid, "D", low, gaps=barmerge.gaps_off, lookahead=barmerge.lookahead_on)
// Menggambar zona Supply dan Demand
plot(supplyHigh, color=color.red, linewidth=2, title="Supply Zone")
plot(demandLow, color=color.green, linewidth=2, title="Demand Zone")
// Logika untuk sinyal beli dan jual berdasarkan Supply dan Demand
buySignal = close > demandLow
sellSignal = close < supplyHigh
// Menandai titik beli dan jual pada grafik
plotshape(series=buySignal, title="Buy Signal", color=color.green, style=shape.labelup, location=location.belowbar)
plotshape(series=sellSignal, title="Sell Signal", color=color.red, style=shape.labeldown, location=location.abovebar)
// Logika strategi untuk memasuki dan keluar dari posisi
strategy.entry("Buy", strategy.long, when=buySignal)
strategy.close("Buy", when=sellSignal)
strategy.entry("Sell", strategy.short, when=sellSignal)
strategy.close("Sell", when=buySignal)