Kve - All
Kve - All
Kve - All
// Table Options
Showema = input.bool(false, 'SHOW EMA ON/OFF ', inline = 'overlayLine1',
group = 'K2024')
ShowSmartNLN = input.bool(false, 'Trend Cloud ON/OFF ', inline =
'overlayLine1', group = 'K2024')
ShowSmartema = input.bool(false, 'Trend EMA ON/OFF ', inline =
'overlayLine1', group = 'K2024')
// - INPUTS START
// Fast MA - type, source, length
showAvgs = input(true, title='Show Moving Average Lines')
type1 = input.string(defval='EMA', title='Fast MA Type: ', options=['SMA', 'EMA',
'WMA', 'VWMA', 'SMMA', 'DEMA', 'TEMA', 'HullMA', 'ZEMA', 'TMA', 'SSMA'])
len1 = input.int(defval=16, title='Fast - Length', minval=1)
gamma1 = 0.33
// Medium Fast MA - type, source, length
type2 = input.string(defval='EMA', title='Medium MA Type: ', options=['SMA', 'EMA',
'WMA', 'VWMA', 'SMMA', 'DEMA', 'TEMA', 'HullMA', 'ZEMA', 'TMA', 'SSMA'])
len2 = input.int(defval=21, title='Medium - Length', minval=1)
gamma2 = 0.55
// Slow MA - type, source, length
type3 = input.string(defval='EMA', title='Slow MA Type: ', options=['SMA', 'EMA',
'WMA', 'VWMA', 'SMMA', 'DEMA', 'TEMA', 'HullMA', 'ZEMA', 'TMA', 'SSMA'])
len3 = input.int(defval=26, title='Slow Length', minval=1)
gamma3 = 0.77
//
// QQE rsi Length, Smoothing, fast ATR factor, source
RSILen = input(14, title='RSI Length')
SF = input(8, title='RSI Smoothing Factor')
QQEfactor = input(5.0, title='Fast QQE Factor')
threshhold = input(10, title='RSI Threshhold')
//
sQQEx = input(false, title='Show QQE Signal crosses')
sQQEz = input(false, title='Show QQE Zero crosses')
sQQEc = input(false, title='Show QQE Thresh Hold Channel Exits')
//
tradeSignal = input.string('XC', title='Select which QQE signal to Buy/Sell',
options=['XC', 'XQ', 'XZ'])
closeSignal = input.string('XQ', title='Select which QQE signal to Close Order',
options=['XC', 'XQ', 'XZ'])
//
xfilter = input(false, title='Filter XQ Buy/Sell Orders by Threshold')
filter = input(false, title='Use Moving Average Filter')
dfilter = input(false, title='Use Trend Directional Filter')
ufirst = input(false, title='Only Alert First Buy/Sell in a new Trend')
RSIsrc = input(close, title='Source')
///////////////////////////////////////////////
//* Backtesting Period Selector | Component *//
///////////////////////////////////////////////
//* https://www.tradingview.com/script/eCC1cvxQ-Backtesting-Period-Selector-
Component *//
//* https://www.tradingview.com/u/pbergden/ *//
//* Modifications made by JustUncleL*//
// - INPUTS END
colorRED = input.color(color.new(#ff5252, 0))
colorAQUA = input.color(color.new(#00bcd4,0))
colorLIME = input.color(color.new(#4caf50, 0))
colorRED1 = input.color(color.new(#ff5252, 90))
colorAQUA1 = input.color(color.new(#00bcd4,90))
colorLIME1 = input.color(color.new(#4caf50,90))
//gold = #FFD700
//AQUA = #00FFFFFF
//BLUE = #0000FFFF
//RED = #FF0000FF
//LIME = #00FF00FF
//GRAY = #808080FF
// - FUNCTIONS
// SuperSmoother filter
// © 2013 John F. Ehlers
variant_supersmoother(src, len) =>
a1 = math.exp(-1.414 * 3.14159 / len)
b1 = 2 * a1 * math.cos(1.414 * 3.14159 / len)
c2 = b1
c3 = -a1 * a1
c1 = 1 - c2 - c3
v9 = 0.0
v9 := c1 * (src + nz(src[1])) / 2 + c2 * nz(v9[1]) + c3 * nz(v9[2])
v9
//calc Laguerre
variant_lag(p, g) =>
L0 = 0.0
L1 = 0.0
L2 = 0.0
L3 = 0.0
L0 := (1 - g) * p + g * nz(L0[1])
L1 := -g * L0 + nz(L0[1]) + g * nz(L1[1])
L2 := -g * L1 + nz(L1[1]) + g * nz(L2[1])
L3 := -g * L2 + nz(L2[1]) + g * nz(L3[1])
f = (L0 + 2 * L1 + 2 * L2 + L3) / 6
f
// - /variant
// If have anchor specified, calculate the base multiplier, base on time in mins
//mult = isintraday ? anchor==0 or interval<=0 or interval>=anchor or anchor>1440?
1 : round(anchor/interval) : 1
//mult := not isintraday? 1 : mult // Only available Daily or less
// - FUNCTIONS END
// - SERIES VARIABLES
// MA's
ma_fast = variant(type1, srcclose, len1, gamma1)
ma_medium = variant(type2, srcclose, len2, gamma2)
ma_slow = variant(type3, srcclose, len3, gamma3)
// MA's
ma_fast_alt = variant(type1, srcclose, len1 * mult, gamma1)
ma_medium_alt = variant(type2, srcclose, len2 * mult, gamma2)
ma_slow_alt = variant(type3, srcclose, len3 * mult, gamma3)
//
// Check Filtering.
QQEflong = mult == 1 ? (not filter or srcclose > ma_medium and ma_medium > ma_slow
and ma_fast > ma_medium) and (not dfilter or direction > 0) : (not filter or
ma_medium > ma_medium_alt and srcclose > ma_fast and ma_fast > ma_medium) and (not
dfilter or direction > 0 and altDirection > 0 and srcclose > ma_medium)
QQEfshort = mult == 1 ? (not filter or srcclose < ma_medium and ma_medium < ma_slow
and ma_fast < ma_medium) and (not dfilter or direction < 0) : (not filter or
ma_medium < ma_medium_alt and srcclose < ma_fast and ma_fast < ma_medium) and (not
dfilter or direction < 0 and altDirection < 0 and srcclose < ma_medium)
// Make sure Buy/Sell are non-repaint and occur after close signal.
buy_ := tradeSignal == 'XC' ? QQEclong[1] == 1 and QQEflong[1] ? buy_ + 1 : 0 :
tradeSignal == 'XQ' ? QQExlong[1] == 1 and QQEflong[1] and QQExfilter[1] ? buy_ + 1
: 0 : tradeSignal == 'XZ' ? QQEzlong[1] == 1 and QQEflong[1] ? buy_ + 1 : 0 : 0
sell_ := tradeSignal == 'XC' ? QQEcshort[1] == 1 and QQEfshort[1] ? sell_ + 1 : 0 :
tradeSignal == 'XQ' ? QQExshort[1] == 1 and QQEfshort[1] and QQExfilter[1] ? sell_
+ 1 : 0 : tradeSignal == 'XZ' ? QQEzshort[1] == 1 and QQEfshort[1] ? sell_ + 1 :
0 : 0
//
// Find the first Buy/Sell in trend swing.
Buy = 0
Buy := nz(Buy[1])
Sell = 0
Sell := nz(Sell[1])
Buy := sell_ > 0 ? 0 : buy_ == 1 or Buy > 0 ? Buy + 1 : Buy
Sell := buy_ > 0 ? 0 : sell_ == 1 or Sell > 0 ? Sell + 1 : Sell
tradestate = 0
tradestate := nz(tradestate[1])
tradestate := tradestate == 0 ? buy == 1 ? 1 : sell == 1 ? 2 : 0 : tradestate == 1
and closeLong == 1 or tradestate == 2 and closeShort == 1 ? 0 : tradestate
// - PLOTTING
// Ma's
tcolor = ShowSmartema?( direction < 0 ? colorRED : colorLIME ):na
tcolor1 = ShowSmartema?( direction < 0 ? colorRED1 : colorLIME1 ):na
ma1 = plot(showAvgs ? ma_fast : na, title='MA Fast', color=tcolor, linewidth=1,
transp=50)
ma2 = plot(showAvgs ? ma_medium : na, title='MA Medium Fast', color=tcolor,
linewidth=2, transp=50)
ma3 = plot(showAvgs ? ma_slow : na, title='MA Slow', color=tcolor, linewidth=1,
transp=50)
fill(ma1, ma3, color=tcolor1, transp=10)
// Ma's
altTcolor = ShowSmartema?(altDirection < 0 ? colorRED : colorAQUA):na
altTcolor1 = ShowSmartema?(altDirection < 0 ? colorRED1 : colorAQUA1):na
ma4 = plot(showAvgs and mult > 1 ? ma_fast_alt : na, title='MA Fast',
color=altTcolor, linewidth=1, transp=50)
ma5 = plot(showAvgs and mult > 1 ? ma_medium_alt : na, title='MA Medium Fast',
color=altTcolor, linewidth=2, transp=50)
ma6 = plot(showAvgs and mult > 1 ? ma_slow_alt : na, title='MA Slow',
color=altTcolor, linewidth=1, transp=50)
fill(ma4, ma6, altTcolor1, transp=10)
//EOF
///////////////////////////////////////////////////////////////////////////////////
//////////////
//indicator("LNL Trend System", shorttitle = "LNL Trend System", overlay=true)
// Inputs
BullishDMI = (high - high[1]) > (low[1] - low) and (high - high[1]) > 0 ? (high -
high[1]) : 0
BearishDMI = (low[1] - low) > (high - high[1]) and (low[1] - low) > 0 ? (low[1] -
low) : 0
DMIUp = 100 * ta.rma(BullishDMI,14) / ta.rma(ta.tr(true),14)
DMIDown = 100 * ta.rma(BearishDMI,14) / ta.rma(ta.tr(true),14)
ADXx = (DMIUp + DMIDown) > 0 ? 100 * math.abs(DMIUp - DMIDown) / (DMIUp +
DMIDown) : na
ADX = ta.rma(ADXx,14)
ColorBars = ShowTrendBars and (DMIUp > DMIDown and ADX > 20) ? TrendBarBullish :
ShowTrendBars and (DMIUp < DMIDown and ADX > 20) ? TrendBarBearish :
ShowTrendBars ? TrendBarNeutral : na
barcolor(color = ColorBars, editable = false)
ema8 = ta.vwma(close, 8)
ema13 = ta.vwma(close, 13)
ema21 = ta.vwma(close, 21)
ema34 = ta.vwma(close, 34)
emaup = ema8 > ema13 and ema13 > ema21 and ema21 > ema34
emadn = ema8 < ema13 and ema13 < ema21 and ema21 < ema34
TimeFrameA =
timeframe.period == '1' ? '5' :
timeframe.period == '2' ? '5' :
timeframe.period == '3' ? '5' :
timeframe.period == '4' ? '5' :
timeframe.period == '5' ? '30' :
timeframe.period == '10' ? '30' :
timeframe.period == '15' ? '30' :
timeframe.period == '30' ? '240' :
timeframe.period == '60' ? '240' :
timeframe.period == '120' ? '240' :
timeframe.period == '180' ? 'D' :
timeframe.period == '240' ? 'D' :
timeframe.period == 'D' ? 'W' :
timeframe.period == 'W' ? 'M' :
timeframe.period == 'M' ? '3M' : timeframe.period
// Trend Clouds
////////////ShowSmartTrail//////////////
///////////////////////////////////
TrendUp = Up68
TrendDown = Dn68
Trendtrade = 1
ex = 0.0
ex := ta.crossover(Trendtrade, 0) ? norm_h : ta.crossunder(Trendtrade, 0) ?
norm_l : Trendtrade == 1 ? math.max(ex[1], norm_h) : Trendtrade == -1 ?
math.min(ex[1], norm_l) : ex[1]
//}
//}
fib1Level = 61.8
fib2Level = 78.6
fib3Level = 88.6
f1 = ex + (trail - ex) * fib1Level / 100
f2 = ex + (trail - ex) * fib2Level / 100
f3 = ex + (trail - ex) * fib3Level / 100
l100 = trail + 0
/////////////////////////////
// Integración de RSI
// Señal de trading
var bool buySignal = na
var bool sellSignal = na
// Plot en el gráfico
plotshape( ShowBS ?buySignal:na, title="Buy Signal", location=location.belowbar,
color=color.green, style=shape.triangleup, size=size.small, text="Buy",
textcolor=color.rgb(255, 0, 0))
plotshape( ShowBS ?sellSignal:na, title="Sell Signal", location=location.abovebar,
color=color.red, style=shape.triangledown, size=size.small, text="Sell",
textcolor=color.rgb(255, 0, 0))
////////////////////////////
////////////////// REV ZONES BB ////////////////////
//
===================================================================================
============================================
// EzAlgo SR
/////////////////////////////////////////////////////////////////////
// INDICATOR SETTINGS
swing_length = input.int(10, title = 'Swing High/Low Length', group = "👉 SUPPLY AND
DEMAND", minval = 1, maxval = 50)
history_of_demand_to_keep = input.int(20, title = 'History To Keep',group = "👉
SUPPLY AND DEMAND" ,minval = 5, maxval = 50)
box_width = input.float(7, title = 'Supply/Demand Box Width', group = "👉 SUPPLY AND
DEMAND", minval = 1, maxval = 10, step = 0.5)
//
//END SETTINGS
//
//
//FUNCTIONS
//
else if swing_type == -1
if array.get(array, 0) >= array.get(array, 1)
label_text := 'HL'
else
label_text := 'LL'
label.new(bar_index - swing_length, array.get(array,0), text = label_text,
style=label.style_label_up, textcolor = swing_type_color, color =
color.new(swing_type_color, 100), size = size.tiny)
atr_threshold = atr7 * 2
okay_to_draw = true
for i = 0 to array.size(box_array) - 1
top = box.get_top(array.get(box_array, i))
bottom = box.get_bottom(array.get(box_array, i))
poi = (top + bottom) / 2
if box_type == 1
box_top := array.get(value_array, 0)
box_bottom := box_top - atr_buffer
poi := (box_top + box_bottom) / 2
else if box_type == -1
box_bottom := array.get(value_array, 0)
box_top := box_bottom + atr_buffer
poi := (box_top + box_bottom) / 2
//delete oldest box, and then create a new box and add it to the array
if box_type == 1 and okay_to_draw
box.delete( array.get(box_array, array.size(box_array) - 1) )
f_array_add_pop(box_array, box.new( left = box_left, top = box_top, right =
box_right, bottom = box_bottom, border_color = supply_outline_color,
bgcolor = ShowSR?supply_color:na, extend = extend.right, text = 'SELL
ZONE', text_halign = text.align_center, text_valign = text.align_center, text_color
= ShowSR?poi_label_color:na, text_size = size.small, xloc = xloc.bar_index))
if zone_type == 1
for i = 0 to array.size(box_array) - 1
level_to_break = box.get_top(array.get(box_array,i))
// if ta.crossover(close, level_to_break)
if close >= level_to_break
copied_box = box.copy(array.get(box_array,i))
f_array_add_pop(bos_array, copied_box)
mid = (box.get_top(array.get(box_array,i)) +
box.get_bottom(array.get(box_array,i))) / 2
box.set_top(array.get(bos_array,0), mid)
box.set_bottom(array.get(bos_array,0), mid)
box.set_extend( array.get(bos_array,0), extend.none)
box.set_right( array.get(bos_array,0), bar_index)
box.set_text( array.get(bos_array,0), 'BOS' )
box.set_text_color( array.get(bos_array,0), bos_label_color)
box.set_text_size( array.get(bos_array,0), size.small)
box.set_text_halign( array.get(bos_array,0), text.align_center)
box.set_text_valign( array.get(bos_array,0), text.align_center)
box.delete(array.get(box_array, i))
box.delete(array.get(label_array, i))
if zone_type == -1
for i = 0 to array.size(box_array) - 1
level_to_break = box.get_bottom(array.get(box_array,i))
// if ta.crossunder(close, level_to_break)
if close <= level_to_break
copied_box = box.copy(array.get(box_array,i))
f_array_add_pop(bos_array, copied_box)
mid = (box.get_top(array.get(box_array,i)) +
box.get_bottom(array.get(box_array,i))) / 2
box.set_top(array.get(bos_array,0), mid)
box.set_bottom(array.get(bos_array,0), mid)
box.set_extend( array.get(bos_array,0), extend.none)
box.set_right( array.get(bos_array,0), bar_index)
box.set_text( array.get(bos_array,0), 'BOS' )
box.set_text_color( array.get(bos_array,0), bos_label_color)
box.set_text_size( array.get(bos_array,0), size.small)
box.set_text_halign( array.get(bos_array,0), text.align_center)
box.set_text_valign( array.get(bos_array,0), text.align_center)
box.delete(array.get(box_array, i))
box.delete(array.get(label_array, i))
for i = 0 to array.size(box_array) - 1
box.set_right(array.get(box_array, i), bar_index + 100)
//
//END FUNCTIONS
//
//
//CALCULATIONS
//
// CALCULATE ATR
atr7 = ta.atr(50)
f_extend_box_endpoint(current_supply_box)
f_extend_box_endpoint(current_demand_box)
//ZIG ZAG
h = ta.highest(high, swing_length * 2 + 1)
l = ta.lowest(low, swing_length * 2 + 1)
f_isMin(len) =>
l == low[len]
f_isMax(len) =>
h == high[len]
f_drawLine() =>
_li_color = show_zigzag ? zigzag_color : color.new(#ffffff,100)
line.new(timeHigh - swing_length, lastHigh, timeLow - swing_length, lastLow,
xloc.bar_index, color=_li_color, width=2)
if dirUp
if f_isMin(swing_length) and low[swing_length] < lastLow
lastLow := low[swing_length]
timeLow := bar_index
line.delete(li)
li := f_drawLine()
li
if not dirUp
if f_isMax(swing_length) and high[swing_length] > lastHigh
lastHigh := high[swing_length]
timeHigh := bar_index
line.delete(li)
li := f_drawLine()
li
if f_isMin(swing_length) and low[swing_length] < lastHigh
lastLow := low[swing_length]
timeLow := bar_index
dirUp := true
li := f_drawLine()
if f_isMax(swing_length) and high[swing_length] > lastLow
lastHigh := high[swing_length]
timeHigh := bar_index
dirUp := false
li := f_drawLine()
li
// if barstate.islast
// label.new(x = bar_index + 10, y = close[1], text =
str.tostring( array.size(current_supply_poi) ))
// label.new(x = bar_index + 20, y = close[1], text =
str.tostring( box.get_bottom( array.get(current_supply_box, 0))))
// label.new(x = bar_index + 30, y = close[1], text =
str.tostring( box.get_bottom( array.get(current_supply_box, 1))))
// label.new(x = bar_index + 40, y = close[1], text =
str.tostring( box.get_bottom( array.get(current_supply_box, 2))))
// label.new(x = bar_index + 50, y = close[1], text =
str.tostring( box.get_bottom( array.get(current_supply_box, 3))))
// label.new(x = bar_index + 60, y = close[1], text =
str.tostring( box.get_bottom( array.get(current_supply_box, 4))))
// # ============================[SESSIONS]============================ #
//Session A
show_sesa = input(true, '', inline = 'sesa', group = 'Session A')
sesa_txt = input('New York', '', inline = 'sesa', group = 'Session A')
sesa_ses = input.session('1300-2200', '', inline = 'sesa', group = 'Session A')
sesa_css = input.color(#ff5e0049, '', inline = 'sesa', group = 'Session A')
//Session B
show_sesb = input(true, '', inline = 'sesb', group = 'Session B')
sesb_txt = input('London', '', inline = 'sesb', group = 'Session B')
sesb_ses = input.session('0700-1600', '', inline = 'sesb', group = 'Session B')
sesb_css = input.color(#2156f349, '', inline = 'sesb', group = 'Session B')
//Session C
show_sesc = input(true, '', inline = 'sesc', group = 'Session C')
sesc_txt = input('Tokyo', '', inline = 'sesc', group = 'Session C')
sesc_ses = input.session('0000-0900', '', inline = 'sesc', group = 'Session C')
sesc_css = input.color(#00000049, '', inline = 'sesc', group = 'Session C')
//Timezones
tz_incr = input.int(0, 'UTC (+/-)', group = 'Timezone')
use_exchange = input(false, 'Use Exchange Timezone', group = 'Timezone')
//Ranges Options
bg_transp = input.float(90, 'Background Borders', group = 'Ranges Settings')
show_outline = input(true, 'Range Outline', group = 'Ranges Settings')
show_txt = input(true, 'Range Label', group = 'Ranges Settings')
//-----------------------------------------------------------------------------}
//Functions
//-----------------------------------------------------------------------------{
n = bar_index
sma
var float y1 = na
var float y2 = na
var float stdev = na
var float r2 = na
//Session Vwap
get_vwap(session) =>
var float num = na
var float den = na
[num, den]
//Set line
set_line(session, y1, y2, session_css)=>
var line tl = na
if show_txt
lbl := label.new(t, max, session_name
, xloc = xloc.bar_time
, textcolor = session_css
, style = label.style_label_down
, color = color.new(color.white, 100)
, size = size.tiny)
if session and session == session[1]
max := math.max(high, max)
min := math.min(low, min)
box.set_top(bx, max)
box.set_rightbottom(bx, n, min)
if show_txt
label.set_xy(lbl, int(math.avg(t, time)), max)
//-----------------------------------------------------------------------------}
//Sessions
//-----------------------------------------------------------------------------{
tf = timeframe.period
//-----------------------------------------------------------------------------}
//Overlays
//-----------------------------------------------------------------------------{
var float max_sesa = na
var float min_sesa = na
var float max_sesb = na
var float min_sesb = na
var float max_sesc = na
var float min_sesc = na
var float max_sesd = na
var float min_sesd = na
//Ranges
if showSessions? (show_sesa and sesa_range):na
[max, min] = get_range(is_sesa, sesa_txt, sesa_css)
max_sesa := max
min_sesa := min
//-----------------------------------------------------------------------------{
//Plot max/min
plot(showSessions and sesa_maxmin ? max_sesa : na, 'Session A Maximum', sesa_css,
1, plot.style_linebr,editable = false)
plot(showSessions and sesa_maxmin ? min_sesa : na, 'Session A Minimum', sesa_css,
1, plot.style_linebr,editable = false)
// 0. Inputs
// 1. Types
// 2. Switches
// 3. Variables and arrays
// 4. Custom Functions
// 5. Execution
// 6. Constructs
///////////////////////////////////////////////////////////////////////
// This source code is subject to the terms of the Mozilla Public License 2.0 at
https://mozilla.org/MPL/2.0/
// © btc_charlie / @TheParagonGrp
//@version=5
//indicator('Ema Trend Scanner', overlay=true)
// Variables
var ok = 0
var countBuy = 0
var countSell = 0
srck = input(close, title='OHLC Type')
i_fastEMA = input(12, title='Fast EMA')
i_slowEMA = input(25, title='Slow EMA')
i_defEMA = input(25, title='Consolidated EMA')
// Define EMAs
v_fastEMA = ta.ema(srck, i_fastEMA)
v_slowEMA = ta.ema(srck, i_slowEMA)
v_biasEMA = ta.ema(srck, i_defEMA)
// Plot EMAs
plot(Showema?(i_bothEMAs ? v_biasEMA:na):na, color=emaColor, linewidth=3,
title='Consolidated EMA')
plot(Showema?(i_bothEMAs ? v_fastEMA : na):na, title='Fast EMA', color=emaColor)
plot(Showema?(i_bothEMAs ? v_slowEMA : na):na, title='Slow EMA', color=emaColor)
if buyk
countBuy += 1
countBuy
if buyk
countSell := 0
countSell
if sellk
countSell += 1
countSell
if sellk
countBuy := 0
countBuy
buysignal = countBuy < 2 and countBuy > 0 and countSell < 1 and buyk and not
buyk[1]
sellsignal = countSell > 0 and countSell < 2 and countBuy < 1 and sellk and not
sellk[1]
// Plot Bull/Bear
////////////////////////////////
emaUpColor() =>
hlc3 >= usedEma
emaDownColor() =>
hlc3 < usedEma
col = hlc3 >= usedEma ? color.lime : hlc3 < usedEma ? color.red : color.white
emaDownColor_1 = emaDownColor()
//barcolor(emaUpColor() ? color.lime : emaDownColor_1 ? color.red : na)
plot(Showema?(shema and usedEma ? usedEma : na):na, title='EMA',
style=plot.style_line, linewidth=3, color=col)