1Copy the scriptPress Copy script above, or the copy button on the code below.
2Open the Pine EditorOpen a TradingView chart and choose Pine Editor at the bottom of the screen.
3Paste over the templateCreate a new indicator, select all of the template text and paste. Press Save and give it a name.
4Add it to the chartPress Add to chart, then adjust the settings with the gear icon next to its name.
Source Code
248 lines of Pine Script v4 from ANN MACD FORECAST.txt, published under MIT. Keep the author's credit and licence lines when you reuse it.
ANN MACD FORECAST.txt
//@version=4
//MIT License
//Copyright (c) 2019 user-Noldo
//Permission is hereby granted, free of charge, to any person obtaining a copy
//of this software and associated documentation files (the "Software"), to deal
//in the Software without restriction, including without limitation the rights
//to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
//copies of the Software, and to permit persons to whom the Software is
//furnished to do so, subject to the following conditions:
//The above copyright notice and this permission notice shall be included in all
//copies or substantial portions of the Software.
//THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
//IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
//FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
//AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
//LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
//OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
//SOFTWARE.
study("ANN MACD Future Forecast (SPY 1D) ", max_bars_back=21)
src = close[0]
lights = input(title="Barcolor I / 0 ? ", options=["ON", "OFF"], defval="OFF")
// Essential Functions
// Highest - Lowest Functions ( All efforts goes to RicardoSantos )
f_highest(_src, _length)=>
_adjusted_length = _length < 1 ? 1 : _length
_value = _src
for _i = 0 to (_adjusted_length-1)
_value := _src[_i] >= _value ? _src[_i] : _value
_return = _value
f_lowest(_src, _length)=>
_adjusted_length = _length < 1 ? 1 : _length
_value = _src
for _i = 0 to (_adjusted_length-1)
_value := _src[_i] <= _value ? _src[_i] : _value
_return = _value
// Function Sum
f_sum(_src , _length) =>
_output = 0.00
_length_adjusted = _length < 1 ? 1 : _length
for i = 0 to _length_adjusted-1
_output := _output + _src[i]
// Unlocked Exponential Moving Average Function
f_ema(_src, _length)=>
_length_adjusted = _length < 1 ? 1 : _length
_multiplier = 2 / (_length_adjusted + 1)
_return = 0.00
_return := na(_return[1]) ? _src : ((_src - _return[1]) * _multiplier) + _return[1]
// Unlocked Moving Average Function
f_sma(_src, _length)=>
_output = 0.00
_length_adjusted = _length < 0 ? 0 : _length
w = cum(_src)
_output:= (w - w[_length_adjusted]) / _length_adjusted
_output
// Definition : Function Bollinger Bands
Multiplier = 2
_length_bb = 20
e_r = f_sma(src,_length_bb)
// Function Standard Deviation :
f_stdev(_src,_length) =>
float _output = na
_length_adjusted = _length < 2 ? 2 : _length
_avg = f_ema(_src , _length_adjusted)
evar = (_src - _avg) * (_src - _avg)
evar2 = ((f_sum(evar,_length_adjusted))/_length_adjusted)
_output := sqrt(evar2)
std_r = f_stdev(src , _length_bb )
upband = e_r + (Multiplier * std_r) // Upband
dnband = e_r - (Multiplier * std_r) // Lowband
basis = e_r // Midband
// Function : Squeeze Momentum Indicator (SQZMOM_LB) (LazyBear)
length = 20
mult = 2.0
lengthKC=20
multKC = 1.5
// Calculate BB
dev = multKC * f_stdev(src, length)
upperBB = e_r + dev
lowerBB = e_r - dev
// Calculate KC
ma = f_sma(src, lengthKC)
range = tr
rangema = f_sma(range, lengthKC)
upperKC = ma + rangema * multKC
lowerKC = ma - rangema * multKC
sqzOn = (lowerBB > lowerKC) and (upperBB < upperKC)
sqzOff = (lowerBB < lowerKC) and (upperBB > upperKC)
noSqz = (sqzOn == false) and (sqzOff == false)
val = linreg(src - f_sma(f_sma(f_highest(f_highest(src,1), lengthKC), f_lowest(f_lowest(src,1), lengthKC)),f_sma(src,lengthKC)), lengthKC,0)
// 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(volume)
input_2 = tangentdiff(e_r)
input_3 = tangentdiff(upband)
input_4 = tangentdiff(dnband)
input_5 = tangentdiff(val)
// 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)
// Hidden Layers
n_5 = ActivationFunctionTanh( -35.733 * n_0 + -86.718 * n_1 + -16.948 * n_2 + -12.384 * n_3 + -38.803 * n_4 + 43.379)
n_6 = ActivationFunctionTanh( -2.394 * n_0 + -85.060 * n_1 + -6.174 * n_2 + -45.667 * n_3 + 26.925 * n_4 + 16.028)
n_7 = ActivationFunctionTanh( -63.221 * n_0 + -7.447 * n_1 + 34.106 * n_2 + -28.880 * n_3 + -23.098 * n_4 + 9.914)
n_8 = ActivationFunctionTanh( -59.117 * n_0 + 41.706 * n_1 + 19.044 * n_2 + -13.141 * n_3 + 40.028 * n_4 + -50.017)
n_9 = ActivationFunctionTanh( -9.193 * n_0 + -64.825 * n_1 + 12.735 * n_2 + 11.168 * n_3 + 13.162 * n_4 + -6.669)
// Output Layer
_output = ActivationFunctionTanh(4.118 * n_5 + 36.306 * n_6 + -22.908 * n_7 + 11.143 * n_8 + -32.203 * n_9 + -0.263)
_chg_src = tangentdiff(src) * 100
_seed = (_output - _chg_src)
// MACD : SEED
fastLength = 12
slowlength = 26
signalLength = 9
macd = f_ema(_seed, fastLength) - f_ema(_seed, slowlength)
signal = f_ema(macd, signalLength)
hist = macd - signal
// Conditions :
positive_condition = hist < 0
negative_condition = hist > 0
col_hist() => positive_condition ? color.new(#F5FFFA,0) : negative_condition ? color.new(#FF355E,0) : color.new(color.yellow,0)
col_histo = col_hist()
//Plot data
hline(0, color=#FFB300, linewidth = 2)
plot(hist, color=(positive_condition ? #00A86B : #D40000), style=plot.style_columns,linewidth= 5 , title="Area", transp=30)
plot(hist, color=col_histo,style =plot.style_cross, title="Forecast", linewidth=3)
// 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.green : (negative_condition and _lights == 1.00) ? color.red : na
color barColor = na
barColor := color_condition()
barcolor(color = barColor)
Overview
ANN MACD Future Forecast (SPY 1D) calculates Bollinger Bands and Squeeze Momentum using custom functions for SMA, EMA, standard deviation, highest and lowest values. The script plots these values in a separate pane and draws bar color based on the lights input setting. It targets SPY on the 1D timeframe and includes no exit rules or position sizing.
The inputs you can change from the gear icon on the chart. Defaults are the author's.
Setting
Type
Default
Variable
Barcolor I / 0 ?
string
OFF
lights
Third-party code. ForexR did not write, test or endorse this script, and the summary above was generated automatically from its code and README. Indicators describe the past, and a strategy's backtest can look better than live trading, especially when a script repaints. Check it in the Strategy Tester and on a demo account before you rely on it.
Farid Makram Custom Levels is a multi-signal indicator for TradingView that combines RSI momentum analysis with MOBO oscillator signals based on the DPO. It generates buy and sell signals when RSI crosses its moving average or when DPO crosses zero, with confi
MACD-V is a volatility-normalized momentum indicator based on research by Alex Spiroglou. It calculates the standard MACD histogram and normalizes it by dividing by the Average True Range (ATR). Plotted in a separate pane as a colored histogram, it includes us
MultiIndicator combines multiple technical indicators into a single separate pane to save chart space. It calculates and displays market regime detection based on ordinary least squares regression, a Holt exponential smoothing crossover, normalized RSI, ADX, a
This indicator plots an oscillator in a separate pane. It builds several SuperTrend series across a user-defined factor range and step, using ATR as the band width. On each bar it measures the distance between the close and each SuperTrend output, then groups
PPO ATR Bands plots a percentage price oscillator in a separate pane. It compares a Hull average of typical price with a volume-weighted exponential average of Parabolic SAR, then scales three true-range bands around the slow average into matching oscillator l
The 8-Factor Composite Screener evaluates equities across fundamental and technical criteria, including valuation ratios, earnings and revenue growth, 12-month return momentum, proximity to 52-week highs, Stage 2 moving average alignment, benchmark relative st