Neural Network
Neural Network
////////////////////////////////////////////////////////////////////////////////
//TREND INDICATORS▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼
//Trend EMA
tttradetrend = "Only place BUY or SELL orders with the direction of the Trend EMA."
tradetrendoption = input(false, title="Only Tade with Trend", tooltip=tttradetrend)
len111 = input(defval=200, minval=0, maxval=2000, title="Trend EMA Length")
src111 = close
out111 = ema(src111, len111)
ma111 = plot(out111, title="EMA 200", linewidth=2, color=color.blue, offset=0)
mabuy = out111 > out111[1]
masell = out111 < out111[1]
//5 EMAs////////////////////////////////////////////////////////////////////////
len1 = 9
src1 = close
out1 = ema(src1, len1)
ema1color = (out1 > out1[1] ? #00bcd4 : #e91e63)
ema1 = plot(out1, title="EMA 9", linewidth=3, color=color.new(ema1color, 50),
offset=0, display=display.none)
fill(price, ema1, title="EMA 9 Fill", color=color.new(ema1color, 90),
editable=true)
len2 = 21
src2 = close
out2 = ema(src2, len2)
ema2color = (out2 > out2[1] ? #00bcd4 : #e91e63)
ema2 = plot(out2, title="EMA 21", linewidth=3, color=color.new(ema2color, 50),
offset=0, display=display.none)
fill(price, ema2, title="EMA 21 Fill", color=color.new(ema2color, 90),
editable=true)
len3 = 55
src3 = close
out3 = ema(src3, len3)
ema3color = (out3 > out3[1] ? #00bcd4 : #e91e63)
ema3 = plot(out3, title="EMA 55", linewidth=3, color=color.new(ema3color, 50),
offset=0, display=display.none)
fill(price, ema3, title="EMA 55 Fill", color=color.new(ema3color, 90),
editable=true)
len4 = 100
src4 = close
out4 = ema(src4, len4)
ema4color = (out4 > out4[1] ? #00bcd4 : #e91e63)
ema4 = plot(out4, title="EMA 100", linewidth=3, color=color.new(ema4color, 50),
offset=0, display=display.none)
fill(price, ema4, title="EMA 100 Fill", color=color.new(ema4color, 90),
editable=true)
len5 = 200
src5 = close
out5 = ema(src5, len5)
ema5color = (out5 > out5[1] ? #00bcd4 : #e91e63)
ema5 = plot(out5, title="EMA 200", linewidth=3, color=color.new(ema5color, 50),
offset=0, display=display.none)
fill(price, ema5, title="EMA 200 Fill", color=color.new(ema5color, 90),
editable=true)
//Supertrend////////////////////////////////////////////////////////////////////
atrPeriod = 10
factor = 3
[supertrend, direction] = supertrend(factor, atrPeriod)
bodyMiddle = plot((open + close) / 2, display=display.none, title="Body Middle
Line")
uptrend = direction < 0 and direction[1] > 0[1] ? supertrend : na
downtrend = direction > 0 and direction[1] < 0[1] ? supertrend : na
//fill(bodyMiddle, upTrend, color.new(color.green, 90), fillgaps=false)
//fill(bodyMiddle, downTrend, color.new(color.red, 90), fillgaps=false)
//bullishsupertrend = supertrend < close and supertrend[1] > close
//plotshape(uptrend, style=shape.labelup, color=color.green,
location=location.belowbar, size=size.large)
//HMA///////////////////////////////////////////////////////////////////////////
len6 = 100
src6 = close
hma = wma(2*wma(src6, len6/2)-wma(src6, len6), floor(sqrt(len6)))
hmacolor = close > hma ? #00bcd4 : #e91e63
plot(hma, title="HMA Line", color=color.new(hmacolor, 25), linewidth=5)
//Parabolic SAR/////////////////////////////////////////////////////////////////
start = 0.02
increment = 0.01
maximum = 0.2
psar = sar(start, increment, maximum)
//plot(psar, "ParabolicSAR", style=plot.style_circles, color=#ffffff)
//END▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲
////////////////////////////////////////////////////////////////////////////////
//MOMENTUM INCIDATORS▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼
//RSI Divergence////////////////////////////////////////////////////////////////
len11 = 14
src11 = close
lbR11 = 2
lbL11 = 6
rangeUpper11 = 60
rangeLower11 = 5
plotBull11 = true
plotHiddenBull11 = false
plotBear11 = true
plotHiddenBear11 = false
bearColor11 = color.red
bullColor11 = color.green
hiddenBullColor11 = color.new(color.green, 80)
hiddenBearColor11 = color.new(color.red, 80)
textColor11 = color.white
noneColor11 = color.new(color.white, 100)
osc11 = rsi(src11, len11)
//MACD Divergence///////////////////////////////////////////////////////////////
fast_length12 = 12
slow_length12 = 26
src12 = close
signal_length12 = 9
sma_source12 = "EMA"
sma_signal12 = "EMA"
//Plot colors
col_macd12 = #2962FF
col_signal12 = #FF6D00
col_grow_above12 = #26A69A
col_fall_above12 = #B2DFDB
col_grow_below12 = #FFCDD2
col_fall_below12 = #FF5252
//Calculating
fast_ma12 = sma_source12 == "SMA" ? sma(src12, fast_length12) : ema(src12,
fast_length12)
slow_ma12 = sma_source12 == "SMA" ? sma(src12, slow_length12) : ema(src12,
slow_length12)
macd = fast_ma12 - slow_ma12
signal = sma_signal12 == "SMA" ? sma(macd, signal_length12) : ema(macd,
signal_length12)
hist = macd - signal
//plot(hist, title="Histogram", style=plot.style_columns, color=(hist>=0 ? (hist[1]
< hist ? col_grow_above12 : col_fall_above12) : (hist[1] < hist ?
col_grow_below12 : col_fall_below12)))
//plot(macd, title="MACD", color=col_macd12)
//plot(signal, title="Signal", color=col_signal12)
donttouchzero12 = true
lbR12 = 2
lbL12 = 6
rangeUpper12 = 60
rangeLower12 = 5
plotBull12 = true
plotHiddenBull12 = false
plotBear12 = true
plotHiddenBear12 = false
bearColor12 = color.red
bullColor12 = color.green
hiddenBullColor12 = color.new(color.green, 80)
hiddenBearColor12 = color.new(color.red, 80)
textColor12 = color.white
noneColor12 = color.new(color.white, 100)
osc12 = macd
bullCond12 = plotBull12 and priceLL12 and oscHL12 and plFound12 and blowzero12
//plot(plFound12 ? osc12[lbR12] : na, offset=-lbR12, title="Regular Bullish",
linewidth=2, color=(bullCond12 ? bullColor12 : noneColor12))
//plotshape(bullCond12 ? osc12[lbR12] : na, offset=-lbR12, title="Regular Bullish
Label", text=" Bull ", style=shape.labelup, location=location.absolute,
color=bullColor12, textcolor=textColor12)
bearCond12 = plotBear12 and priceHH12 and oscLH12 and phFound12 and bearzero12
//plot(phFound12 ? osc12[lbR12] : na, offset=-lbR12, title="Regular Bearish",
linewidth=2, color=(bearCond12 ? bearColor12 : noneColor12))
//plotshape(bearCond12 ? osc12[lbR12] : na, offset=-lbR12, title="Regular Bearish
Label", text=" Bear ", style=shape.labeldown, location=location.absolute,
color=bearColor12, textcolor=textColor12)
//plot(hline, color=color.gray)
//plot(wt1, color=color.white)
//plot(wt2, color=color.blue)
//Divergence
lbR13 = 2
lbL13 = 6
rangeUpper13 = 60
rangeLower13 = 5
plotBull13 = true
plotHiddenBull13 = false
plotBear13 = true
plotHiddenBear13 = false
bearColor13 = color.red
bullColor13 = color.green
hiddenBullColor13 = color.green
hiddenBearColor13 = color.red
textColor13 = color.white
noneColor13 = color.new(color.white, 100)
k13 = wt1
d13 = wt2
osc13 = k13
_inRange13(cond) =>
bars13 = barssince(cond == true)
rangeLower13 <= bars13 and bars13 <= rangeUpper13
//Regular Bullish
//Osc: Higher Low
oscHL13 = osc13[lbR13] > valuewhen(plFound13, osc13[lbR13], 1) and
_inRange13(plFound13[1])
//Hidden Bullish
//Regular Bearish
//Hidden Bearish
//Stochastic Divergence/////////////////////////////////////////////////////////
periodK14 = 14
smoothK14 = 3
periodD14 = 3
k14 = sma(stoch(close, high, low, periodK14), smoothK14)
d14 = sma(k14, periodD14)
//plot(k14, title="%K", color=#2962FF)
//plot(d14, title="%D", color=#FF6D00)
//h0 = hline(80, "Upper Band", color=#787B86)
//h1 = hline(20, "Lower Band", color=#787B86)
//fill(h0, h1, color=color.rgb(33, 150, 243, 90), title="Background")
//Divergence
lbR14 = 2
lbL14 = 6
rangeUpper14 = 60
rangeLower14 = 5
plotBull14 = true
plotHiddenBull14 = false
plotBear14 = true
plotHiddenBear14 = false
bearColor14 = color.red
bullColor14 = color.green
hiddenBullColor14 = color.green
hiddenBearColor14 = color.red
textColor14 = color.white
noneColor14 = color.new(color.white, 100)
osc14 = k14
_inRange14(cond) =>
bars14 = barssince(cond == true)
rangeLower14 <= bars14 and bars14 <= rangeUpper14
//Regular Bullish
//Hidden Bullish
//Osc: Lower Low
oscLL14 = osc14[lbR14] < valuewhen(plFound14, osc14[lbR14], 1) and
_inRange14(plFound14[1])
//Regular Bearish
//Hidden Bearish
//END▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲
////////////////////////////////////////////////////////////////////////////////
//VOLATILITY INDICATORS▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼
//Bollinger Bands///////////////////////////////////////////////////////////////
length1 = 20
src7 = close
mult1 = 2.0
basis = sma(src7, length1)
dev = mult1 * stdev(src7, length1)
upper = basis + dev
lower = basis - dev
offset = 0
//plot(basis, "Basis", color=#FF6D00, offset = offset)
//p1 = plot(upper, "Upper", color=#2962FF, offset = 0)
//p2 = plot(lower, "Lower", color=#2962FF, offset = 0)
//fill(p1, p2, title = "Background", color=color.rgb(33, 150, 243, 95))
//Divergence
lbR15 = 2
lbL15 = 6
rangeUpper15 = 60
rangeLower15 = 5
plotBull15 = true
plotHiddenBull15 = false
plotBear15 = true
plotHiddenBear15 = false
bearColor15 = color.red
bullColor15 = color.green
hiddenBullColor15 = color.green
hiddenBearColor15 = color.red
textColor15 = color.white
noneColor15 = color.new(color.white, 100)
d15 = rvi
osc15 = d15
_inRange15(cond) =>
bars15 = barssince(cond == true)
rangeLower15 <= bars15 and bars15 <= rangeUpper15
//Regular Bullish
//Hidden Bullish
//Regular Bearish
//Hidden Bearish
pivot_high16 =
iff(src16=="Close",pivothigh(close,left16,right16),pivothigh(high,left16,right16))
pivot_lows16 = iff(src16=="Close",pivotlow(close,
left16,right16),pivotlow(low,left16,right16))
quick_pivot_high16 =
iff(src16=="Close",pivothigh(close,left16,quick_right16),pivothigh(high,left16,quic
k_right16))
quick_pivot_lows16 = iff(src16=="Close",pivotlow(close,
left16,quick_right16),pivotlow(low, left16,quick_right16))
length17 = 9
src17 = close
hma17 = wma(2*wma(src17, length17/2)-wma(src17, length17), floor(sqrt(length17)))
buy1 = hma17 > level1 and hma17[1] < level1[1] and close > close[2]
buy2 = hma17 > level2 and hma17[1] < level2[1] and close > close[2]
buy3 = hma17 > level3 and hma17[1] < level3[1] and close > close[2]
buy4 = hma17 > level4 and hma17[1] < level4[1] and close > close[2]
buy5 = hma17 > level5 and hma17[1] < level5[1] and close > close[2]
buy6 = hma17 > level6 and hma17[1] < level6[1] and close > close[2]
buy7 = hma17 > level7 and hma17[1] < level7[1] and close > close[2]
buy8 = hma17 > level8 and hma17[1] < level8[1] and close > close[2]
sell1 = hma17 < level1 and hma17[1] > level1[1] and close < close[2]
sell2 = hma17 < level2 and hma17[1] > level2[1] and close < close[2]
sell3 = hma17 < level3 and hma17[1] > level3[1] and close < close[2]
sell4 = hma17 < level4 and hma17[1] > level4[1] and close < close[2]
sell5 = hma17 < level5 and hma17[1] > level5[1] and close < close[2]
sell6 = hma17 < level6 and hma17[1] > level6[1] and close < close[2]
sell7 = hma17 < level7 and hma17[1] > level7[1] and close < close[2]
sell8 = hma17 < level8 and hma17[1] > level8[1] and close < close[2]
//END▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲
////////////////////////////////////////////////////////////////////////////////
//VOLUME INDICATORS▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼
//OBV Divergence////////////////////////////////////////////////////////////////
len18 = 20
src18 = close
lbR18 = 2
lbL18 = 6
rangeUpper18 = 60
rangeLower18 = 5
plotBull18 = true
plotHiddenBull18 = false
plotBear18 = true
plotHiddenBear18 = false
bearColor18 = color.red
bullColor18 = color.green
hiddenBullColor18 = color.green
hiddenBearColor18 = color.new(color.red, 80)
textColor18 = color.white
noneColor18 = color.new(color.white, 100)
csrc = change(src18)
obv1(src18) => cum(change(src18) > 0 ? volume : csrc < 0 ? -volume : 0*volume)
os = obv1(src18)
obv_osc = (os - ema(os,len18))
obc_color=obv_osc > 0 ? color.green : color.red
//plot(obv_osc, color=obc_color, style=plot.style_line,title="OBV-Points",
linewidth=2)
//plot(obv_osc, color=color.silver, transp=70, title="OBV", style=plot.style_area)
//hline(0)
_inRange(cond) =>
bars = barssince(cond == true)
rangeLower18 <= bars and bars <= rangeUpper18
// Regular Bullish
// Hidden Bullish
// Regular Bearish
// Hidden Bearish
//VWAP//////////////////////////////////////////////////////////////////////////
computeVWAP(src20, isNewPeriod, stDevMultiplier) =>
var float sumSrcVol = na
var float sumVol = na
var float sumSrcSrcVol = na
hideonDWM = false
var anchor = "Session"
src20 = hlc3
offset20 = 0
showBands = true
stdevMult = 1.0
timeChange(period) =>
change(time(period))
tcD = timeChange("D")
tcW = timeChange("W")
tcM = timeChange("M")
tc3M = timeChange("3M")
tc12M = timeChange("12M")
float vwapValue = na
float std = na
float upperBandValue = na
float lowerBandValue = na
//Candle Patterns///////////////////////////////////////////////////////////////
//Bullish Engulfing
C_DownTrend = true
C_UpTrend = true
var trendRule1 = "SMA50"
var trendRule2 = "SMA50, SMA200"
var trendRule = trendRule1
if trendRule == trendRule1
priceAvg = sma(close, 50)
C_DownTrend := close < priceAvg
C_UpTrend := close > priceAvg
if trendRule == trendRule2
sma200 = sma(close, 200)
sma50 = sma(close, 50)
C_DownTrend := close < sma50 and sma50 < sma200
C_UpTrend := close > sma50 and sma50 > sma200
C_Len = 14 // ema depth for bodyAvg
C_ShadowPercent = 5.0 // size of shadows
C_ShadowEqualsPercent = 100.0
C_DojiBodyPercent = 5.0
C_Factor = 2.0 // shows the number of times the shadow dominates the candlestick
body
label_color_bullish = color.blue
C_EngulfingBullishNumberOfCandles = 2
C_EngulfingBullish = C_DownTrend and C_WhiteBody and C_LongBody and C_BlackBody[1]
and C_SmallBody[1] and close >= open[1] and open <= close[1] and ( close > open[1]
or open < close[1] )
if C_EngulfingBullish
var ttBullishEngulfing = "Engulfing\nAt the end of a given downward trend,
there will most likely be a reversal pattern. To distinguish the first day, this
candlestick pattern uses a small body, followed by a day where the candle body
fully overtakes the body from the day before, and closes in the trend’s opposite
direction. Although similar to the outside reversal chart pattern, it is not
essential for this pattern to completely overtake the range (high to low), rather
only the open and the close."
//label.new(bar_index, patternLabelPosLow, text="BE",
style=label.style_label_up, color = label_color_bullish, textcolor=color.white,
tooltip = ttBullishEngulfing)
//bgcolor(highest(C_EngulfingBullish?1:0, C_EngulfingBullishNumberOfCandles)!=0 ?
color.blue : na, offset=-(C_EngulfingBullishNumberOfCandles-1))
//Bearish Engulfing
label_color_bearish = color.red
C_EngulfingBearishNumberOfCandles = 2
C_EngulfingBearish = C_UpTrend and C_BlackBody and C_LongBody and C_WhiteBody[1]
and C_SmallBody[1] and close <= open[1] and open >= close[1] and ( close < open[1]
or open > close[1] )
if C_EngulfingBearish
var ttBearishEngulfing = "Engulfing\nAt the end of a given uptrend, a reversal
pattern will most likely appear. During the first day, this candlestick pattern
uses a small body. It is then followed by a day where the candle body fully
overtakes the body from the day before it and closes in the trend’s opposite
direction. Although similar to the outside reversal chart pattern, it is not
essential for this pattern to fully overtake the range (high to low), rather only
the open and the close."
//label.new(bar_index, patternLabelPosHigh, text="BE",
style=label.style_label_down, color = label_color_bearish, textcolor=color.white,
tooltip = ttBearishEngulfing)
//bgcolor(highest(C_EngulfingBearish?1:0, C_EngulfingBearishNumberOfCandles)!=0 ?
color.red : na, offset=-(C_EngulfingBearishNumberOfCandles-1))
//END▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲
////////////////////////////////////////////////////////////////////////////////
//SIGNAL SCORES▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼
//Position Options
longpositions = input(title="Long Positions", defval=true)
shortpositions = input(title="Short Positions", defval=true)
//Score Requirements
stronglongscore = input(defval=10, minval=0, maxval=1000, title="Required Strong
LONG Score")
strongshortscore = input(defval=10, minval=0, maxval=1000, title="Required Strong
SHORT Score")
weaklongscore = input(defval=8, minval=0, maxval=1000, title="Required Weak LONG
Score")
weakshortscore = input(defval=8, minval=0, maxval=1000, title="Required Weak SHORT
Score")
//EMA Signals
emadirectionimportance = input(defval=2, minval=0, maxval=100, title="EMA Trend
Direction Importance")
emadirectionup = out5 < close ? emadirectionimportance : 0
emadirectionupstatus = emadirectionup ? "EMA Trend Direction Up" : na
emadirectiondown = out5 > close ? emadirectionimportance : 0
emadirectiondownstatus = emadirectiondown ? "EMA Trend Direction Down" : na
emapushpullimportance = input(defval=2, minval=0, maxval=100, title="EMA Pressure
Importance")
emapushup = out2 > out2[1] and out3 < out3[1] ? emapushpullimportance : 0
emapushupstatus = emapushup ? "EMA Pushing Up" : na
emapulldown = out2 < out2[1] and out3 > out3[1] ? emapushpullimportance : 0
emapulldownstatus = emapulldown ? "EMA Pulling Down" : na
//HMA Signals
hmacloseposimportance = input(defval=1, minval=0, maxval=100, title="HMA Trend
Direction Importance")
hmacloseposup = hma < close and hma[1] ? hmacloseposimportance : 0
hmacloseposupstatus = hmacloseposup ? "Price Crossed Over HMA" : na
hmacloseposdown = hma > close ? hmacloseposimportance : 0
hmacloseposdownstatus = hmacloseposdown ? "Price Crossed Under HMA" : na
//RSI Signals
rsidivimportance = input(defval=4, minval=0, maxval=100, title="RSI Divergence
Importance")
rsidivup = bullCond11 or bullCond11[1] or bullCond11[2] ? rsidivimportance : 0
rsidivupstatus = rsidivup ? "Bullish RSI Divergence" : na
rsidivdown = bearCond11 or bearCond11[1] or bearCond11[2] ? rsidivimportance : 0
rsidivdownstatus = rsidivdown ? "Bearish RSI Divergence" : na
//MACD Signals
macddivimportance = input(defval=0, minval=0, maxval=100, title="MACD Divergence
Importance")
macddivup = bullCond12 or bullCond12[1] or bullCond12[2] ? macddivimportance : 0
macddivupstatus = macddivup ? "Bullish MACD Divergence" : na
macddivdown = bearCond12 or bearCond12[1] or bearCond12[2] ? macddivimportance : 0
macddivdownstatus = macddivdown ? "Bearish MACD Divergence" : na
//WaveTrend Signals
wtdivimportance = input(defval=0, minval=0, maxval=100, title="WaveTrend Divergence
Importance")
wtdivup = bullCond13 or bullCond13[1] or bullCond13[2] ? wtdivimportance : 0
wtdivupstatus = wtdivup ? "Bullish WaveTrend Divergence" : na
wtdivdown = bearCond13 or bearCond13[1] or bearCond13[2] ? wtdivimportance : 0
wtdivdownstatus = wtdivdown ? "Bearish WaveTrend Divergence" : na
//Stochastic Signals
sdivimportance = input(defval=1, minval=0, maxval=100, title="Stochastic Divergence
Importance")
sdivup = bullCond14 or bullCond14[1] or bullCond14[2] ? sdivimportance : 0
sdivupstatus = sdivup ? "Bullish Stoch Divergence" : na
sdivdown = bearCond14 or bearCond14[1] or bearCond14[2] ? sdivimportance : 0
sdivdownstatus = sdivdown ? "Bearish Stoch Divergence" : na
//Volatility Indicators/////////////////////////////////////////////////////////
//VWAP Signals
vwapcrossimportance = input(defval=0, minval=0, maxval=100, title="VWAP Cross HMA
Importance")
vwapcrossup = hma < vwapValue and hma[1] > vwapValue[1] ? vwapcrossimportance : 0
vwapcrossupstatus = vwapcrossup ? "VWAP Crossed Above HMA" : na
vwapcrossdown = hma > vwapValue and hma[1] < vwapValue[1] ? vwapcrossimportance : 0
vwapcrossdownstatus = vwapcrossdown ? "VWAP Crossed Below HMA" : na
//END▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲
////////////////////////////////////////////////////////////////////////////////
//COLLECT SIGNALS▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼
//Classify Entries
stronglongentrysignal = emadirectionup + emapushup + supertrendup +
supertrendrevup + psardirup + psarrevup + hmacloseposup + hmapivotup +
rsidivup + rsioversold + rsicrossup + macddivup + histpivotup +
macdcrosssignalup + wtdivup + wtcrosssignalup + sdivup + scrosssignalup +
bbcontup + atrrevup + rviposup + rvidivup + srcrossup + obvdivup +
cmfcrossup + cmflevup + vwapcrossup + vwaptrendup + bulleng >=
stronglongscore
strongshortentrysignal = emadirectiondown + emapulldown + supertrenddown +
supertrendrevdown + psardirdown + psarrevdown + hmacloseposdown + hmapivotdown +
rsidivdown + rsioverbought + rsicrossdown + macddivdown + histpivotdown +
macdcrosssignaldown + wtdivdown + wtcrosssignaldown + sdivdown + scrosssignaldown +
bbcontdown + atrrevdown + rviposdown + rvidivdown + srcrossdown + obvdivdown +
cmfcrossdown + cmflevdown + vwapcrossdown + vwaptrenddown + beareng >=
strongshortscore
weaklongentrysignal = emadirectionup + emapushup + supertrendup +
supertrendrevup + psardirup + psarrevup + hmacloseposup + hmapivotup +
rsidivup + rsioversold + rsicrossup + macddivup + histpivotup +
macdcrosssignalup + wtdivup + wtcrosssignalup + sdivup + scrosssignalup +
bbcontup + atrrevup + rviposup + rvidivup + srcrossup + obvdivup +
cmfcrossup + cmflevup + vwapcrossup + vwaptrendup + bulleng >=
weaklongscore
weakshortentrysignal = emadirectiondown + emapulldown + supertrenddown +
supertrendrevdown + psardirdown + psarrevdown + hmacloseposdown + hmapivotdown +
rsidivdown + rsioverbought + rsicrossdown + macddivdown + histpivotdown +
macdcrosssignaldown + wtdivdown + wtcrosssignaldown + sdivdown + scrosssignaldown +
bbcontdown + atrrevdown + rviposdown + rvidivdown + srcrossdown + obvdivdown +
cmfcrossdown + cmflevdown + vwapcrossdown + vwaptrenddown + beareng >=
weakshortscore
//END▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲
////////////////////////////////////////////////////////////////////////////////
//PLOT SIGNALS▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼
//END▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲
////////////////////////////////////////////////////////////////////////////////
//PLOT STATUS▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼
//Trend Status//////////////////////////////////////////////////////////////////
//EMA Status
if emadirectionup
table.cell(statuswindow, 3, 1, text=tostring(emadirectionupstatus),
bgcolor=color.new(#00bcd4, 50), text_color=color.white, text_size=size.small)
if emadirectiondown
table.cell(statuswindow, 3, 1, text=tostring(emadirectiondownstatus),
bgcolor=color.new(#e91e63, 50), text_color=color.white, text_size=size.small)
if emapushup ? 1 : na
table.cell(statuswindow, 3, 2, text=tostring(emapushupstatus),
bgcolor=color.new(#00bcd4, 50), text_color=color.white, text_size=size.small)
if emapushup ? na : 1
table.clear(statuswindow, 3, 2)
if emapulldown ? 1 : na
table.cell(statuswindow, 3, 3, text=tostring(emapulldownstatus),
bgcolor=color.new(#e91e63, 50), text_color=color.white, text_size=size.small)
if emapulldown ? na : 1
table.clear(statuswindow, 3, 3)
//SuperTrend Status
if supertrendup
table.cell(statuswindow, 3, 4, text=tostring(supertrendupstatus),
bgcolor=color.new(#00bcd4, 50), text_color=color.white, text_size=size.small)
if supertrenddown
table.cell(statuswindow, 3, 4, text=tostring(supertrenddownstatus),
bgcolor=color.new(#e91e63, 50), text_color=color.white, text_size=size.small)
if supertrendrevup ? 1 : na
table.cell(statuswindow, 3, 5, text=tostring(supertrendrevupstatus),
bgcolor=color.new(#00bcd4, 50), text_color=color.white, text_size=size.small)
if supertrendrevup ? na : 1
table.clear(statuswindow, 3, 5)
if supertrendrevdown ? 1 : na
table.cell(statuswindow, 3, 6, text=tostring(supertrendrevdownstatus),
bgcolor=color.new(#e91e63, 50), text_color=color.white, text_size=size.small)
if supertrendrevdown ? na : 1
table.clear(statuswindow, 3, 6)
//HMA Status
if hmacloseposup
table.cell(statuswindow, 3, 10, text=tostring(hmacloseposupstatus),
bgcolor=color.new(#00bcd4, 50), text_color=color.white, text_size=size.small)
if hmacloseposdown
table.cell(statuswindow, 3, 10, text=tostring(hmacloseposdownstatus),
bgcolor=color.new(#e91e63, 50), text_color=color.white, text_size=size.small)
if hmapivotup ? 1 : na
table.cell(statuswindow, 3, 11, text=tostring(hmapivotupstatus),
bgcolor=color.new(#00bcd4, 50), text_color=color.white, text_size=size.small)
if hmapivotup ? na : 1
table.clear(statuswindow, 3, 11)
if hmapivotdown ? 1 : na
table.cell(statuswindow, 3, 12, text=tostring(hmapivotdownstatus),
bgcolor=color.new(#e91e63, 50), text_color=color.white, text_size=size.small)
if hmapivotdown ? na : 1
table.clear(statuswindow, 3, 12)
//Momentum Status///////////////////////////////////////////////////////////////
//RSI Status
if rsidivup ? 1 : na
table.cell(statuswindow, 2, 1, text=tostring(rsidivupstatus),
bgcolor=color.new(#00bcd4, 50), text_color=color.white, text_size=size.small)
if rsidivup ? na : 1
table.clear(statuswindow, 2, 1)
if rsidivdown ? 1 : na
table.cell(statuswindow, 2, 2, text=tostring(rsidivdownstatus),
bgcolor=color.new(#e91e63, 50), text_color=color.white, text_size=size.small)
if rsidivdown ? na : 1
table.clear(statuswindow, 2, 2)
if rsioversold ? 1 : na
table.cell(statuswindow, 2, 3, text=tostring(rsioversoldstatus),
bgcolor=color.new(#00bcd4, 50), text_color=color.white, text_size=size.small)
if rsioversold ? na : 1
table.clear(statuswindow, 2, 3)
if rsioverbought ? 1 : na
table.cell(statuswindow, 2, 4, text=tostring(rsioverboughtstatus),
bgcolor=color.new(#e91e63, 50), text_color=color.white, text_size=size.small)
if rsioverbought ? na : 1
table.clear(statuswindow, 2, 4)
if rsicrossup ? 1 : na
table.cell(statuswindow, 2, 5, text=tostring(rsicrossupstatus),
bgcolor=color.new(#00bcd4, 50), text_color=color.white, text_size=size.small)
if rsicrossup ? na : 1
table.clear(statuswindow, 2, 5)
if rsicrossdown ? 1 : na
table.cell(statuswindow, 2, 6, text=tostring(rsicrossdownstatus),
bgcolor=color.new(#e91e63, 50), text_color=color.white, text_size=size.small)
if rsicrossdown ? na : 1
table.clear(statuswindow, 2, 6)
//MACD Status
if macddivup ? 1 : na
table.cell(statuswindow, 2, 7, text=tostring(macddivupstatus),
bgcolor=color.new(#00bcd4, 50), text_color=color.white, text_size=size.small)
if macddivup ? na : 1
table.clear(statuswindow, 2, 7)
if macddivdown ? 1 : na
table.cell(statuswindow, 2, 8, text=tostring(macddivdownstatus),
bgcolor=color.new(#e91e63, 50), text_color=color.white, text_size=size.small)
if macddivdown ? na : 1
table.clear(statuswindow, 2, 8)
if histpivotup ? 1 : na
table.cell(statuswindow, 2, 9, text=tostring(histpivotupstatus),
bgcolor=color.new(#00bcd4, 50), text_color=color.white, text_size=size.small)
if histpivotup ? na : 1
table.clear(statuswindow, 2, 9)
if histpivotdown ? 1 : na
table.cell(statuswindow, 2, 10, text=tostring(histpivotdownstatus),
bgcolor=color.new(#e91e63, 50), text_color=color.white, text_size=size.small)
if histpivotdown ? na : 1
table.clear(statuswindow, 2, 10)
if macdcrosssignalup ? 1 : na
table.cell(statuswindow, 2, 11, text=tostring(macdcrosssignalupstatus),
bgcolor=color.new(#00bcd4, 50), text_color=color.white, text_size=size.small)
if macdcrosssignalup ? na : 1
table.clear(statuswindow, 2, 11)
if macdcrosssignaldown ? 1 : na
table.cell(statuswindow, 2, 12, text=tostring(macdcrosssignaldownstatus),
bgcolor=color.new(#e91e63, 50), text_color=color.white, text_size=size.small)
if macdcrosssignaldown ? na : 1
table.clear(statuswindow, 2, 12)
//Stochastic Status
if sdivup ? 1 : na
table.cell(statuswindow, 2, 17, text=tostring(sdivupstatus),
bgcolor=color.new(#00bcd4, 50), text_color=color.white, text_size=size.small)
if sdivup ? na : 1
table.clear(statuswindow, 2, 17)
if sdivdown ? 1 : na
table.cell(statuswindow, 2, 18, text=tostring(sdivdownstatus),
bgcolor=color.new(#e91e63, 50), text_color=color.white, text_size=size.small)
if sdivdown ? na : 1
table.clear(statuswindow, 2, 18)
if scrosssignalup ? 1 : na
table.cell(statuswindow, 2, 19, text=tostring(scrosssignalupstatus),
bgcolor=color.new(#00bcd4, 50), text_color=color.white, text_size=size.small)
if scrosssignalup ? na : 1
table.clear(statuswindow, 2, 19)
if scrosssignaldown ? 1 : na
table.cell(statuswindow, 2, 20, text=tostring(scrosssignaldownstatus),
bgcolor=color.new(#e91e63, 50), text_color=color.white, text_size=size.small)
if scrosssignaldown ? na : 1
table.clear(statuswindow, 2, 20)
//Volatility
Status/////////////////////////////////////////////////////////////////
//ATR Status
if atrrevup ? 1 : na
table.cell(statuswindow, 1, 3, text=tostring(atrrevupstatus),
bgcolor=color.new(#00bcd4, 50), text_color=color.white, text_size=size.small)
if atrrevup ? na : 1
table.clear(statuswindow, 1, 3)
if atrrevdown ? 1 : na
table.cell(statuswindow, 1, 4, text=tostring(atrrevdownstatus),
bgcolor=color.new(#e91e63, 50), text_color=color.white, text_size=size.small)
if atrrevdown ? na : 1
table.clear(statuswindow, 1, 4)
//RVI Status
if rviposup ? 1 : na
table.cell(statuswindow, 1, 5, text=tostring(rviposupstatus),
bgcolor=color.new(#00bcd4, 50), text_color=color.white, text_size=size.small)
if rviposup ? na : 1
table.clear(statuswindow, 1, 5)
if rviposdown ? 1 : na
table.cell(statuswindow, 1, 6, text=tostring(rviposdownstatus),
bgcolor=color.new(#e91e63, 50), text_color=color.white, text_size=size.small)
if rviposdown ? na : 1
table.clear(statuswindow, 1, 6)
if rvidivup ? 1 : na
table.cell(statuswindow, 1, 7, text=tostring(rvidivupstatus),
bgcolor=color.new(#00bcd4, 50), text_color=color.white, text_size=size.small)
if rvidivup ? na : 1
table.clear(statuswindow, 1, 7)
if rvidivdown ? 1 : na
table.cell(statuswindow, 1, 8, text=tostring(rvidivdownstatus),
bgcolor=color.new(#e91e63, 50), text_color=color.white, text_size=size.small)
if rvidivdown ? na : 1
table.clear(statuswindow, 1, 8)
//Volume Status/////////////////////////////////////////////////////////////////
//VWAP Status
if vwapcrossup ? 1 : na
table.cell(statuswindow, 0, 6, text=tostring(vwapcrossupstatus),
bgcolor=color.new(#00bcd4, 50), text_color=color.white, text_size=size.small)
if vwapcrossup ? na : 1
table.clear(statuswindow, 0, 6)
if vwapcrossdown ? 1 : na
table.cell(statuswindow, 0, 7, text=tostring(vwapcrossdownstatus),
bgcolor=color.new(#e91e63, 50), text_color=color.white, text_size=size.small)
if vwapcrossdown ? na : 1
table.clear(statuswindow, 0, 7)
if vwaptrendup ? 1 : na
table.cell(statuswindow, 0,8, text=tostring(vwaptrendupstatus),
bgcolor=color.new(#00bcd4, 50), text_color=color.white, text_size=size.small)
if vwaptrenddown ? 1 : na
table.cell(statuswindow, 0, 8, text=tostring(vwaptrenddownstatus),
bgcolor=color.new(#e91e63, 50), text_color=color.white, text_size=size.small)
//END▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲
////////////////////////////////////////////////////////////////////////////////
//STOP LOSS WARNINGS▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼
//END▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲
////////////////////////////////////////////////////////////////////////////////
//STRATEGY TESTER▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼
//Long
if tradetrendoption ? alternatelong and mabuy and longpositions : alternatelong and
longpositions
strategy.entry("longposition", strategy.long, comment="Long Entry")
if (shortentry or printstoplong) and longpositions
strategy.close("longposition", comment="Long Exit")
//Short
if tradetrendoption ? alternateshort and masell and shortpositions : alternateshort
and shortpositions
strategy.entry("shortposition", strategy.short, comment=" Short Entry")
if (longentry or printstopshort) and shortpositions
strategy.close("shortposition", comment="Short Exit")
//Alerts
ttbuystring = "Input your custom alert message here. In the Alert settings, choose
\"Neural Network\" and \"Alert() functionc calls only\"\nIf you're using a 3Commas
Bot, make sure to format your message correctly with forward slashes in front of
each quotation, you can find videos about how to do this on YouTube. Or ask 3Commas
support about how to format the message for PineScript."
ttsellstring = "Input your custom alert message here. In the Alert settings, choose
\"Neural Network\" and \"Alert() functionc calls only\"\nIf you're using a 3Commas
Bot, make sure to format your message correctly with forward slashes in front of
each quotation, you can find videos about how to do this on YouTube. Or ask 3Commas
support about how to format the message for PineScript."
ttstopstring = "Input your custom alert message here. In the Alert settings, choose
\"Neural Network\" and \"Alert() functionc calls only\"\nIf you're using a 3Commas
Bot, make sure to format your message correctly with forward slashes in front of
each quotation, you can find videos about how to do this on YouTube. Or ask 3Commas
support about how to format the message for PineScript."
usebuyalert = input(defval=true, title="Use BUY Alert", group="Alert Messages")
buystring = input(title="Buy Alert Message", defval="BUY", type=input.string,
confirm=false, group="Alert Messages", tooltip=ttbuystring)
usesellalert = input(defval=true, title="Use SELL Alert", group="Alert Messages")
sellstring = input(title="Sell Alert Message", defval="SELL", type=input.string,
confirm=false, group="Alert Messages", tooltip=ttsellstring)
usestopalert = input(defval=true, title="Use STOP Alert", group="Alert Messages")
stopstring = input(title="Stop Alert Message", defval="STOP", type=input.string,
confirm=false, group="Alert Messages", tooltip=ttstopstring)
//END▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲
////////////////////////////////////////////////////////////////////////////////