OPEN-SOURCE SCRIPT

Kamal 8 Tick Trading Setup

//version=5
indicator("Kamal 8 Tick Trading Setup", overlay=true)

// Define the length for the lookback period
length = 8

// Calculate the highest high and lowest low of the previous 'length' candles, excluding the current candle
highestHigh = ta.highest(high[1], length)
lowestLow = ta.lowest(low[1], length)

// Initialize a variable to track the current position
var int position = 0 // 0 = no position, 1 = buy, -1 = sell

// Generate Buy and Sell signals
buySignal = (close > highestHigh) and (position != 1)
sellSignal = (close < lowestLow) and (position != -1)

// Update the position variable
if (buySignal)
position := 1
if (sellSignal)
position := -1

// Plot Buy and Sell signals on the chart
plotshape(series=buySignal, location=location.belowbar, color=color.green, style=shape.labelup, text="BUY")
plotshape(series=sellSignal, location=location.abovebar, color=color.red, style=shape.labeldown, text="SELL")

// Debugging plots to check the highest high and lowest low
plot(highestHigh, color=color.blue, title="Highest High")
plot(lowestLow, color=color.orange, title="Lowest Low")

Wyłączenie odpowiedzialności