xel_arjona

Acc/DistAMA with FRACTAL DEVIATION BANDS by @XeL_Arjona

ACCUMULATION/DISTRIBUTION ADAPTIVE MOVING AVERAGE with FRACTAL DEVIATION BANDS
Ver. 2.5 @ 16.09.2015
By Ricardo M Arjona @XeL_Arjona


DISCLAIMER:

The Following indicator/code IS NOT intended to be a formal investment advice or recommendation by the
author, nor should be construed as such. Users will be fully responsible by their use regarding their own trading vehicles/assets.

The embedded code and ideas within this work are FREELY AND PUBLICLY available on the Web for NON LUCRATIVE ACTIVITIES and must remain as is.


Pine Script code MOD's and adaptations by @XeL_Arjona with special mention in regard of:
  • Buy (Bull) and Sell (Bear) "Power Balance Algorithm" by:
    Stocks & Commodities V. 21:10 (68-72): "Bull And Bear Balance Indicator by Vadim Gimelfarb"
  • Fractal Deviation Bands by @XeL_Arjona.
  • Color Cloud Fill by @ChrisMoody

CHANGE LOG:
  • Following a "Fractal Approach" now the lookback window is hardcode correlated with a given timeframe. (Default @ 126 days as Half a Year / 252 bars)
  • Clean and speed up of Adaptive Moving Average Algo.
  • Fractal Deviation Band Cloud coloring smoothed.

>

ALL NEW IDEAS OR MODIFICATIONS to these indicator(s) are Welcome in favor to deploy a better and more accurate readings. I will be very glad to be notified at Twitter or TradingVew accounts at: @XeL_Arjona


Any important addition to this work MUST REMAIN PUBLIC by means of CreativeCommons CC & TradingView. Copyright 2015

开源脚本

本着真正的TradingView精神,该脚本的作者将其开源发布,以便交易者可以理解和验证它。为作者喝彩!您可以免费使用它,但在出版物中重复使用此代码受网站规则的约束。 您可以收藏它以在图表上使用。

免责声明

这些信息和出版物并不意味着也不构成TradingView提供或认可的金融、投资、交易或其它类型的建议或背书。请在使用条款阅读更多信息。

想在图表上使用此脚本?
//	* ACCUMULATION/DISTRIBUTION ADAPTIVE MOVING AVERAGE with FRACTAL DEVIATION BANDS.
//    Ver. 2.5 @ 16.09.2015
//    By Ricardo M Arjona @XeL_Arjona
//	
//		DISCLAIMER:
//
//      The Following indicator/code IS NOT intended to be
//      a formal investment advice or recommendation by the
//      author, nor should be construed as such. Users
//      will be fully responsible by their use regarding 
//      their own trading vehicles/assets.
//
//		The embedded code and ideas within this work are 
//		FREELY AND PUBLICLY available on the Web
//		for NON LUCRATIVE ACTIVITIES and must remain as is.
//
//		Pine Script code MOD's and adaptations by @XeL_Arjona 
//      with special mention in regard of:
//      + Buy (Bull) and Sell (Bear) "Power Balance Algorithm" by:
//          Stocks & Commodities V. 21:10 (68-72):
//          "Bull And Bear Balance Indicator by Vadim Gimelfarb"
//      + "Fractal Deviation Bands" idea by @XeL_Arjona.
//      + Color Cloud Fill Condition algorithm by @ChrisMoody
//
//      CHANGE LOG:
//
//      -  Following a "Fractal Approach" now the lookback window
//          is hardcode correlated with a given timeframe.
//          (Default @ 126 days as Half a Year / 252 bars)
//      -  Clean and speed up of Adaptive Moving Average Algo.
//      -  Fractal Deviation Band Cloud coloring smoothed.
//      
//            << THIS IS AN EXPERIMENTAL INDICATOR !! >>
//
//         ALL NEW IDEAS OR MODIFICATIONS to these indicator(s) are
//      Welcome in favor to deploy a better and more accurate readings.
//      I will be very glad to be notified at Twitter or TradingVew
//      accounts at:   @XeL_Arjona
//
//      Any important addition to this work MUST REMAIN
//      PUBLIC by means of CreativeCommons CC & TradingView.
//      2015
//		
//////////////////////////////////////////////////////////////////
study("Accumulation/DistributionAMA with FRACTAL DEVIATION BANDS by @XeL_Arjona", shorttitle="adFDB_XeL", overlay=true)
sbm = input(1, title="Harmonics: fibo(1) padovan(2)", defval=1, minval=1, maxval=2)
resi = input(title="Fixed Resolution @ :", type=resolution, defval="D")
p = input(title="Lookback on Fixed Resolution:", defval=126)
novol = input(false, title="Weight A/D Line without Volume:")
colb = input(false, title="Acc/Dist ColorBars:")
// MAIN GENERAL VARIABLES/FUNCTIONS
resb = resi
bc1 = #99ff99
bc2 = #4ccc4c
bc3 = #1a801a
bc4 = #004c0d
sc1 = #ffc0c0
sc2 = #ff8080
sc3 = #ff4040
sc4 = red
// N-Adaptive Moving Average
nama(array,periods,a) =>
    nmEma = nz(nmEma[1], array) + a * (array-nz(nmEma[1], array))
// Bollinger Bands Function
BolTop(array,per,mult) =>
    std = stdev(array,per)*mult
    bbt = array + std
BolBot(array,per,mult) =>
    std = stdev(array,per)*mult
    bbb = array - std
//Algebraic Constants for general calculations.
_phi = 1.618033  // Phi Number (Fibonacci Seq.)
_pn =  1.324718  // Plastic Number (Podovan Seq.)
Fm = iff(sbm==1,_phi,iff(sbm==2,_pn,0))
// Close Conditions for Pressure Algorithms
cl = close
op = open
hi = high
lo = low
// Bull And Bear "Power-Balance" by Vadim Gimelfarb Algorithm
BP =    iff(cl<op,          iff(cl[1]<op,   max(hi-cl[1], cl-lo), 
                                            max(hi-op, cl-lo)),
        iff(cl>op,          iff(cl[1]>op,   hi-lo, 
                                            max(op-cl[1], hi-lo)),
        iff(hi-cl>cl-lo,    iff(cl[1]<op,   max(hi-cl[1],cl-lo),
                                            hi-op),
        iff(hi-cl<cl-lo,    iff(cl[1]>op,   hi-lo,
                                            max(op-cl[1], hi-lo)),
        iff(cl[1]>op,       max(hi-op, cl-lo),
        iff(cl[1]<op,       max(op-cl[1], hi-lo),
        hi-lo))))))
SP =    iff(cl<op,          iff(cl[1]>op,   max(cl[1]-op, hi-lo),
                                            hi-lo),
        iff(cl>op,          iff(cl[1]>op,   max(cl[1]-lo, hi-cl),
                                            max(op-lo, hi-cl)),
        iff(hi-cl>cl-lo,    iff(cl[1]>op,   max(cl[1]-op, hi-lo),
                                            hi-lo),
        iff(hi-cl<cl-lo,    iff(cl[1]>op,   max(cl[1]-lo, hi-cl),
                                            op-lo),
        iff(cl[1]>op,       max(cl[1]-op, hi-lo),
        iff(cl[1]<op,       max(op-lo, hi-cl),
        hi-lo))))))
TP = BP+SP
// GENERAL CALCULATION VARIABLES FOR STUDIES
// Workaround condition for non-reported volume securities.
evol = volume
vol = na(evol) ? 1 : iff(evol <= 0, 1, evol)
// Buy&Sell Pressure Volume (Accumulation-Distribution)
BPV = novol ? BP/TP : (BP/TP)*vol
SPV = novol ? SP/TP : (SP/TP)*vol
TPV = BPV+SPV
bpS = sum(BPV,p)
bpSum = security(tickerid,resb,bpS)
spS = sum(SPV,p)
spSum = security(tickerid,resb,spS)
// Volume Pressures Weighted Averages (Volatility nEMA)
alpha = 2/(p+1) // Original EWMA alpha - Use any Alpha Weighting of your choice to Adapt the Avg.
bpMavg = nama(BPV*(close),p,alpha) / nama(TPV,p,alpha)*2
spMavg = nama(SPV*(close),p,alpha) / nama(TPV,p,alpha)*2
VPMavg = avg(bpMavg,spMavg)
// Fractal Deviation Bands (Morphic Multiplier)
vortex = security(tickerid,resb,VPMavg)
dev = Fm
FDBvt = BolTop(vortex,p,dev)
TB1 = security(tickerid,resb,FDBvt) 
FDB1t = BolTop(FDBvt,p,dev)
TB2 = security(tickerid,resb,FDB1t)
FDB2t = BolTop(FDB1t,p,dev)
TB3 = security(tickerid,resb,FDB2t)
FDB3t = BolTop(FDB2t,p,dev)
TB4 = security(tickerid,resb,FDB3t)
FDBvb = BolBot(vortex,p,dev)
BB1 = security(tickerid,resb,FDBvb)
FDB1b = BolBot(FDBvb,p,dev)
BB2 = security(tickerid,resb,FDB1b)
FDB2b = BolBot(FDB1b,p,dev)
BB3 = security(tickerid,resb,FDB2b)
FDB3b = BolBot(FDB2b,p,dev)
BB4 = security(tickerid,resb,FDB3b)
// PLOT DIRECTIVES
TrendCol = bpSum > spSum ? black : bpSum == spSum ? gray : #ff0000
VortexCol = close >= vortex ? green : red
//Center Avg Line
va = plot(vortex, color=VortexCol, title='Vortex', style=line, linewidth=2, transp=0)
//Fractal Bands
t1 = plot(TB1, color=bc4, editable=false)
t2 = plot(TB2, color=bc3, editable=false)
t3 = plot(TB3, color=bc2, editable=false)
t4 = plot(TB4, color=bc1, editable=false)
b1 = plot(BB1, color=sc4, editable=false)
b2 = plot(BB2, color=sc3, editable=false)
b3 = plot(BB3, color=sc2, editable=false)
b4 = plot(BB4, color=sc1, editable=false)
// Cloud Background
fill(va, t1, color=bc1, transp=81, title='BullZ1')
fill(t1, t2, color=bc2, transp=81, title='BullZ2')
fill(t2, t3, color=bc3, transp=81, title='BullZ3')
fill(t3, t4, color=bc4, transp=81, title='BullZ4')
fill(va, b1, color=sc1, transp=81, title='BearZ1')
fill(b1, b2, color=sc2, transp=81, title='BearZ2')
fill(b2, b3, color=sc3, transp=81, title='BearZ3')
fill(b3, b4, color=sc4, transp=81, title='BearZ4')
barcolor(colb ? TrendCol:na, editable=false)