PHP Code:
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © PhantomFlow_s666ex_
//@version=5
indicator("..", "...", true, max_lines_count = 500)
type fractal
int fractal_bar
box bx
type wave
bool isActive
bool isSearchCountertrendFormation
bool isSearchTrendFormation
int bar_start
int bar_end
float high_price
float low_price
array<line> lines
var array<wave> waves_down = array.new<wave>()
var array<wave> waves_up = array.new<wave>()
var array<int> fractals_down_zigzag = array.new<int>()
var array<int> fractals_up_zigzag = array.new<int>()
var array<bool> listFractals = array.new<bool>()
var array<fractal> LevelsShort = array.new<fractal>()
var array<fractal> LevelsLong = array.new<fractal>()
var array<fractal> LevelsShortHTF = array.new<fractal>()
var array<fractal> LevelsLongHTF = array.new<fractal>()
var array<int> levelsToCoef = array.new<int>()
ltf = timeframe.period
up_trend_start = input.color(title='Low', defval = color.rgb(255, 253, 106), group="Up Trend Power", inline = "up_trend")
up_trend_end = input.color(title='High', defval = color.rgb(0, 255, 0), group="Up Trend Power", inline = "up_trend")
down_trend_start = input.color(title='Low', defval = color.rgb(255, 89, 255), group="Down Trend Power", inline = "down_trend")
down_trend_end = input.color(title='High', defval = color.rgb(255, 0, 0), group="Down Trend Power", inline = "down_trend")
n_zigzag = 2
is_down_fractal_zigzag() =>
bool isConfirmFractal = false
for i = 0 to n_zigzag + n_zigzag
if low[n_zigzag] > low[i]
break
if (i == n_zigzag + n_zigzag)
isConfirmFractal := true
isConfirmFractal
is_up_fractal_zigzag() =>
bool isConfirmFractal = false
for i = 0 to n_zigzag + n_zigzag
if high[n_zigzag] < high[i]
break
if (i == n_zigzag + n_zigzag)
isConfirmFractal := true
isConfirmFractal
check_is_add_up_liquidity() =>
if array.size(fractals_up_zigzag) > 2
item1 = array.last(fractals_up_zigzag)
item2 = array.get(fractals_up_zigzag, array.size(fractals_up_zigzag) - 2)
item3 = array.get(fractals_up_zigzag, array.size(fractals_up_zigzag) - 3)
if (high[bar_index - item1] < high[bar_index - item2] and high[bar_index - item2] < high[bar_index - item3])
if array.size(waves_up) == 0
array.push(waves_up, wave.new(true, true, true, item3, item1, high[bar_index - item3], high[bar_index - item1], array.new<line>()))
true
else
wave last_wave = array.last(waves_up)
if (item3 >= last_wave.bar_start and item3 < last_wave.bar_end)
last_wave.bar_end := item1
last_wave.low_price := high[bar_index - item1]
last_wave.isActive := false
true
else
array.push(waves_up, wave.new(true, true, true, item3, item1, high[bar_index - item3], high[bar_index - item1], array.new<line>()))
true
check_is_add_down_liquidity() =>
if array.size(fractals_down_zigzag) > 2
item1 = array.last(fractals_down_zigzag)
item2 = array.get(fractals_down_zigzag, array.size(fractals_down_zigzag) - 2)
item3 = array.get(fractals_down_zigzag, array.size(fractals_down_zigzag) - 3)
if (low[bar_index - item1] > low[bar_index - item2] and low[bar_index - item2] > low[bar_index - item3])
if array.size(waves_down) == 0
array.push(waves_down, wave.new(true, true, true, item3, item1, low[bar_index - item1], low[bar_index - item3], array.new<line>()))
true
else
wave last_wave = array.last(waves_down)
if (item3 >= last_wave.bar_start and item3 < last_wave.bar_end)
last_wave.bar_end := item1
last_wave.high_price := low[bar_index - item1]
last_wave.isActive := false
true
else
array.push(waves_down, wave.new(true, true, true, item3, item1, low[bar_index - item1], low[bar_index - item3], array.new<line>()))
true
bool is_search_fractal_zigzag = bar_index - n_zigzag * 2 >= 0
if is_search_fractal_zigzag and true
if is_up_fractal_zigzag()
if array.size(fractals_up_zigzag) == 0
array.push(fractals_up_zigzag, bar_index - (n_zigzag))
array.push(listFractals, true)
else
isUpLastFractal = array.last(listFractals)
lastFractal = array.last(fractals_up_zigzag)
if isUpLastFractal and high[bar_index - lastFractal] < high[n_zigzag]
array.pop(fractals_up_zigzag)
array.push(fractals_up_zigzag, bar_index - (n_zigzag))
check_is_add_up_liquidity()
if not isUpLastFractal
lastFractalDown = array.last(fractals_down_zigzag)
if (low[bar_index - lastFractalDown] < high[n_zigzag])
array.push(fractals_up_zigzag, bar_index - (n_zigzag))
array.push(listFractals, true)
check_is_add_up_liquidity()
if is_down_fractal_zigzag()
if array.size(fractals_down_zigzag) == 0
array.push(fractals_down_zigzag, bar_index - (n_zigzag))
array.push(listFractals, false)
else
isUpLastFractal = array.last(listFractals)
lastFractal = array.last(fractals_down_zigzag)
if not isUpLastFractal and low[bar_index - lastFractal] > low[n_zigzag]
array.pop(fractals_down_zigzag)
array.push(fractals_down_zigzag, bar_index - (n_zigzag))
check_is_add_down_liquidity()
if isUpLastFractal
lastFractalUp = array.last(fractals_up_zigzag)
if (high[bar_index - lastFractalUp] > low[n_zigzag])
array.push(fractals_down_zigzag, bar_index - (n_zigzag))
array.push(listFractals, false)
check_is_add_down_liquidity()
bool isDownTrend = false
bool isUpTrend = false
var float last_low = na
var float last_high = na
if (array.size(waves_up) != 0 and array.size(waves_down) != 0)
wave lastWaveUp = array.last(waves_up)
wave lastWaveDown = array.last(waves_down)
if (close < lastWaveDown.high_price and close > lastWaveUp.low_price)
if (lastWaveDown.bar_end < lastWaveUp.bar_end)
isUpTrend := true
last_low := lastWaveUp.low_price
last_high := lastWaveUp.high_price
else
isDownTrend := true
last_low := lastWaveDown.low_price
last_high := lastWaveDown.high_price
if (close >= lastWaveDown.high_price and close > lastWaveUp.low_price)
isUpTrend := true
last_low := lastWaveUp.low_price
last_high := lastWaveUp.high_price
if (close < lastWaveDown.high_price and close <= lastWaveUp.low_price)
isDownTrend := true
last_low := lastWaveDown.low_price
last_high := lastWaveDown.high_price
if (array.size(waves_up) != 0 and array.size(waves_down) == 0)
wave lastWave = array.last(waves_up)
if (close > lastWave.low_price)
isUpTrend := true
last_low := lastWave.low_price
last_high := lastWave.high_price
if (array.size(waves_down) != 0 and array.size(waves_up) == 0)
wave lastWave = array.last(waves_down)
if (close < lastWave.high_price)
isDownTrend := true
last_low := lastWave.low_price
last_high := lastWave.high_price
var color trend_css = na
float signal = ta.ema(close, 1)
color signalColorDown = color.from_gradient(signal, last_low, last_high, up_trend_start, up_trend_end)
color signalColorUp = color.from_gradient(signal, last_low, last_high, down_trend_end, down_trend_start)
if isDownTrend
trend_css := signalColorUp
if isUpTrend
trend_css := signalColorDown
plotcandle(open, high, low, close
, color = trend_css
, wickcolor = trend_css
, bordercolor = trend_css
, editable = false
, display = display.pane)
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © mxrshxl_trxde
//@version=5
n = input.int(2, title='Min. bars for range')
coefZone = 4
// all_color = input.color(title='All colors', defval = color.rgb(0, 255, 234, 80), group="Visual Settings", inline = 'bg_ltf_color_liquidity')
color_up = input.color(title='Background UP', defval = color.rgb(255, 0, 0, 20), group="Visual Settings", inline = 'bg_ltf_color_liquidity')
color_down = input.color(title='Background DOWN', defval = color.rgb(0, 255, 0, 20), group="Visual Settings", inline = 'bg_ltf_color_liquidity')
// color_up_setup = input.color(title='Background UP Setup', defval = color.rgb(255, 0, 234, 80), group="Visual Settings", inline = 'bg_ltff_color_liquidity')
// color_down_setup = input.color(title='Background DOWN Setup', defval = color.rgb(0, 225, 255, 80), group="Visual Settings", inline = 'bg_ltff_color_liquidity')
type zone
int startBar
int endBar
float priceHigh
float priceLow
bool isChained
bool isDropZone
bool isActive
bool isBuildZone
string typeSort
box bx
bool isSetup
var array<zone> zones_all = array.new<zone>()
var array<zone> chain_zones_all = array.new<zone>()
var array<float> sized_zones = array.new<float>()
if (array.size(zones_all) != 0)
zone lastZone = array.last(zones_all)
if lastZone.priceLow > close or lastZone.priceHigh < close
if (lastZone.endBar - lastZone.startBar != 1 and lastZone.endBar - lastZone.startBar >= n and not lastZone.isDropZone)
lastZone.isChained := true
array.push(sized_zones, lastZone.priceHigh - lastZone.priceLow)
if (array.size(sized_zones) > 5)
array.shift(sized_zones)
else
if not na(lastZone.bx)
box.delete(lastZone.bx)
array.remove(zones_all, array.indexof(zones_all, lastZone))
if high[1] >= close and high[1] >= open and low[1] <= close and low[1] <= open
isContinous = true
if (array.size(zones_all) != 0)
zone lastZone = array.last(zones_all)
if not lastZone.isChained
if lastZone.priceHigh >= close and lastZone.priceHigh >= close[1] and lastZone.priceHigh >= open and lastZone.priceHigh >= open[1] and lastZone.priceLow <= close and lastZone.priceLow <= close[1] and lastZone.priceLow <= open and lastZone.priceLow <= open[1]
lastZone.endBar := bar_index
isContinous := false
if not na(lastZone.bx)
box.delete(lastZone.bx)
// lastZone.bx := box.new(lastZone.startBar, lastZone.priceHigh, lastZone.endBar, lastZone.priceLow, border_color = all_color, bgcolor = all_color)
else
if lastZone.endBar - lastZone.startBar == 1 or lastZone.endBar - lastZone.startBar < n
if not na(lastZone.bx)
box.delete(lastZone.bx)
array.remove(zones_all, array.indexof(zones_all, lastZone))
else
lastZone.isChained := true
array.push(sized_zones, lastZone.priceHigh - lastZone.priceLow)
if (array.size(sized_zones) > 5)
array.shift(sized_zones)
if lastZone.isChained and not lastZone.isBuildZone
lastZone.isDropZone := true
if not na(lastZone.bx)
box.delete(lastZone.bx)
if array.size(sized_zones) != 0 and isContinous
if (high[1] - low[1]) / array.avg(sized_zones) > coefZone
array.push(sized_zones, high[1] - low[1])
if (array.size(sized_zones) > 5)
array.shift(sized_zones)
isContinous := false
else
array.push(zones_all, zone.new(bar_index - 1, bar_index, high[1], low[1], false, false, false, false, na, na, false))
if array.size(sized_zones) == 0 and isContinous
array.push(zones_all, zone.new(bar_index - 1, bar_index, high[1], low[1], false, false, false, false, na, na, false))
if array.size(zones_all) != 0
zone lastZone = array.last(zones_all)
if not lastZone.isChained and array.size(zones_all) > 1
lastZone := array.get(zones_all, array.size(zones_all) - 2)
if lastZone.isChained and not lastZone.isBuildZone and not lastZone.isDropZone
if high > lastZone.priceHigh and close > lastZone.priceHigh
if lastZone.endBar - lastZone.startBar >= n
lastZone.isBuildZone := true
lastZone.isActive := true
lastZone.typeSort := 'long'
array.push(chain_zones_all, lastZone)
if not na(lastZone.bx)
box.delete(lastZone.bx)
lastZone.bx := box.new(lastZone.startBar, lastZone.priceHigh, lastZone.endBar, lastZone.priceLow, border_color = color_down, bgcolor = color_down)
else
lastZone.isDropZone := true
if not na(lastZone.bx)
box.delete(lastZone.bx)
if low < lastZone.priceLow and close < lastZone.priceLow
if lastZone.endBar - lastZone.startBar >= n
lastZone.isBuildZone := true
lastZone.isActive := true
lastZone.typeSort := 'short'
array.push(chain_zones_all, lastZone)
if not na(lastZone.bx)
box.delete(lastZone.bx)
lastZone.bx := box.new(lastZone.startBar, lastZone.priceHigh, lastZone.endBar, lastZone.priceLow, border_color = color_up, bgcolor = color_up)
else
lastZone.isDropZone := true
if not na(lastZone.bx)
box.delete(lastZone.bx)
// if array.size(zones_all) > 2
// zone lastZone = array.last(zones_all)
// zone prevZone = array.get(zones_all, array.size(zones_all) - 2)
// zone prevPrevZone = array.get(zones_all, array.size(zones_all) - 3)
// if lastZone.isBuildZone and prevZone.isBuildZone and prevPrevZone.isBuildZone
// if lastZone.typeSort == "short" and prevZone.typeSort == "short" and prevPrevZone.typeSort == "long"
// if prevPrevZone.priceHigh >= prevZone.priceLow and prevPrevZone.priceHigh < prevZone.priceHigh and lastZone.priceHigh >= prevZone.priceLow and lastZone.priceHigh < prevZone.priceHigh
// lastZone.isSetup := true
// if not na(lastZone.bx)
// box.delete(lastZone.bx)
// lastZone.bx := box.new(lastZone.startBar, lastZone.priceHigh, lastZone.endBar, lastZone.priceLow, border_color = color_up_setup, bgcolor = color_up_setup)
// if lastZone.typeSort == "long" and prevZone.typeSort == "long" and prevPrevZone.typeSort == "short"
// if prevPrevZone.priceLow <= prevZone.priceHigh and prevPrevZone.priceLow > prevZone.priceLow and lastZone.priceLow <= prevZone.priceHigh and lastZone.priceLow > prevZone.priceLow
// lastZone.isSetup := true
// if not na(lastZone.bx)
// box.delete(lastZone.bx)
// lastZone.bx := box.new(lastZone.startBar, lastZone.priceHigh, lastZone.endBar, lastZone.priceLow, border_color = color_down_setup, bgcolor = color_down_setup)
// © DraftVenture
//@version=5
// User-defined inputs
length = input(20, "Period")
// Calculate highest and lowest points
highestHigh = ta.highest(high, length)
lowestLow = ta.lowest(low, length)
// Get bars since high and low
barsSinceHigh = ta.barssince(high == highestHigh)
barsSinceLow = ta.barssince(low == lowestLow)
// Calculate the sine wave using highest and lowest points
x = bar_index - ta.min(bar_index)
omega = 2 * math.pi / length
sineLine = math.sin(omega * x) * (highestHigh - lowestLow) / 2 + (highestHigh + lowestLow) / 2
// Plotting
plot(sineLine, color=color.white)
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © DeltaAlgo
//@version=5
// user inputs
length22 = input.int(6, "Length", 2, 999, 1, inline = "tgc", group = "trend gaussian channel settings")
mult22 = input.float(3, "", 1, 5, 0.01, "Top & Bottom Band Multiplier", "tgc", "trend gaussian channel settings")
barcol22 = input.bool(false, "Bar Colors", "Toggle On/Off Candle Colors", group = "candle color settings")
signal22 = input.bool(true, "Trend Shift Signals", "Toggle On/Off Trend Signals When Trend Shifts", group = "candle color settings")
// gaussian channel
guassianBasis(float source, int length22, float mult22) =>
basis = ta.ema(ta.hma(ta.sma(source, length22), length22 * 2), length22 /2)
topBand = basis + (ta.atr(105) * (mult22 * 1.005))
lowBand = basis - (ta.atr(105) / (mult22 / 1.005))
[basis, topBand, lowBand]
[base, upper, lower] = guassianBasis(close, length22, mult22)
upward = base < high
dnward = base > low
basePlot = plot(base, "Base", upward ? color.new(#00cf4b, 15) : color.new(#ff5252, 15), 2)
upperPlot = plot(upper, "Upper", upward ? color.new(#00cf4b, 20) : color.new(#ff5252, 20), 2)
lowerPlot = plot(lower, "Lower", upward ? color.new(#00cf4b, 20) : color.new(#ff5252, 20), 2)
//fill(upperPlot, lowerPlot, upward ? color.new(#00cf4b, 80) : color.new(#ff0000, 80), "Channel Fill")
// barcolor
uptrend = color.from_gradient(ta.rsi(close, 15), 25, 76, #67248f, #00cf4b)
ranging = color.from_gradient(ta.rsi(close, 15), 30, 75, #63726f, #67248f)
dntrend = color.from_gradient(ta.rsi(close, 15), 8, 82, #ff0000, #67248f)
//barcolor(barcol22 ? high > upper ? uptrend : high < upper and high > lower ? ranging : dntrend : na)
// signals
upSignalCondition = high > upper and ta.crossover(low, upper)
dnSignalCondition = low < lower and ta.crossunder(high, lower)
plotshape(signal22 and upSignalCondition, "Bullish Signal", shape.labelup, location.belowbar, color.new(#00cf4b, 35), size = size.small)
plotshape(signal22 and dnSignalCondition, "Bearish Signal", shape.labeldown, location.abovebar, color.new(#ff0000, 35), size = size.small)
Yer İmleri