Latest source code for the indicator I'm working on.
Any suggestions are much appreciated.
//
@version=5indicator("Footprint Chart with Signals", overlay=true)
// Inputs
priceType = input.string("HL2", title="Price Source", options=["HL2", "Close", "Open", "High", "Low"])
volumeType = input.string("Volume", title="Volume Source", options=["Volume"])
numRows = input.int(10, title="Number of Rows", minval=1)
barWidth = input.int(2, title="Bar Width", minval=1)
atrLength = input.int(14, title="ATR Length", minval=1)
priceSource = priceType == "HL2" ? hl2 : priceType == "Close" ? close : priceType == "Open" ? open : priceType == "High" ? high : low
volumeSource = volumeType == "Volume" ? volume : volume
// Calculate footprint data
delta = volumeSource * (priceSource - open)
footprint = array.new_float(0)
volumeSum = 0.0
for i = 0 to 100
volumeSum := volumeSum + volumeSource[i * barWidth]
array.push(footprint, volumeSum)
array.reverse(footprint)
// Plot the chart
plot(delta, "Delta", color=color.blue, style=plot.style_histogram, linewidth=2)
// Add price action signals
ema5 = ta.ema(priceSource, 5)
maFast = ta.sma(priceSource, 5)
maSlow = ta.sma(priceSource, 20)
// TDI calculations
rsiPeriod = 13
bandLength = 34
emaLength = 2
rsi = ta.rsi(priceSource, rsiPeriod)
band = ta.sma(rsi, bandLength)
upper = ta.highest(band, bandLength)
lower = ta.lowest(band, bandLength)
emaUpper = ta.ema(upper, emaLength)
emaLower = ta.ema(lower, emaLength)
isUptrend = maFast > maSlow and close > ema5 and ta.crossover(rsi, emaUpper)
isDowntrend = maFast < maSlow and close < ema5 and ta.crossunder(rsi, emaLower)
var
bool buySignal = false
var
bool sellSignal = false
var
bool negateSignal = false
buySignal := not buySignal[1] and isUptrend and not isDowntrend[1]
sellSignal := not sellSignal[1] and isDowntrend and not isUptrend[1]
negateSignal := (buySignal[1] and isDowntrend) or (sellSignal[1] and isUptrend)
plotshape(buySignal, style=shape.triangleup, location=location.belowbar, color=color.green, size=size.small, transp=0)
plotshape(sellSignal, style=shape.triangledown, location=location.abovebar, color=color.red, size=size.small, transp=0)
plotshape(negateSignal, style=shape.arrowdown, location=location.abovebar, color=color.orange, size=size.small, transp=0)
// Stop loss and take profit levels based on the day's range
atr = ta.atr(atrLength)
stopLossLevelLong = close - atr
stopLossLevelShort = close + atr
takeProfitLevelLong = close + atr
takeProfitLevelShort = close - atr
plot(buySignal ? stopLossLevelLong : na, color=color.red)
plot(sellSignal ? stopLossLevelShort : na, color=color.red)
plot(buySignal ? takeProfitLevelLong : na, color=color.green)
plot(sellSignal ? takeProfitLevelShort : na, color=color.green)
You don’t trade for money, you trade for freedom.