Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 4

//@version=4

study("UTT BARS) " , max_bars_back = 21)


src = close[0]
lights = input(title="Barcolor I / 0 ? ", options=["ON", "OFF"], defval="OFF")

// Definition : INDICATORS

// RSI

_rsi = rsi(close,14)

// MACD

fun_macd(_src,_fastlen,_slowlen,_signallen) =>

float _output = na
_macd = ema(_src,_fastlen) - ema(_src,_slowlen)
_signal = ema(_macd , _signallen)
_output := _macd - _signal

_hist = fun_macd(src,12,26,9)

// MOMENTUM

t_mom = 10

f_mom(_src , _length) =>

_output = 0.00
_length_adjusted = _length < 0 ? 0 : _length

_output := nz((_src / _src[_length_adjusted] ) - 1 ) * 100

mom = f_mom(src , t_mom)

// BOLLINGER BANDS

length = input(20, minval=1)


mult = input(2.0, minval=0.001, maxval=50)
basis = sma(src, length)
dev = mult * stdev(src, length)
upper = basis + dev
lower = basis - dev

// CM GUPPY EMA

len1 = input(3, minval=1, title="Fast EMA 1")


len2 = input(5, minval=1, title="Fast EMA 2")
len3 = input(8, minval=1, title="Fast EMA 3")
len4 = input(10, minval=1, title="Fast EMA 4")
len5 = input(12, minval=1, title="Fast EMA 5")
len6 = input(15, minval=1, title="Fast EMA 6")
//Slow EMA
len7 = input(30, minval=1, title="Slow EMA 7")
len8 = input(35, minval=1, title="Slow EMA 8")
len9 = input(40, minval=1, title="Slow EMA 9")
len10 = input(45, minval=1, title="Slow EMA 10")
len11 = input(50, minval=1, title="Slow EMA 11")
len12 = input(60, minval=1, title="Slow EMA 12")

//Fast EMA
ema1 = ema(src, len1)
ema2 = ema(src, len2)
ema3 = ema(src, len3)
ema4 = ema(src, len4)
ema5 = ema(src, len5)
ema6 = ema(src, len6)
//Slow EMA
ema7 = ema(src, len7)
ema8 = ema(src, len8)
ema9 = ema(src, len9)
ema10 = ema(src, len10)
ema11 = ema(src, len11)
ema12 = ema(src, len12)

// DEEP LEARNING INDICATORS

_indicator1 = ((_rsi - _rsi[1] ) / (_rsi[1]))


_indicator2 = ((volume - volume[1] ) / (volume[1]))
_indicator3 = ((_hist - _hist[1] ) / (_hist[1]))
_indicator4 = ((mom - mom[1] ) / (mom[1]))
_indicator5 = ((lower - lower[1] ) / (lower[1]))
_indicator6 = ((basis - basis[1] ) / (basis[1]))
_indicator7 = ((upper - upper[1] ) / (upper[1]))

_indicator8 = ((ema1 - ema1[1] ) / (ema1[1]))


_indicator9 = ((ema2 - ema2[1] ) / (ema2[1]))
_indicator10 = ((ema3 - ema3[1] ) / (ema3[1]))
_indicator11 = ((ema4 - ema4[1] ) / (ema4[1]))
_indicator12 = ((ema5 - ema5[1] ) / (ema5[1]))
_indicator13 = ((ema6 - ema6[1] ) / (ema6[1]))
_indicator14 = ((ema7 - ema7[1] ) / (ema7[1]))
_indicator15 = ((ema8 - ema8[1] ) / (ema8[1]))
_indicator16 = ((ema9 - ema9[1] ) / (ema9[1]))
_indicator17 = ((ema10 - ema10[1] ) / (ema10[1]))
_indicator18 = ((ema11 - ema11[1] ) / (ema11[1]))
_indicator19 = ((ema12 - ema12[1] ) / (ema12[1]))

// Inputs on Tangent Function :

tangentdiff(_src) => nz((_src - _src[1]) / _src[1] )

// Deep Learning Activation Function (Tanh) :

ActivationFunctionTanh(v) => (1 - exp(-2 * v))/( 1 + exp(-2 * v))

// DEEP LEARNING

// INPUTS :

input_1 = tangentdiff(_indicator1)
input_2 = tangentdiff(_indicator2)
input_3 = tangentdiff(_indicator3)
input_4 = tangentdiff(_indicator4)
input_5 = tangentdiff(_indicator5)
input_6 = tangentdiff(_indicator6)
input_7 = tangentdiff(_indicator7)
input_8 = tangentdiff(_indicator8)
input_9 = tangentdiff(_indicator9)
input_10 = tangentdiff(_indicator10)
input_11 = tangentdiff(_indicator11)
input_12 = tangentdiff(_indicator12)
input_13 = tangentdiff(_indicator13)
input_14 = tangentdiff(_indicator14)
input_15 = tangentdiff(_indicator15)
input_16 = tangentdiff(_indicator16)
input_17 = tangentdiff(_indicator17)
input_18 = tangentdiff(_indicator18)
input_19 = tangentdiff(_indicator19)

// LAYERS :

// Input Layers

n_0 = ActivationFunctionTanh(input_1 + 0)
n_1 = ActivationFunctionTanh(input_2 + 0)
n_2 = ActivationFunctionTanh(input_3 + 0)
n_3 = ActivationFunctionTanh(input_4 + 0)
n_4 = ActivationFunctionTanh(input_5 + 0)
n_5 = ActivationFunctionTanh(input_6 + 0)
n_6 = ActivationFunctionTanh(input_7 + 0)
n_7 = ActivationFunctionTanh(input_8 + 0)
n_8 = ActivationFunctionTanh(input_9 + 0)
n_9 = ActivationFunctionTanh(input_10 + 0)
n_10 = ActivationFunctionTanh(input_11 + 0)
n_11 = ActivationFunctionTanh(input_12 + 0)
n_12 = ActivationFunctionTanh(input_13 + 0)
n_13 = ActivationFunctionTanh(input_14 + 0)
n_14 = ActivationFunctionTanh(input_15 + 0)
n_15 = ActivationFunctionTanh(input_16 + 0)
n_16 = ActivationFunctionTanh(input_17 + 0)
n_17 = ActivationFunctionTanh(input_18 + 0)
n_18 = ActivationFunctionTanh(input_19 + 0)

// Hidden Layers - 1

n_19 = ActivationFunctionTanh( -0.000052 * n_0 + 0.000023 * n_1 + -0.000002 * n_2 + 0.000030 * n_3 + 0.000048 * n_4 + -0.000430 * n_5 +
-0.000184 * n_6 + -0.000083 * n_7 + -0.000118 * n_8 + -0.000184 * n_9 + -0.000230 * n_10 + -0.000273 * n_11 +
-0.000310 * n_12 + -0.000362 * n_13 + -0.000362 * n_14 + -0.000356 * n_15 + -0.000350 * n_16 + -0.000344 * n_17 +
-0.000335 * n_18 + -0.053564 )
n_20 = ActivationFunctionTanh( -0.000055 * n_0 + 0.000025 * n_1 + -0.000002 * n_2 + 0.000032 * n_3 + 0.000051 * n_4 + -0.000457 * n_5 +
-0.000195 * n_6 + -0.000088 * n_7 + -0.000126 * n_8 + -0.000196 * n_9 + -0.000244 * n_10 + -0.000291 * n_11 +
-0.000329 * n_12 + -0.000385 * n_13 + -0.000385 * n_14 + -0.000378 * n_15 + -0.000372 * n_16 + -0.000366 * n_17 +
-0.000357 * n_18 + 0.070562 )

// Hidden Layer 2 :

n_21 = ActivationFunctionTanh(-0.020503 * n_19 + -0.021810 * n_20 + -0.104142 )

n_22 = ActivationFunctionTanh(-0.024450 * n_19 + -0.026009 * n_20 + 0.354036 )

n_23 = ActivationFunctionTanh(-0.020446 * n_19 + -0.021750 * n_20 + -0.109031)

n_24 = ActivationFunctionTanh(-0.017133 * n_19 + -0.018226 * n_20 + -0.373775)

n_25 = ActivationFunctionTanh(-0.018139 * n_19 + -0.019296 * n_20 + -0.296678)

n_26 = ActivationFunctionTanh(-0.016135 * n_19 + -0.017164 * n_20 + -0.449026)

// Output Layer

_output = ActivationFunctionTanh( -0.188169 * n_21 + -0.233289 * n_22 + -0.187686 * n_23 + -0.161870 * n_24 + -0.169295 * n_25 + -0.154724 * n_26 + -0.711455 )

_chg_src = tangentdiff(src) * 100

_seed = (_output - _chg_src)

// MACD : SEED

fastLength = 12
slowlength = 26
signalLength = 9

macd = ema(_seed, fastLength) - ema(_seed, slowlength)


signal = ema(macd, signalLength)

hist = macd - signal

// Conditions :

positive_condition = hist < 0


negative_condition = hist > 0

//Plot data

hline(0, color=color.black, linewidth = 3)

plot(hist, color=(positive_condition ? color.rgb(229, 233, 13) : color.rgb(204, 8, 243)), style=plot.style_histogram,linewidth= 5 , title="Histogram", transp=0)

plot(hist,color= color.white , style = plot.style_line , linewidth = 1 , transp = 15)

// Definition : Barcolor

_lights = 0.00

if (lights=="ON")

_lights:= 1.00

if (lights=="OFF")

_lights:= -1.00

bcolor_on = _lights == 1.00


bcolor_off = _lights == -1.00

color_condition() =>

(positive_condition and _lights == 1.00) ? color.rgb(243, 239, 2) : (negative_condition and _lights == 1.00) ? color.rgb(227, 9, 235) : na

color barColor = na
barColor := color_condition()

barcolor(color = barColor)
// Alerts

alertcondition(positive_condition , title='Buy Signal', message='Buy Signal ')


alertcondition(negative_condition , title='Sell Signal', message='Sell Signal ')

You might also like