Spider Vision
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © peacefulLizard50262

//@version=5
indicator("Spider Vision")
import peacefulLizard50262/Spider_Plot/1 as s

// DTO Function
dto(period_) => 
    barsback = period_/2 + 1
    ma = ta.sma(close, period_)
    dpo = close[barsback] - ma
    dpo

// Chop Zone Function
chopZone(length) =>
    ci = math.log10(math.sum(ta.atr(1), length) / (ta.highest(length) - ta.lowest(length))) / math.log10(length)
    ci

// BBW Function
bbw(src, length, mult) =>
    basis = ta.sma(src, length)
    dev = mult * ta.stdev(src, length)
    upper = basis + dev
    lower = basis - dev
    bbr = (src - lower)/(upper - lower)
    bbr

// Chaikin Function
chaikin(short, long) =>
    osc = ta.ema(ta.accdist, short) - ta.ema(ta.accdist, long)
    osc

source = input.source(close, "Source")
normalize_length = input.int(20)
rsiLength = input.int(14, "RSI Length", 1)
stoKLength = input.int(14, "Stochastic %K Length", 1)
momLength = input.int(10, "Momentum Length", 1)
bbwLength = input.int(20, "BBW Length", 1)
bbwMult = input.float(2.0, "BBW Multiplier")
dtoPeriod = input.int(20, "DTO Period", 1)
chopZoneLength = input.int(14, "Chop Zone Length", 1)
chaikinShort = input.int(3, "Chaikin Short Period", 1)
chaikinLong = input.int(10, "Chaikin Long Period", 1)

rsi_color = input.color(color.new(color.red , 80), "RSI Color")
sto_color = input.color(color.new(color.green , 80), "Stochastic Color")
mom_color = input.color(color.new(color.orange , 80), "Momentum Color")
bbw_color = input.color(color.new(color.aqua , 80), "BBW Color")
dto_color = input.color(color.new(color.purple , 80), "DTO Color")
cpz_color = input.color(color.new(color.navy , 80), "Chop Zone Color")
ckn_color = input.color(color.new(color.lime , 80), "Chaikin Color")

axes_color = input.color(color.gray, "Axes Color")
scale = input.int(30, "Scale")

rsi = ta.rsi(source, rsiLength) / 100
sto = ta.stoch(close, high, low, stoKLength) / 100
mom = s.data_normalize(ta.mom(source, momLength), "Range", normalize_length)
bbw = s.data_normalize(bbw(source, bbwLength, bbwMult), "Range", normalize_length)
dto = s.data_normalize(dto(dtoPeriod), "Range", normalize_length)
cpz = chopZone(chopZoneLength)
ckn = s.data_normalize(chaikin(chaikinShort, chaikinLong), "Range", normalize_length)

data = array.from(rsi, sto, mom, bbw, dto, cpz, ckn)
data_color = array.from(rsi_color, sto_color, mom_color, bbw_color, dto_color, cpz_color, ckn_color)

s.draw_spider_plot(data, data_color, axes_color, scale)
