Heikin ++
Heikin ++
Heikin ++
///////////////////////////////////////
/// RSI ///
//////////////////////////////////////
color_bars = input(false, title='color bars?')
len_rsi = input(14,'RSI length')
xxx = (2 * len_rsi) - 1
timeframe_rsi = input.timeframe(defval='30', title='RSI timeframe')
timeframe_rsi2 = input.timeframe(defval='30', title='RSI timeframe 2')
ohlc = request.security(ha_t, timeframe_rsi, ta.ema(close1, xxx))
atr = request.security(ha_t, timeframe_rsi, ta.atr(xxx))
range_1 = atr
rsi_50 = ohlc
rsi_10 = rsi_50 - 4 * range_1
rsi_20 = rsi_50 - 3 * range_1
rsi_30 = rsi_50 - 2 * range_1
rsi_40 = rsi_50 - range_1
rsi_60 = rsi_50 + range_1
rsi_70 = rsi_50 + 2 * range_1
rsi_80 = rsi_50 + 3 * range_1
rsi_90 = rsi_50 + 4 * range_1
/// divergence
prd = input.int(defval=5, title='Pivot Period', minval=1, maxval=50)
source = input.string(defval='Close', title='Source for Pivot Points',
options=['Close', 'High/Low'])
searchdiv = input.string(defval='Regular/Hidden', title='Divergence Type',
options=['Regular', 'Hidden', 'Regular/Hidden'])
showindis = input.string(defval='First Letter', title='Show Indicator Names',
options=['Full', 'First Letter', 'Don\'t Show'])
showlimit = input.int(1, title='Minimum Number of Divergence', minval=1, maxval=11)
maxpp = input.int(defval=10, title='Maximum Pivot Points to Check', minval=1,
maxval=20)
maxbars = input.int(defval=150, title='Maximum Bars to Check', minval=5,
maxval=200)
shownum = input(defval=true, title='Show Divergence Number')
showlast = input(defval=false, title='Show Only Last Divergence')
dontconfirm = input(defval=false, title='Don\'t Wait for Confirmation')
showlines = input(defval=false, title='Show Divergence Lines')
showpivot = input(defval=false, title='Show Pivot Points')
calcmacd = input(defval=true, title='MACD')
calcmacda = input(defval=true, title='MACD Histogram')
calcrsi = input(defval=true, title='RSI')
calcstoc = input(defval=true, title='Stochastic')
calccci = input(defval=true, title='CCI')
calcmom = input(defval=true, title='Momentum')
calcobv = input(defval=true, title='OBV')
calcvwmacd = input(true, title='VWmacd')
calccmf = input(true, title='Chaikin Money Flow')
calcmfi = input(true, title='Money Flow Index')
calcext = input(false, title='Check External Indicator')
externalindi = input(defval=close, title='External Indicator')
pos_reg_div_col = input(defval=color.yellow, title='Positive Regular Divergence')
neg_reg_div_col = input(defval=color.navy, title='Negative Regular Divergence')
pos_hid_div_col = input(defval=color.lime, title='Positive Hidden Divergence')
neg_hid_div_col = input(defval=color.red, title='Negative Hidden Divergence')
pos_div_text_col = input(defval=color.black, title='Positive Divergence Text
Color')
neg_div_text_col = input(defval=color.white, title='Negative Divergence Text
Color')
reg_div_l_style_ = input.string(defval='Solid', title='Regular Divergence Line
Style', options=['Solid', 'Dashed', 'Dotted'])
hid_div_l_style_ = input.string(defval='Dashed', title='Hdden Divergence Line
Style', options=['Solid', 'Dashed', 'Dotted'])
reg_div_l_width = input.int(defval=2, title='Regular Divergence Line Width',
minval=1, maxval=5)
hid_div_l_width = input.int(defval=1, title='Hidden Divergence Line Width',
minval=1, maxval=5)
showmas = input.bool(defval=false, title='Show MAs 50 & 200', inline='ma12')
cma1col = input.color(defval=color.lime, title='', inline='ma12')
cma2col = input.color(defval=color.red, title='', inline='ma12')
// get indicators
rsi = ta.rsi(closeh, 14) // RSI
[macd, signal, deltamacd] = ta.macd(closeh, 12, 26, 9) // MACD
moment = ta.mom(closeh, 10) // Momentum
cci = ta.cci(closeh, 10) // CCI
Obv = ta.obv // OBV
stk = ta.sma(ta.stoch(closeh, highh, lowh, 14), 3) // Stoch
maFast = ta.vwma(closeh, 12) // volume weighted macd
maSlow = ta.vwma(closeh, 26)
vwmacd = maFast - maSlow
Cmfm = (closeh - lowh - (highh - closeh)) / (highh - lowh) // Chaikin money flow
Cmfv = Cmfm * volume
cmf = ta.sma(Cmfv, 21) / ta.sma(volume, 21)
Mfi = ta.mfi(closeh, 14) // Moneyt Flow Index
if arrived
divlen := len
break
divlen
if arrived
divlen := len
break
divlen
// check minimum number of divergence, if less than showlimit then delete all
divergence
total_div = 0
for x = 0 to array.size(all_divergences) - 1 by 1
total_div += math.round(math.sign(array.get(all_divergences, x)))
total_div
for x = 0 to 10 by 1
div_type = -1
for y = 0 to 3 by 1
if array.get(all_divergences, x * 4 + y) > 0 // any divergence?
div_type := y
if y % 2 == 1
dnumdiv_top += 1
top_label_col := array.get(div_colors, y)
top_label_col
if y % 2 == 0
dnumdiv_bottom += 1
bottom_label_col := array.get(div_colors, y)
bottom_label_col
if not array.includes(distances, array.get(all_divergences, x * 4 + y))
// line not exist ?
array.push(distances, array.get(all_divergences, x * 4 + y))
// draw labels
if showindis != 'Don\'t Show' or shownum
if shownum and dnumdiv_top > 0
divergence_text_top += str.tostring(dnumdiv_top)
divergence_text_top
if shownum and dnumdiv_bottom > 0
divergence_text_bottom += str.tostring(dnumdiv_bottom)
divergence_text_bottom
if divergence_text_top != ''
if divergence_text_bottom != ''
////////////////////////////////////
/// Cpr
///////////////////////////////////
[DayPivotLevel,DayBCPRlevel,DayTCPRlevel,DayR1level,DayS1level,DayR2level,DayS2leve
l,DayR3level,DayS3level] = request.security(ha_t, 'D',
[DayPivotLevel1[1],DayBCPRlevel1[1],DayTCPRlevel1[1],DayR1level1[1],DayS1level1[1],
DayR2level1[1],DayS2level1[1],DayR3level1[1],DayS3level1[1]], barmerge.gaps_off,
barmerge.lookahead_on)
///////////////////////////////////
//////////// MTF SnR Levels
/////////////////////////////////////
///////////////////////////////////
//////////// MTF SnR Levels
/////////////////////////////////////
signal_length = input.int(title='Signal Smoothing', minval=1, maxval=200, defval=9)
sma_signal = input(title='Simple MA (Signal Line)', defval=true)
////////////////////////////////
// ginley
///////////////////////////////
length = input.int(14, minval=1)
length1 = input.int(20, minval=1)
length2 = input.int(50, minval=1)
length21 = input.int(100, minval=1)
length3 = input.int(200, minval=1)
length4 = input.int(500, minval=1)
sourc = closeh1
mg = 0.0
mg := na(mg[1]) ? ta.ema(sourc, length) : mg[1] + (sourc - mg[1]) / (length *
math.pow(sourc/mg[1], 4))
mg1 = 0.0
mg1 := na(mg1[1]) ? ta.ema(sourc, length1) : mg1[1] + (sourc - mg1[1]) / (length1 *
math.pow(sourc/mg1[1], 4))
mg2 = 0.0
mg2 := na(mg2[1]) ? ta.ema(sourc, length2) : mg2[1] + (sourc - mg2[1]) / (length2 *
math.pow(sourc/mg2[1], 4))
mg21 = 0.0
mg21 := na(mg21[1]) ? ta.ema(sourc, length21) : mg21[1] + (sourc - mg21[1]) /
(length21 * math.pow(sourc/mg21[1], 4))
mg3 = 0.0
mg3 := na(mg3[1]) ? ta.ema(sourc, length3) : mg3[1] + (sourc - mg3[1]) / (length3 *
math.pow(sourc/mg3[1], 4))
mg4 = 0.0
mg4 := na(mg4[1]) ? ta.ema(sourc, length4) : mg4[1] + (sourc - mg4[1]) / (length4 *
math.pow(sourc/mg4[1], 4))
lwidth2 = 3
plot(mg, title='ginley 14', linewidth=lwidth2, style=plot.style_line,
color=color.new(color.red, 0))
plot(mg1, title='ginley 20', linewidth=lwidth2, style=plot.style_line,
color=color.new(color.orange, 0))
plot(mg2, title='ginley 50', linewidth=lwidth2, style=plot.style_line,
color=color.new(#49f343, 7))
plot(mg21, title='ginley 100', linewidth=lwidth2, style=plot.style_line,
color=color.new(#42eddc, 0))
plot(mg3, title='ginley 200', linewidth=lwidth2, style=plot.style_line,
color=color.new(#e84aa6, 0))
//plot(mg4, title='ginley 500', linewidth=lwidth2, style=plot.style_line,
color=color.new(color.white, 0))
/////////////////////////
/// gann
/////////////////////////
//GANN DEG //
pcsq = math.sqrt(pclose_d)
//GANN DEG //
//GANN MULTI//
//////////////////////////////////////////////////////////
//Gann SQ Levels //
//GANN LABEL//
ll_offset = bar_index+2
/////////////////END/////////////////////////////////
///////////////////////////
///// breakout
////////////////////////////
// A switch to control background coloring of the test period - Use for easy
visualization of backtest range and manual calculation of
// buy and hold (via measurement) if doing prior periods since value in Strategy
Tester extends to current date by default
testPeriodBackground = input(title='Color Background - Test Period?', defval=false)
testPeriodBackgroundColor = testPeriodBackground and time >= Start and time <=
Finish ? #00FF00 : na
//bgcolor(testPeriodBackgroundColor, transp=95)
// == FILTERING ==
// Inputs
useMaFilter = input(title='Use MA for Filtering?', defval=false)
maType = input.string(defval='EMA', options=['EMA', 'SMA'], title='MA Type For
Filtering')
maLength = input.int(defval=200, title='MA Period for Filtering', minval=1)
// Check to see if the useMaFilter check box is checked, this then inputs this
conditional "maFilterCheck" variable into the strategy entry
maFilterCheck = if useMaFilter == true
maFilter
else
0
// === PLOT SWING HIGH/LOW AND MOST RECENT LOW TO USE AS STOP LOSS EXIT POINT ===
// Inputs
//pvtLenL = input(3, minval=1, title="Pivot Length Left Hand Side") //use if
you want to change this to an input
//pvtLenR = input(3, minval=1, title="Pivot Length Right Hand Side") //use if
you want to change this to an input
pvtLenL = 3
pvtLenR = 3
// Count How many candles for current Pivot Level, If new reset.
counthi = request.security(symb,"30",ta.barssince(not na(pvthi)))
countlo = request.security(symb,"30",ta.barssince(not na(pvtlo)))
pvthis = fixnan(pvthi)
pvtlos = fixnan(pvtlo)
hipc = request.security(symb,"30",ta.change(pvthis)) != 0 ? na : color.maroon
lopc = request.security(symb,"30",ta.change(pvtlos)) != 0 ? na : color.green
// Stop Levels
stopBuff = input.float(0.0, minval=-2, title='Stop Loss Buffer off Swing Low (%)')
stopPerc = stopBuff * .01 // Turn stop buffer input into a percentage
stopLevel = request.security(symb,"30",ta.valuewhen(pvtlo_, lowh[pvtLenR], 0))
//Stop Level at Swing Low
stopLevel2 = stopLevel - stopLevel * stopPerc // Stop Level with user-defined
buffer to avoid stop hunts and give breathing room
//plot(stopLevel2, style=plot.style_line, color=color.new(color.orange, 50),
show_last=1, linewidth=1, trackprice=true)
buyLevel = request.security(symb,"30",ta.valuewhen(pvthi_, highh[pvtLenR], 0))
//Buy level at Swing High
buyLevel2 = buyLevel + buyLevel * stopPerc // Buy-stop level with user-defined
buffer to avoid stop hunts and give breathing room
//plot(buyLevel2, style=plot.style_line, color=color.new(color.aqua, 50),
show_last=1, linewidth=1, trackprice=true)
if buyStudy
label.new(x=bar_index, y=math.min(low1, low1[1]), text="B", color=color.blue,
textcolor=color.white, style=label.style_label_up, size=size.small)
if sellStudy
label.new(x=bar_index, y=math.max(high1, high1[1]), text="S",
color=color.fuchsia, textcolor=color.white, style=label.style_label_down,
size=size.small)
////////////////////////////////////////////
//// vwap week
///////////////////////////////////////////////
q = timenow - 7*86400000
f(x, y, z, a)=>
ini = time>=x and time[1]<x
src = hlc * volume1
vol = volume1
dev = hlc*hlc*volume1
src := ini?src:src+src[1]
vol := ini?vol:vol+vol[1]
dev := ini?dev:dev+dev[1]
vwap = src/vol
dev1 = math.sqrt(dev/vol-vwap*vwap)*y
dev2 = math.sqrt(dev/vol-vwap*vwap)*z
dev3 = math.sqrt(dev/vol-vwap*vwap)*a
[vwap, dev1, dev2, dev3]
vlwidth = 3
[vwap, dev1, dev2, dev3] = f(q, 1.0, 2.0, 3.0)
plot(vwap,color=color.white,linewidth=vlwidth)
plot(vwap+dev1,color=color.red,linewidth=vlwidth)
plot(vwap-dev1,color=color.red,linewidth=vlwidth)
plot(vwap+dev2,color=color.blue,linewidth=vlwidth)
plot(vwap-dev2,color=color.blue,linewidth=vlwidth)
plot(vwap+dev3,color=color.teal,linewidth=vlwidth)
plot(vwap-dev3,color=color.teal,linewidth=vlwidth)
upperBand = vwap+dev1
lowerBand = vwap-dev1
upperBand2 = vwap+dev2
lowerBand2 = vwap-dev2
upperBand3 = vwap+dev3
lowerBand3 = vwap-dev3
vol_ema = ta.ema(volume1, 20)
if volume1 > vol_ema and open1 < lowerBand and close1 > lowerBand
label.new(x=bar_index, y=math.max(low1, low1[1]), color=color.teal, text =
'VB',textcolor=color.white, style=label.style_label_up, size=size.tiny)
if volume1 > vol_ema and open1 < lowerBand2 and close1 > lowerBand2
label.new(x=bar_index, y=math.max(low1, low1[1]), color=color.teal, text =
'VB',textcolor=color.white, style=label.style_label_up, size=size.tiny)
if volume1 > vol_ema and open1 < lowerBand3 and close1 > lowerBand3
label.new(x=bar_index, y=math.max(low1, low1[1]), color=color.teal, text =
'VB',textcolor=color.white, style=label.style_label_up, size=size.tiny)
if volume1 > vol_ema and open1 < vwap and close1 > vwap
label.new(x=bar_index, y=math.max(low1, low1[1]), color=color.teal, text =
'VB',textcolor=color.white, style=label.style_label_up, size=size.tiny)
if volume1 > vol_ema and open1 > lowerBand and close1 < lowerBand
label.new(x=bar_index, y=math.max(high1, high1[1]), color=color.orange, text =
'VB',textcolor=color.white, style=label.style_label_down, size=size.tiny)
if volume1 > vol_ema and open1 > lowerBand2 and close1 < lowerBand2
label.new(x=bar_index, y=math.max(high1, high1[1]), color=color.orange, text =
'VB',textcolor=color.white, style=label.style_label_down, size=size.tiny)
if volume1 > vol_ema and open1 > lowerBand3 and close1 < lowerBand3
label.new(x=bar_index, y=math.max(high1, high1[1]), color=color.orange, text =
'VB',textcolor=color.white, style=label.style_label_down, size=size.tiny)
if volume1 > vol_ema and open1 > vwap and close1 < vwap
label.new(x=bar_index, y=math.max(high1, high1[1]), color=color.orange, text =
'VB',textcolor=color.white, style=label.style_label_down, size=size.tiny)