PHP Code:
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © fondDealer96636
//@version=5
indicator('*', max_lines_count=200, overlay=true, max_bars_back=201,max_boxes_count = 200)
// input
start11 = 2
lookback11 = input(1, "Sensitivity", tooltip="Low (High Sensitivity), High (Low Sensitivity).\n\nAdjust according to timeframe and asset.")
resp11 = 1
smoothing11 = input(1, "Smoothing")
source11 = input(close, "Source")
// global
var ix = -1
var mal = array.new_int(0)
// functions
avg(source11, len11) =>
sum = 0.0
for i = 0 to len11-1
sum += source11[i]
sum/len11
bull = close > open
wick_touch(x) =>
bull ? ((close <= x and x <= high) or (low <= x and x <= open)) : ((open <= x and x <= high) or (low <= x and x <= close))
body_touch(x) =>
bull ? (open < x and x < close) : (close < x and x < open)
touches(t) =>
touches = 0
for i = 0 to lookback11-1
touches += t[i] ? 1 : 0
touches
// local
ix := ix+1
prev_mal = ix >= 1 ? array.get(mal, ix-1) : start11
cma = avg(source11, prev_mal)
cma_p1 = avg(source11, prev_mal+1)
cma_m1 = avg(source11, prev_mal-1)
d = touches(wick_touch(cma))
d_p1 = touches(wick_touch(cma_p1))
d_m1 = touches(wick_touch(cma_m1))
d_b = touches(body_touch(cma))
d_p1_b = touches(body_touch(cma_p1))
d_m1_b = touches(body_touch(cma_m1))
any_body_touch = d_b > 0 or d_p1_b > 0 or d_m1_b > 0
no_wick_touch = d <= 0 and d_p1 <= 0 and d_m1 <= 0
wick_maximized = d >= d_p1 and d >= d_m1 ? prev_mal : (d_p1 >= d and d_p1 >= d_m1 ? prev_mal+resp11 : (d_m1 >= d and d_m1 >= d_p1 ? prev_mal-resp11 : na))
uptrend = cma > cma[1]
downtrend = cma < cma[1]
against_trend = (uptrend and close < cma) or (downtrend and close > cma)
new_mal = no_wick_touch or against_trend ? prev_mal-resp11 : (any_body_touch ? prev_mal+resp11 : wick_maximized)
next_mal = na(new_mal) ? prev_mal : new_mal
array.push(mal, next_mal < 2 ? 2 : (next_mal > 200 ? 200 : next_mal))
// graph
scma = ta.ema(cma, smoothing11)
plot(scma, "MA1", color=color.rgb(255, 235, 59, 100))
///////////////////////////////
// input
start1122 = 2
lookback1122 = input(4, "Sensitivity", tooltip="Low (High Sensitivity), High (Low Sensitivity).\n\nAdjust according to timeframe and asset.")
resp1122 = 1
smoothing1122 = input(1, "Smoothing")
source1122 = input(close, "Source")
// global
var ix11 = -1
var mal11 = array.new_int(0)
// functions
avg11(source1122, len1122) =>
sum = 0.0
for i = 0 to len1122-1
sum += source1122[i]
sum/len1122
bull11 = close > open
wick_touch11(x) =>
bull11 ? ((close <= x and x <= high) or (low <= x and x <= open)) : ((open <= x and x <= high) or (low <= x and x <= close))
body_touch11(x) =>
bull11 ? (open < x and x < close) : (close < x and x < open)
touches11(t) =>
touches = 0
for i = 0 to lookback1122-1
touches += t[i] ? 1 : 0
touches
// local
ix11 := ix11+1
prev_mal11 = ix >= 1 ? array.get(mal11, ix11-1) : start11
cma11 = avg11(source1122, prev_mal11)
cma_p111 = avg11(source1122, prev_mal11+1)
cma_m111 = avg11(source1122, prev_mal11-1)
d11 = touches11(wick_touch(cma11))
d_p111 = touches11(wick_touch(cma_p111))
d_m111 = touches11(wick_touch(cma_m111))
d_b11 = touches(body_touch(cma11))
d_p1_b11 = touches(body_touch(cma_p111))
d_m1_b11 = touches(body_touch(cma_m111))
any_body_touch11 = d_b11 > 0 or d_p1_b11 > 0 or d_m1_b11 > 0
no_wick_touch11 = d <= 0 and d_p111 <= 0 and d_m111 <= 0
wick_maximized11 = d >= d_p111 and d >= d_m111 ? prev_mal11 : (d_p111 >= d and d_p111 >= d_m111 ? prev_mal11+resp1122 : (d_m111 >= d and d_m111 >= d_p111 ? prev_mal11-resp1122 : na))
uptrend11 = cma11 > cma11[1]
downtrend11 = cma11 < cma11[1]
against_trend11 = (uptrend11 and close < cma11) or (downtrend11 and close > cma11)
new_mal11 = no_wick_touch11 or against_trend11 ? prev_mal11-resp1122 : (any_body_touch ? prev_mal11+resp1122 : wick_maximized11)
next_mal11 = na(new_mal11) ? prev_mal11 : new_mal11
array.push(mal11, next_mal11 < 2 ? 2 : (next_mal11 > 200 ? 200 : next_mal11))
// graph
scma11 = ta.ema(cma11, smoothing11)
plot(scma11, "MA2", color=color.rgb(33, 149, 243, 100))
crossUp = ta.crossover(scma,scma11)
crossDn = ta.crossunder(scma,scma11)
plotshape(crossUp,
title='Cross Long',
style=shape.labelup,
location=location.belowbar,
text='A',
textcolor=color.new(color.white, 0),
color=color.new(color.teal, 0),
size=size.auto,
editable=true)
plotshape(crossDn,
title='Cross Short',
style=shape.labeldown,
location=location.abovebar,
text='S',
textcolor=color.new(color.white, 0),
color=color.new(color.maroon, 0),
size=size.auto,
editable=true)
//Alerts
alertcondition(crossUp != 0, 'Long', 'Long')
alertcondition(crossDn != 0, 'Short', 'Short')
//////////////////////////////////////////////////////////
// © GASANOV_KIRILL
// v 2.0.1
// added labels
// removed std 257v
// setted up fib 274v
//@version=5
// INPUT
show_difference_label = input.bool(title ="Show difference", defval = true)
// alma
alma_source = close
alma_period = input.int(title='Window Size', defval=200, group='Alma')
alma_offset = input.float(title='Offset', defval=0.80, group='Alma')
alma_sigma = input.float(title='Sigma', defval=5.5, group='Alma')
border_first = input.float(title='First border offset', defval=4, group='Borders')
border_second = input.float(title='Second border offset (%)', defval=0.7, group='Borders')
border_third = input.float(title='Third border offset (%)', defval=1.4, group='Borders')
// keltner
kc_period = input.int(title='Keltner period', defval=100, group='Keltner')
kc_mult = input.float(title='Keltner mult.', defval=4, group='Keltner')
kc_atr_period = input.int(title='Keltner atr period', defval=50, group='Keltner')
kc_ma_period = input.int(title='Keltner ma period', defval=70, group='Keltner')
// fibonacci
fib_ma_period = input.int(title='Fibonacci ma period', defval=25, group='Fibonacci')
fib_atr_period = input.int(title='Fibonacci atr period', defval=25, group='Fibonacci')
fib_ratio_mult = input.float(title='Fibonacci ration', defval=3.5, group='Fibonacci')
fib_smooth_period = input.int(title='Fibonacci smooth period', defval=100, group='Fibonacci')
border_kc_lerp = input.float(title='Border kc lerp', defval=0.95, minval=0, maxval=1, group='Borders and lerp')
border_fib_lerp = input.float(title='Border fib lerp', defval=0.45, minval=0, maxval=1, group='Borders and lerp')
//PROPERTIES -----------------------------------------------------
get_kc_lerp() =>
border_kc_lerp
// FUNCTIONS -------------------------------------------------------------------
// ALMA MA
alma_template(source, length) =>
ta.alma(source, length, alma_offset, alma_sigma)
// Hull MA
hull_ma_build(source, length) =>
hullma = ta.wma(2 * ta.wma(source, length / 2) - ta.wma(source, length), math.floor(math.sqrt(length)))
hullma
// number to percent
do_percent(percent) =>
percent / 100
// percent difference from base value to other value
do_percent_diff(base_value, other_value) =>
((other_value*100)/base_value)-100
// create new coord for line based on percentage
do_offset_line(main_line, percent) =>
main_line * (1 + do_percent(percent))
// interpolates values
do_lerp(value_a, value_b, t) =>
(1 - t) * value_a + t * value_b
// normalize value between range min-max
do_normalize(min, max, value) =>
(value - min) / (max - min)
do_normalize_negative(min, max, value) =>
2 * ((value - min) / (max - min)) - 1
do_print(_text) =>
// Create label on the first bar.
var _label = label.new(bar_index, na, _text, xloc.bar_index, yloc.price, color.white, label.style_label_up, color.green, size.large, text.align_left)
// On next bars, update the label's x and y position, and the text it displays.
label.set_xy(_label, bar_index, ta.highest(10)[1])
label.set_text(_label, _text)
do_label(value_label, value_text, value_barindex, value_price) =>
label.set_xy(value_label, value_barindex, value_price)
label.set_text(value_label, value_text)
// MAIN ------------------------------------------------
// Fibonacci
fib_ma = ta.ema(close, fib_ma_period)
fib_tr1 = math.max(high - low, math.abs(high - close[1]))
fib_tr = math.max(fib_tr1, math.abs(low - close[1]))
fib_atr = ta.sma(fib_tr, fib_atr_period)
// green or red
//fib_prev_candle_state = ta.ema(close[1] > open[1] ? 1 : 0, 100)
// if trend not match border type (up-top, down-bottom) we minimise affect
//fib_ratio = fib_atr * fib_ratio_mult
//fib_top = fib_ma + (fib_ratio * fib_prev_candle_state)
//fib_bottom = fib_ma - (fib_ratio *(1-fib_prev_candle_state))
fib_ratio = fib_atr * fib_ratio_mult
fib_top = fib_ma + (fib_ratio)
fib_bottom = fib_ma - (fib_ratio)
fib_top_smoothed = hull_ma_build(fib_top, fib_smooth_period)
fib_bottom_smoothed = hull_ma_build(fib_bottom, fib_smooth_period)
// Keltner channel
kc_ma = ta.ema(alma_source, kc_period)
kc_range_ma = ta.atr(kc_atr_period)
kc_top = kc_ma + kc_range_ma * kc_mult
kc_bottom = kc_ma - kc_range_ma * kc_mult
// Ma based on kc_top/bottom and hma
kc_top_ma = hull_ma_build(kc_top, kc_ma_period)
kc_bottom_ma = hull_ma_build(kc_bottom, kc_ma_period)
// Main trend line
alma_main = alma_template(alma_source, alma_period)
// Calculate alma borders (top,bottom)
alma_top_raw = do_offset_line(alma_main, border_first)
alma_bottom_raw = do_offset_line(alma_main, -border_first)
// Lerp borders with kc
kc_lerp = get_kc_lerp()
alma_top = alma_top_raw
alma_bottom = alma_bottom_raw
// kc lerp
alma_top := do_lerp(alma_top, kc_top_ma, kc_lerp)
alma_bottom := do_lerp(alma_bottom, kc_bottom_ma, kc_lerp)
// Second pass ------------------------------------------------------------------
// price calculations
// normalize price between borders in range [-infinity[-1,+1]+infintiy]
normalized_price_top = do_normalize(alma_main, alma_top, close)
normalized_price_bottom = 1 - do_normalize(alma_bottom, alma_main, close)
normalized_price_top := normalized_price_top < 1 ? 0 : normalized_price_top
normalized_price_bottom := normalized_price_bottom < 1 ? 0 : normalized_price_bottom
// fibonacci lerp values
fib_lerp_top = 0.0
fib_lerp_bottom = 0.0
fib_lerp_top := normalized_price_top * border_fib_lerp
fib_lerp_bottom := normalized_price_bottom * border_fib_lerp
// apply fibonacci to border
alma_top := do_lerp(alma_top, fib_top_smoothed, border_fib_lerp)
alma_bottom := do_lerp(alma_bottom, fib_bottom_smoothed, border_fib_lerp)
// construct additional border layers
alma_top_2 = do_offset_line(alma_top, border_second)
alma_top_3 = do_offset_line(alma_top, border_third)
alma_bottom_2 = do_offset_line(alma_bottom, -border_second)
alma_bottom_3 = do_offset_line(alma_bottom, -border_third)
//plot(alma_top_2)
//plot(alma_bottom_2)
//plot(alma_top_3)
//plot(alma_bottom_3)
// THIRD PASS ------------------------------------------------
// Percent from main line.
normalized_price_top_for_diff = do_normalize(alma_bottom, alma_top, close)
// clamp normalized value
normalized_price_top_for_diff := ta.ema(normalized_price_top_for_diff < 0 ? 0: normalized_price_top_for_diff > 1 ? 1: normalized_price_top_for_diff, kc_period)
normalized_price_bottom_for_diff = 1 - normalized_price_top_for_diff
difference_percent_top = do_percent_diff(alma_main, alma_top_2)
difference_percent_bottom = do_percent_diff(alma_main, alma_bottom_2)
difference_percent_overall = difference_percent_top - difference_percent_bottom
mult_diff_overall = difference_percent_overall/10 < 1 ? 1 : difference_percent_overall/10
additional_percent_offset_top = normalized_price_top_for_diff * ((difference_percent_top/10) * mult_diff_overall)
additional_percent_offset_bottom = normalized_price_bottom_for_diff * ((difference_percent_bottom/10)* mult_diff_overall)
border_second_offset_top = border_second + additional_percent_offset_top/2
border_third_offset_top = border_third + additional_percent_offset_top
border_second_offset_bottom = -border_second + additional_percent_offset_bottom/2
border_third_offset_bottom = -border_third + additional_percent_offset_bottom
// calculate new alma borders
alma_top := ta.ema(alma_top,9)
alma_top_2 := do_offset_line(alma_top, border_second_offset_top)
alma_top_3 := do_offset_line(alma_top, border_third_offset_top)
alma_bottom_2 := do_offset_line(alma_bottom, border_second_offset_bottom)
alma_bottom_3 := do_offset_line(alma_bottom, border_third_offset_bottom)
// PLOT -------------------------------------------
//main lines
//plot(alma_main, title='Trend line', color=color.new(#7b1fa2, 0), style=plot.style_circles)
//borders
//plot(alma_top, title='Border top 1', color=color.new(#fff176, 50), linewidth=4)
//plot(alma_top_2, title='Border top 2', color=color.new(#e57373, 0))
//plot(alma_top_3, title='Border top 3', color=color.new(#ef5350, 0), linewidth=4)
//plot(alma_bottom, title='Border bottom 1', color=color.new(#009688, 50), linewidth=4)
//plot(alma_bottom_2, title='Border bottom 2', color=color.new(#81c784, 0))
//plot(alma_bottom_3, title='Border bottom 3', color=color.new(#4caf50, 0), linewidth=4)
// keltner
//plot(kc_top, color=color.new(color.maroon, 0), title='KC+', display=display.none)
//plot(kc_bottom, color=color.new(color.orange, 0), title='KC-', display=display.none)
//plot(kc_top_ma, color=color.new(color.maroon, 0), title='KC+ HMA', style=plot.style_circles, display=display.none)
//plot(kc_bottom_ma, color=color.new(color.orange, 0), title='KC- HMA', style=plot.style_circles, display=display.none)
// fibonacci
//plot(fib_top, color=color.new(color.red, 0), title='Fib+', display=display.none)
//plot(fib_bottom, color=color.new(color.green, 0), title='Fib-', display=display.none)
//plot(fib_top_smoothed, color=color.new(color.red, 0), title='Fib+ Smooth', style=plot.style_circles, display=display.none)
//plot(fib_bottom_smoothed, color=color.new(color.green, 0), title='Fib- Smooth', style=plot.style_circles, display=display.none)
// LABELS -----------------------------------------------------
var drawing_color_top = color.new(#e57373, 0)
var drawing_color_bottom = color.new(#81c784, 0)
var drawing_color_main = color.new(#ab47bc, 0)
var drawing_color_overall = color.new(#ec407a,0)
// Difference label
difference_bar_index = bar_index + 5
var label_difference_top = label.new(x = bar_index, y = close, yloc = yloc.price, color = drawing_color_top, textcolor = color.black, style = label.style_label_down)
var label_difference_bottom = label.new(x = bar_index, y = close, yloc = yloc.price, color = drawing_color_bottom, textcolor = color.black, style = label.style_label_up)
var label_difference_overall =label.new(x = bar_index, y = close, yloc = yloc.price, color = drawing_color_overall, textcolor = color.black, style = label.style_label_down)
// helper arrow lines
line_difference_top = line.new(x1 = bar_index, y1 = alma_top_2, x2 =difference_bar_index, y2 = alma_top_2, style = line.style_arrow_left,color = drawing_color_top)
line_difference_bottom = line.new(x1 = bar_index, y1 = alma_bottom_2,x2 =difference_bar_index, y2 = alma_bottom_2, style = line.style_arrow_left,color = drawing_color_bottom)
line_difference_main_****t = line.new(x1 = difference_bar_index, y1 = alma_bottom_2, x2 =difference_bar_index, y2 = alma_top_2, style = line.style_arrow_both,color=drawing_color_overall)
line_difference_main_overall = line.new(x1 = difference_bar_index, y1 = alma_main, x2 =difference_bar_index+5, y2 = alma_main, style = line.style_arrow_left,color=drawing_color_overall)
line.delete(line_difference_top[1]) // redraw lines
line.delete(line_difference_bottom[1])
line.delete(line_difference_main_****t[1])
line.delete(line_difference_main_overall[1])
if show_difference_label
do_label(label_difference_top, "+"+ str.tostring(difference_percent_top, format.percent), difference_bar_index, alma_top_2)
do_label(label_difference_bottom, str.tostring(difference_percent_bottom, format.percent), difference_bar_index, alma_bottom_2)
do_label(label_difference_overall, str.tostring(difference_percent_overall, format.percent), difference_bar_index+5,alma_main)
else
label.delete(label_difference_top)
label.delete(label_difference_bottom)
label.delete(label_difference_overall)
line.delete(line_difference_top)
line.delete(line_difference_bottom)
line.delete(line_difference_main_****t)
line.delete(line_difference_main_overall)
// Labels
//var label_difference_top = label.new(x = bar_index, y = close,yloc = yloc.price,color = color.white, textcolor = color.black,style = label.style_label_down)
//do_label(label_difference_top, "Textik", bar_index+5, alma_top_2)
//if not show_difference_label
//label.delete(label_difference_top)
//var label_difference_bottom = label.new(x = bar_index, y = close,yloc = yloc.price,color = color.white, textcolor = color.black, style = label.style_label_up)
//do_label(label_difference_bottom, "Textik", bar_index+5, alma_bottom_2)
//if not show_difference_label
// label.delete(label_difference_bottom)
////////////////////////////////////////////////////////////////////////////////////////////
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © starbolt
//@version=5
len = input.int(3, 'Length', step=1, minval=1)
displace = input.int(1, 'Displace', step=1, minval=0)
ma_type = input.string('SMA', 'MA Type', options=['SMA', 'EMA', 'WMA', 'ALMA', 'VWMA', 'HMA', 'LSMA', 'SMMA', 'DEMA'])
alma_offset6 = input.float(0.85, 'ALMA Offset', step=0.01, minval=0, maxval=1)
alma_sigma6 = input.float(6, 'ALMA Sigma', step=0.01)
lsma_offset = input.int(0, 'LSMA Offset', step=1)
//Hilo Activator
float hilo = na
hi = ta.sma(high, len)
lo = ta.sma(low, len)
// Exponential Moving Average (EMA)
if ma_type == 'EMA'
hi := ta.ema(high, len)
lo := ta.ema(low, len)
// Weighted Moving Average (WMA)
if ma_type == 'WMA'
hi := ta.wma(high, len)
lo := ta.wma(low, len)
// Arnaud Legoux Moving Average (ALMA)
if ma_type == 'ALMA'
hi := ta.alma(high, len, alma_offset6, alma_sigma6)
lo := ta.alma(low, len, alma_offset6, alma_sigma6)
// Hull Moving Average (HMA)
if ma_type == 'HMA'
hi := ta.wma(2 * ta.wma(high, len / 2) - ta.wma(high, len), math.round(math.sqrt(len)))
lo := ta.wma(2 * ta.wma(low, len / 2) - ta.wma(low, len), math.round(math.sqrt(len)))
// Volume-weighted Moving Average (VWMA)
if ma_type == 'VWMA'
hi := ta.vwma(high, len)
lo := ta.vwma(low, len)
// Least Square Moving Average (LSMA)
if ma_type == 'LSMA'
hi := ta.linreg(high, len, lsma_offset)
lo := ta.linreg(low, len, lsma_offset)
// Smoothed Moving Average (SMMA)
if ma_type == 'SMMA'
hi := (hi[1] * (len - 1) + high) / len
lo := (lo[1] * (len - 1) + low) / len
// Double Exponential Moving Average (DEMA)
if ma_type == 'DEMA'
e1_high = ta.ema(high, len)
e1_low = ta.ema(low, len)
hi := 2 * e1_high - ta.ema(e1_high, len)
lo := 2 * e1_low - ta.ema(e1_low, len)
hilo := close > hi[displace] ? 1 : close < lo[displace] ? -1 : hilo[1]
ghla = hilo == -1 ? hi[displace] : lo[displace]
color = hilo == -1 ? color.red : color.green
//Alerts
buyCondition = hilo == 1 and hilo[1] == -1
sellCondition = hilo == -1 and hilo[1] == 1
if buyCondition
alert('Long', alert.freq_once_per_bar)
if sellCondition
alert('Short', alert.freq_once_per_bar)
//Plots
plot(ghla, color=color, style=plot.style_stepline)
/////////////////////////////////
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © veryfid
//@version=5
//Inputs
length = input.int(20, 'Upper Length', inline='length')
length2 = input.int(20, 'Lower Length', inline='length')
astart = input.int(2, 'Draw Upper Line From Pivot #', inline='pivot')
aend = input.int(0, 'To Pivot #', inline='pivot')
bstart = input.int(3, 'Draw Lower Line From Pivot #', inline='pivot2')
bend = input.int(0, 'To Pivot #', inline='pivot2')
csrc = input.bool(false, 'Use Custom Source?', inline='custom')
src = input.source(close, 'Select:', inline='custom')
color55 = input.string('Red/Green', 'Line Color:', options=['Red/Green', 'White', 'Yellow', 'Blue'], inline='custom2')
lwidth = input.string('1', 'Line Width:', options=['1', '2', '3', '4'], inline='custom2')
//Conditions
up = ta.pivothigh(csrc ? src : high, length, length)
dn = ta.pivotlow(csrc ? src : low, length2, length2)
n = bar_index
a1 = ta.valuewhen(not na(up), n, astart)
b1 = ta.valuewhen(not na(dn), n, bstart)
a2 = ta.valuewhen(not na(up), n, aend)
b2 = ta.valuewhen(not na(dn), n, bend)
//Colors
color1 = color.red
color2 = color.green
if color55 == 'White'
color1 := color.white
color2 := color.white
color2
if color55 == 'Yellow'
color1 := color.yellow
color2 := color.yellow
color2
if color55 == 'Blue'
color1 := color.blue
color2 := color.blue
color2
if color55 == 'Red/Green'
color1 := color.red
color2 := color.green
color2
//Width
width1 = 1
if lwidth == '1'
width1 := 1
width1
if lwidth == '2'
width1 := 2
width1
if lwidth == '3'
width1 := 3
width1
if lwidth == '4'
width1 := 4
width1
//Plots
line upper = line.new(n[n - a1 + length], up[n - a1], n[n - a2 + length], up[n - a2], extend=extend.right, color=color1, width=width1)
line lower = line.new(n[n - b1 + length2], dn[n - b1], n[n - b2 + length2], dn[n - b2], extend=extend.right, color=color2, width=width1)
line.delete(upper[1])
line.delete(lower[1])
///////////////////////////////
//@version=5
// INPUTS
Range = input.int(10, minval=2, title='Pivot Range')
ATRLength = input.int(10, minval=2, title='ATR Range')
ATRRange = ta.atr(ATRLength)
// PIVOTS
float PivotHigh = na
float PivotLow = na
PivotHigh := ta.pivothigh(Range, Range)
PivotLow := ta.pivotlow(Range, Range)
CountHigh = 0
CountHigh := PivotHigh[1] ? 0 : nz(CountHigh[1]) + 1
CountLow = 0
CountLow := PivotLow[1] ? 0 : nz(CountLow[1]) + 1
PivotHighPlot = 0.0
PivotHighPlot := PivotHigh[1] ? high[Range + 1] : PivotHighPlot[1]
PivotLowPlot = 0.0
PivotLowPlot := PivotLow[1] ? low[Range + 1] : PivotLowPlot[1]
// PLOTS
barcolor(hl2 + ATRRange > PivotHighPlot ? color.green : hl2 - ATRRange < PivotLowPlot ? color.red : color.yellow)
//////////////////////////////////////////////////
//@version=5
length33 = input(title='Length', defval=50)
offset33 = input(title='Offset', defval=0)
src33 = input(close, title='Source')
lsma33 = ta.linreg(src33, length33, offset33)
lsma233 = ta.linreg(lsma33, length33, offset33)
eq33 = lsma33 - lsma233
zlsma33 = lsma33 + eq33
zcolorchange33 = input(title='Change Color ?', defval=true)
zColor33 = zcolorchange33 ? zlsma33 > zlsma33[1] ? color.rgb(76, 175, 79, 100) : color.rgb(255, 82, 82, 100) : color.black
plot(zlsma33, title='50LAG', linewidth=1, color=zColor33)
//////////////////////////////////////////
//@version=5
sp = '***********'
var linefill[] a_lf = array.new <linefill> ()
cLineUp = input.color (color.new(color.lime, 25), '' , group= sp + 'lines' + sp + '*|*' + sp + '*fill', inline='line')
cLineDn = input.color (color.new( #FF0000 , 25), '' , group= sp + 'lines' + sp + '*|*' + sp + '*fill', inline='line')
cFillUp = input.color (color.new(color.lime, 75), '*|*', group= sp + 'lines' + sp + '*|*' + sp + '*fill', inline='line')
cFillDn = input.color (color.new( #FF0000 , 75), '' , group= sp + 'lines' + sp + '*|*' + sp + '*fill', inline='line')
lookback = input.int (125 , 'x bars back' , minval=0, maxval=125)
min = math.min (close, open) // lowest point of body
max = math.max (close, open) // highest point of body
mid = math.avg (close, open) // middle point of body
ixt = input.bool (true, '3', inline='e', group='extend lines')
iExt = input.string('both', '', options=[ 'none' , 'left' , 'right' , 'both' ], inline='e', group='extend lines')
aExt1 = array.from ( 'none' , 'left' , 'right' , 'both' )
aExt2 = array.from (extend.none, extend.left, extend.right, extend.both)
xt = array.get (aExt2 , array.indexof (aExt1, iExt))
//{
// B
//
// ◊
// ◊ ◊
// ◊ ◊
// ◊ ◊
// A ◊ ◊ C
// ◊ ◊
// ◊ ◊
// ◊ ◊
// ◊
//
// D
//}
if barstate.islast
while array.size(a_lf) > 0
fill = array.pop(a_lf)
line.delete(linefill.get_line1(fill))
line.delete(linefill.get_line1(fill))
linefill.delete (fill)
//
for i = 0 to lookback
cLn = close[i] > open[i] ? cLineUp : cLineDn
cFl = close[i] > open[i] ? cFillUp : cFillDn
Ax = bar_index - (i + 1), Ay = mid[i]
Bx = bar_index - (i ), By = max[i] + (max[i] - mid[i]) * (2 / 3)
Cx = bar_index - (i - 1), Cy = Ay
Dx = Bx , Dy = min[i] - (max[i] - mid[i]) * (2 / 3)
//
array.unshift(a_lf, linefill.new(
line.new(Ax, Ay, Bx, By, color= cLn),
line.new(Dx, Dy, Cx, Cy, color= cLn), color= cFl))
array.unshift(a_lf, linefill.new(
line.new(Bx, By, Cx, Cy, color= cLn),
line.new(Ax, Ay, Dx, Dy, color= cLn), color= na ))
idx = math.min(array.size(a_lf) -1, math.min(lookback, input.int(1, '', minval=0, maxval=125, inline='e', group='extend lines'))) * 2
//
if ixt
line.set_extend(linefill.get_line1(array.get(a_lf, array.size(a_lf) - idx -1)), xt)
line.set_extend(linefill.get_line2(array.get(a_lf, array.size(a_lf) - idx -2)), xt)
barcolor(color.new(color.blue, 100))
///////////////////////////////////////////////////////////////////////////////////////////////////////////
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Botnet101
//@version=5
// INPUTS
//{
_timeframe = input.string(defval='60' , title='Pivots Timeframe', options=['15', '30', '60', '240', 'D', 'W', 'M', '3M', '12M'])
colourBars = input.bool (defval=false, title='Colour Bars?' , group="Plot Settings")
showPivot = input.bool (defval=true , title='Show Pivot Points?', group="Plot Settings")
fillPlot = input.bool (defval=true , title='Fill plot?' , group="Plot Settings")
colour_bullish = input.color(defval=color.new(color.green, 70), title="Bullish", group="Colours")
colour_bearish = input.color(defval=color.new(color.red , 70), title="Bearish", group="Colours")
//}
// FUNCTIONS
//{
GetData(timeframe, data) => request.security(syminfo.tickerid, timeframe, data[1], lookahead=barmerge.lookahead_on)
GetColour (canShow, _colour) => canShow ? _colour : na
// Calculate Pivot Points
CalculatPivotPoint () =>
float dailyHigh = GetData(_timeframe, high )
float dailyLow = GetData(_timeframe, low )
float dailyClose = GetData(_timeframe, close)
(dailyHigh + dailyLow + dailyClose) / 3
//}
float pivotPoint = CalculatPivotPoint ()
color bias_colour = close > pivotPoint ? colour_bullish : colour_bearish
color cloud_colour = GetColour(fillPlot , bias_colour )
color pivotPoint_colour = GetColour(showPivot , color.new(bias_colour, 0))
color bar_colour = GetColour(colourBars, color.new(bias_colour, 0))
plot_close = plot(ohlc4 , title='Close', color=na , style=plot.style_stepline, editable=false )
plot_pivot = plot(pivotPoint, title='Pivot', color=pivotPoint_colour, style=plot.style_stepline, editable=true , linewidth=2)
fill (plot_pivot, plot_close, color=cloud_colour, editable=false)
//barcolor(bar_colour , editable=false)
//////////////////////////////////////
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © HoanGhetti
//@version=5
g_sr = 'Support and Resistance'
g_c = 'Conditions'
g_st = 'Styling'
t_r = 'Bar Confirmation: Generates alerts when candle closes. (1 Candle Later) \n\nHigh & Low: By default, the Break & Retest system uses the current close value to determine a condition, selecting High & Low will make the script utilize these two values instead of the close value. In return, the script won\'t repaint and will yield different results.'
t_rv = 'Whenever a potential retest is detected, the indicator knows that a retest is about to happen. In that given situation, this input grants the ability to raise the limit on how many bars are allowed to be actively checked while a potential retest event is active.\n\nExample, if you see the potential retest label, how many bars do you want that potential retest label to be active for to eventually confirm a retest? This system was implemented to prevent retest alerts from going off 10+ bars later from the potential retest point leading to inaccurate results.'
input_lookback = input.int(defval = 5, title = 'Lookback Range', minval = 1, tooltip = 'How many bars for a pivot event to occur.', group = g_sr)
input_retSince = input.int(defval = 2, title = 'Bars Since Breakout', minval = 1, tooltip = 'How many bars since breakout in order to detect a retest.', group = g_sr)
input_retValid = input.int(defval = 2, title = 'Retest Detection Limiter', minval = 1, tooltip = t_rv, group = g_sr)
input_breakout = input.bool(defval = false, title = 'Breakouts', group = g_c)
input_retest = input.bool(defval = false, title = 'Retests', group = g_c)
input_repType = input.string(defval = 'On', title = 'Repainting', options = ['On', 'Off: Candle Confirmation', 'Off: High & Low'], tooltip = t_r, group = g_c)
input_outL = input.string(defval = line.style_dotted, title = 'Outline', group = g_st, options = [line.style_dotted, line.style_dashed, line.style_solid])
input_extend = input.string(defval = extend.none, title = 'Extend', group = g_st, options = [extend.none, extend.right, extend.left, extend.both])
input_labelType = input.string(defval = 'Full', title = 'Label Type', options = ['Full', 'Simple'], group = g_st)
input_labelSize = input.string(defval = size.small, title = 'Label Size', options = [size.tiny, size.small, size.normal, size.large, size.huge], group = g_st)
input_plColor = input.color(defval = color.yellow, title = 'Support', inline = 'Color', group = g_st)
input_phColor = input.color(defval = color.yellow, title = 'Resistance', inline = 'Color', group = g_st)
input_override = input.bool(defval = false, title = 'Override Text Color ', inline = 'Override', group = g_st)
input_textColor = input.color(defval = color.white, title = '', inline = 'Override', group = g_st)
bb = input_lookback
rTon = input_repType == 'On'
rTcc = input_repType == 'Off: Candle Confirmation'
rThv = input_repType == 'Off: High & Low'
breakText = input_labelType == 'Simple' ? 'Br' : 'Break'
// Pivot Instance
pl = fixnan(ta.pivotlow(low, bb, bb))
ph = fixnan(ta.pivothigh(high, bb, bb))
// Box Height
s_yLoc = low[bb + 1] > low[bb - 1] ? low[bb - 1] : low[bb + 1]
r_yLoc = high[bb + 1] > high[bb - 1] ? high[bb + 1] : high[bb - 1]
//-----------------------------------------------------------------------------
// Functions
//-----------------------------------------------------------------------------
drawBox(condition, y1, y2, color) =>
var box drawBox = na
if condition
box.set_right(drawBox, bar_index - bb)
drawBox.set_extend(extend.none)
drawBox := box.new(bar_index - bb, y1, bar_index, y2, color, bgcolor = color.new(color, 90), border_style = input_outL, extend = input_extend)
[drawBox]
updateBox(box) =>
if barstate.isconfirmed
box.set_right(box, bar_index + 5)
breakLabel(y, color, style, textform) => label.new(bar_index, y, textform, textcolor = input_override ? input_textColor : color, style = style, color = color.new(color, 50), size = input_labelSize)
retestCondition(breakout, condition) => ta.barssince(na(breakout)) > input_retSince and condition
repaint(c1, c2, c3) => rTon ? c1 : rThv ? c2 : rTcc ? c3 : na
//-----------------------------------------------------------------------------
// Draw and Update Boxes
//-----------------------------------------------------------------------------
[sBox] = drawBox(ta.change(pl), s_yLoc, pl, input_plColor)
[rBox] = drawBox(ta.change(ph), ph, r_yLoc, input_phColor)
sTop = box.get_top(sBox), rTop = box.get_top(rBox)
sBot = box.get_bottom(sBox), rBot = box.get_bottom(rBox)
updateBox(sBox), updateBox(rBox)
//-----------------------------------------------------------------------------
// Breakout Event
//-----------------------------------------------------------------------------
var bool sBreak = na
var bool rBreak = na
cu = repaint(ta.crossunder(close, box.get_bottom(sBox)), ta.crossunder(low, box.get_bottom(sBox)), ta.crossunder(close, box.get_bottom(sBox)) and barstate.isconfirmed)
co = repaint(ta.crossover(close, box.get_top(rBox)), ta.crossover(high, box.get_top(rBox)), ta.crossover(close, box.get_top(rBox)) and barstate.isconfirmed)
switch
cu and na(sBreak) =>
sBreak := true
if input_breakout
breakLabel(sBot, input_plColor, label.style_label_upper_right, breakText)
co and na(rBreak) =>
rBreak := true
if input_breakout
breakLabel(rTop, input_phColor, label.style_label_lower_right, breakText)
if ta.change(pl)
if na(sBreak)
box.delete(sBox[1])
sBreak := na
if ta.change(ph)
if na(rBreak)
box.delete(rBox[1])
rBreak := na
//-----------------------------------------------------------------------------
// Retest Event
//-----------------------------------------------------------------------------
s1 = retestCondition(sBreak, high >= sTop and close <= sBot) // High is GOET top sBox value and the close price is LOET the bottom sBox value.
s2 = retestCondition(sBreak, high >= sTop and close >= sBot and close <= sTop) // High is GOET top sBox value and close is GOET the bottom sBox value and closing price is LOET the top sBox value.
s3 = retestCondition(sBreak, high >= sBot and high <= sTop) // High is in between the sBox.
s4 = retestCondition(sBreak, high >= sBot and high <= sTop and close < sBot) // High is in between the sBox, and the closing price is below.
r1 = retestCondition(rBreak, low <= rBot and close >= rTop) // Low is LOET bottom rBox value and close is GOET the top sBox value
r2 = retestCondition(rBreak, low <= rBot and close <= rTop and close >= rBot) // Low is LOET bottom rBox value and close is LOET the top sBox value and closing price is GOET the bottom rBox value.
r3 = retestCondition(rBreak, low <= rTop and low >= rBot) // Low is in between the rBox.
r4 = retestCondition(rBreak, low <= rTop and low >= rBot and close > rTop) // Low is in between the rBox, and the closing price is above.
retestEvent(c1, c2, c3, c4, y1, y2, col, style, pType) =>
if input_retest
var bool retOccurred = na
retActive = c1 or c2 or c3 or c4
retEvent = retActive and not retActive[1]
retValue = ta.valuewhen(retEvent, y1, 0)
if pType == 'ph' ? y2 < ta.valuewhen(retEvent, y2, 0) : y2 > ta.valuewhen(retEvent, y2, 0)
retEvent := retActive
// Must be reassigned here just in case the above if statement triggers.
retValue := ta.valuewhen(retEvent, y1, 0)
retSince = ta.barssince(retEvent)
var retLabel = array.new<label>()
if retEvent
retOccurred := na
array.push(retLabel, label.new(bar_index - retSince, y2[retSince], text = input_labelType == 'Simple' ? 'P. Re' : 'Potential Retest', color = color.new(col, 50), style = style, textcolor = input_override ? input_textColor : col, size = input_labelSize))
if array.size(retLabel) == 2
label.delete(array.first(retLabel))
array.shift(retLabel)
retConditions = pType == 'ph' ? repaint(close >= retValue, high >= retValue, close >= retValue and barstate.isconfirmed) : repaint(close <= retValue, low <= retValue, close <= retValue and barstate.isconfirmed)
retValid = ta.barssince(retEvent) > 0 and ta.barssince(retEvent) <= input_retValid and retConditions and not retOccurred
if retValid
label.new(bar_index - retSince, y2[retSince], text = input_labelType == 'Simple' ? 'Re' : 'Retest', color = color.new(col, 50), style = style, textcolor = input_override ? input_textColor : col, size = input_labelSize)
retOccurred := true
if retValid or ta.barssince(retEvent) > input_retValid
label.delete(array.first(retLabel))
if pType == 'ph' and ta.change(ph) and retOccurred
box.set_right(rBox[1], bar_index - retSince)
retOccurred := na
if pType == 'pl' and ta.change(pl) and retOccurred
box.set_right(sBox[1], bar_index - retSince)
retOccurred := na
[retValid, retEvent, retValue]
[rRetValid, rRetEvent] = retestEvent(r1, r2, r3, r4, high, low, input_phColor, label.style_label_upper_left, 'ph')
[sRetValid, sRetEvent] = retestEvent(s1, s2, s3, s4, low, high, input_plColor, label.style_label_lower_left, 'pl')
//-----------------------------------------------------------------------------
// Alerts
//-----------------------------------------------------------------------------
alertcondition(ta.change(pl), 'New Support Level')
alertcondition(ta.change(ph), 'New Resistance Level')
alertcondition(ta.barssince(na(sBreak)) == 1, 'Support Breakout')
alertcondition(ta.barssince(na(rBreak)) == 1, 'Resistance Breakout')
alertcondition(sRetValid, 'Support Retest')
alertcondition(sRetEvent, 'Potential Support Retest')
alertcondition(rRetValid, 'Resistance Retest')
alertcondition(rRetEvent, 'Potential Resistance Retest')
AllAlerts(condition, message) =>
if condition
alert(message)
AllAlerts(ta.change(pl), 'New Support Level')
AllAlerts(ta.change(ph), 'New Resistance Level')
AllAlerts(ta.barssince(na(sBreak)) == 1, 'Support Breakout')
AllAlerts(ta.barssince(na(rBreak)) == 1, 'Resistance Breakout')
AllAlerts(sRetValid, 'Support Retest')
AllAlerts(sRetEvent, 'Potential Support Retest')
AllAlerts(rRetValid, 'Resistance Retest')
AllAlerts(rRetEvent, 'Potential Resistance Retest')
///////////////////////////////////////////////////////////
PHP Code:
//@version=5
indicator('Risk-Adjusted Return Oscillator', shorttitle='*', scale=scale.left, overlay=true)
//@version=5
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Tooltips ///
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
t1 = "Determines the Length of Z-Score Assessment. Defaults to a 75 lookback period"
t2 = "Determines the length of the SMA if the user selects Show SMA. Default is 75, but for a more responsive SMA you can reduce it to 14. Optional."
t3 = "Shows the probability zones in colour."
t4 = "Will Display a summarized Z-Table."
t5 = "Display's the SMA."
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// User Inputs ///
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
len = input.int(20, "Lookback Length", tooltip=t1)
smalen = input.int(20, "SMA Length", tooltip=t2)
//probfill = input.bool(true, "Distribution Probaiblity Fills", tooltip=t3)
//showztable = input.bool(true, "Show Z-Table", tooltip=t4)
showsma = input.bool(true, "Show SMA", tooltip=t5)
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Z-Score/SMA Calculations ///
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
z = (close - ta.sma(close, len)) / ta.stdev(close, len)
cl_sma = ta.sma(close, len)
cl_sd = ta.stdev(close, len)
// SMA
var float z_sma = 0.0
if showsma
z_sma := ta.sma(z, smalen)
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Colours ///
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//color red = color.red
//color green = color.green
//color orange = color.orange
//color yellow = color.yellow
color labelcolor = color.new(color.white, 100)
//color gray = color.new(color.gray, 25)
//color white = color.white
// Colour for Probability Distribution
//color greenfill = color.new(color.green, 75)
//color yellowfill = color.new(color.yellow, 75)
//color redfill = color.new(color.red, 75)
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Logical Assessments ///
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
bool zero_one = z >= 0 and z < 1
bool one_two = z >= 1 and z < 2.01
bool two_three = z >= 2 and z < 3.01
bool three = z >= 3
bool zero = z >= 0.99 and z <= -0.99
bool neg_zero_one = z < 0 and z > -1
bool neg_one_two = z <= -1 and z > -2
bool neg_two_three = z <= -2 and z > -3
bool neg_three = z <= -3
falling = ta.falling(z_sma, 3)
rising = ta.rising(z_sma, 3)
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Plots ///
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//color z_color_plot = z > 0 ? green : z <= 0 ? red : orange
//plot(z, "Z-Score", color=z_color_plot, style=plot.style_area)
//plot(z_sma, "Z-SMA", color=showsma ? white : labelcolor, linewidth=2)
neutral = 0
onesd = 1
twosd = 2
threesd = 3
neg_onesd = -1
neg_twosd = -2
neg_threesd = -3
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Price Level Calculations ///
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
neutral_price = (cl_sma) + (0 * cl_sd)
onesd_price = (cl_sma) + (1 * cl_sd)
twosd_price = (cl_sma) + (2 * cl_sd)
threesd_price = (cl_sma) + (3 * cl_sd)
neg_onesd_price = (cl_sma) + (-1 * cl_sd)
neg_twosd_price = (cl_sma) + (-2 * cl_sd)
neg_threesd_price = (cl_sma) + (-3 * cl_sd)
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Line Plots ///
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
var label neutral_price_line = na
var label onesd_price_line = na
var label twosd_price_line = na
var label threesd_price_line = na
var label neg_onesd_price_line = na
var label neg_twosd_price_line = na
var label neg_threesd_price_line = na
if bar_index >= 75
label.delete(neutral_price_line)
label.delete(onesd_price_line)
label.delete(twosd_price_line)
label.delete(threesd_price_line)
label.delete(neg_onesd_price_line)
label.delete(neg_twosd_price_line)
label.delete(neg_threesd_price_line)
neutral_price_line := label.new(bar_index, y=neutral, text=str.tostring(math.round(neutral_price,2)), color=labelcolor, style=label.style_label_left, textcolor = color.white, size=size.normal, textalign = text.align_right)
onesd_price_line := label.new(bar_index - 5, onesd, str.tostring(math.round(onesd_price,2)), color=labelcolor, style=label.style_label_left, textcolor = color.white, size=size.normal, textalign = text.align_right)
twosd_price_line := label.new(bar_index - 5, twosd, str.tostring(math.round(twosd_price,2)), color=labelcolor, style=label.style_label_left, textcolor = color.white, size=size.normal, textalign = text.align_right)
threesd_price_line := label.new(bar_index - 5, threesd, str.tostring(math.round(threesd_price,2)), color=labelcolor, style=label.style_label_left, textcolor = color.white, size=size.normal, textalign = text.align_right)
neg_onesd_price_line := label.new(bar_index - 5, neg_onesd, str.tostring(math.round(neg_onesd_price,2)), color=labelcolor, style=label.style_label_left, textcolor = color.white, size=size.normal, textalign = text.align_right)
neg_twosd_price_line := label.new(bar_index - 5, neg_twosd, str.tostring(math.round(neg_twosd_price,2)), color=labelcolor, style=label.style_label_left, textcolor = color.white, size=size.normal, textalign = text.align_right)
neg_threesd_price_line := label.new(bar_index - 5, neg_threesd, str.tostring(math.round(neg_threesd_price,2)), color=labelcolor, style=label.style_label_left, textcolor = color.white, size=size.normal, textalign = text.align_right)
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © wbburgin
//@version=5
import jdehorty/KernelFunctions/2 as k
threshold = input.int(20,"Range Threshold",minval=0,maxval=100,
tooltip="Stochastic threshold (0-100) to identify ranging markets. A higher threshold will identify more ranges but will be slower at catching the trend.",
group="General")
l = input.int(14,"ATR Length",group="Stoch ATR")
lengthStoch = input.int(14, "Stochastic Length", minval=1,group="Stoch ATR")
lb = input.int(14,"Lookback",group="Stoch ATR",tooltip="The number of bars used for the estimation of the rational quadratic kernel.")
rw = input.int(1,"Relative Weighting",group="Stoch ATR")
smoothK = input.int(3, "Stochastic Smoothing", minval=1,group="Stoch ATR")
rsisrc = input.source(close,"RSI Source",group="RSI")
rsilen = input.int(14,"RSI Length",group="RSI")
stochatr(atr,smoothK,lookback,weighting,lengthStoch)=>
y = k.rationalQuadratic(ta.stoch(atr,atr,atr,lengthStoch),lookback,weighting,smoothK)
y
atr = ta.atr(l)
k = stochatr(atr,smoothK,lb,rw,lengthStoch)
rsi = ta.rsi(rsisrc,rsilen)
bull = math.sqrt(rsi * k)
bear = math.sqrt((100 - rsi) * k)
barcolor(bull > bear and math.min(bull,bear) > threshold ? color.lime : bear > bull and math.min(bull,bear) > threshold ? color.red : color.rgb(230, 226, 14))
/////////////////////////////////////////////////////////////////////////////////////////////////////
//@version=5
len22=input(1)
o22=ta.ema(open,len22)
c22=ta.ema(close,len22)
h22=ta.ema(high,len22)
l22=ta.ema(low,len22)
haclose = (o22+h22+l22+c22)/4
haopen = o22 // initialize haopen variable
haopen := na(haopen[1]) ? (o22 + c22)/2 : (haopen[1] + haclose[1]) / 2
hahigh = math.max (h22, math.max(haopen,haclose))
halow = math.min (l22, math.min(haopen,haclose))
len233=input(1)
o233=ta.ema(haopen, len233)
c233=ta.ema(haclose, len233)
h233=ta.ema(hahigh, len233)
l233=ta.ema(halow, len233)
// calculate Sancho indicator
sebastine = ((c233 / o233) - 1) * 200
// plot the Sebastine, signal, upper and lower bands
color_sebastine = sebastine >= 0 ? color.rgb(213, 228, 11) : color.red
plot(sebastine, color=color_sebastine, linewidth=2, title="TR",style=plot.style_cross)
hline(0, title="Zero Line", color=color.rgb(122, 121, 121, 52), linestyle=hline.style_dashed, linewidth=1)
//////////////////////////////
Yer İmleri