xel_arjona

Acc/Dist. Cloud with Fractal Deviation Bands by @XeL_Arjona

ACCUMULATION / DISTRIBUTION CLOUD with MORPHIC DEVIATION BANDS
Ver. 2.0.beta.23:08: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 Vadim Gimelfarb published at Stocks & Commodities V. 21:10 (68-72).
  • Custom Weighting Coefficient for Exponential Moving Average (nEMA) adaptation work by @XeL_Arjona with contribution help from @RicardoSantos at TradingView @pinescript chat room.
  • Morphic Numbers (PHI & Plastic) Pine Script adaptation from it's algebraic generation formulas by @XeL_Arjona
  • Fractal Deviation Bands idea by @XeL_Arjona

CHANGE LOG:

  • ACCUMULATION / DISTRIBUTION CLOUD: I decided to change it's name from the Buy to Sell Pressure. The code is essentially the same as older versions and they are the center core (VORTEX?) of all derived New stuff which are:

  • MORPHIC NUMBERS: The "Golden Ratio" expressed by the result of the constant "PHI" and the newer and same in characteristics "Plastic Number" expressed as "PN". For more information about this regard take a look at: HERE!

  • CUSTOM(K) EXPONENTIAL MOVING AVERAGE: Some code has cleaned from last version to include as custom function the nEMA, which use an additional input (K) to customise the way the "exponentially" is weighted from the custom array. For the purpose of this indicator, I implement a volatility algorithm using the Average True Range of last 9 periods multiplied by the morphic number used in the fractal study. (Golden Ratio as default) The result is very similar in response to classic EMA but tend to accelerate or decelerate much more responsive with wider bars presented in trending average.

  • FRACTAL DEVIATION BANDS: The main idea is based on the so useful Standard Deviation process to create Bands in favor of a multiplier (As John Bollinger used in it's own bands) from a custom array, in which for this case is the "Volume Pressure Moving Average" as the main Vortex for the "Fractallitly", so then apply as many "Child bands" using the older one as the new calculation array using the same morphic constant as multiplier (Like Fibonacci but with other approach rather than %ratios). Results are AWSOME! Market tend to accelerate or decelerate their Trend in favor of a Fractal approach. This bands try to catch them, so please experiment and feedback me your own observations.

  • EXTERNAL TICKER FOR VOLUME DATA: I Added a way to input volume data for this kind of study from external tickers. This is just a quicky-hack given that currently TradingView is not adding Volume to their Indexes so; maybe this is temporary by now. It seems that this part of the code is conflicting with intraday timeframes, so You are advised.

This CODE is versioned as BETA FOR TESTING PROPOSES. By now TradingView Admins are changing lot's of things internally, so maybe this could conflict with correct rendering of this study with special tickers or timeframes. I will try to code by itself just the core parts of this study in order to use them at discretion in other areas. 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 TradingView accounts at: @XeL_Arjona

نص برمجي مفتوح المصدر

قام مؤلف هذا النص البرمجي بنشره وجعله مفتوح المصدر، بحيث يمكن للمتداولين فهمه والتحقق منه، وهو الأمر الذي يدخل ضمن قيم TradingView. تحياتنا للمؤلف! يمكنك استخدامه مجانًا، ولكن إعادة استخدام هذا الكود في منشور تحكمه قواعد الموقع. يمكنك جعله مفضلاً لاستخدامه على الرسم البياني.

إخلاء المسؤولية

لا يُقصد بالمعلومات والمنشورات أن تكون، أو تشكل، أي نصيحة مالية أو استثمارية أو تجارية أو أنواع أخرى من النصائح أو التوصيات المقدمة أو المعتمدة من TradingView. اقرأ المزيد في شروط الاستخدام.

هل تريد استخدام هذا النص البرمجي على الرسم البياني؟
//	* ACCUMULATION/DISTRIBUTION CLOUD with MORPHIC DEVIATION BANDS.
//    Ver. 2.0.beta.23.08.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"
//      + Custom Weighting Coefficient for Exponential Moving Average
//          adaptation (nEMA) by @XeL_Arjona with contribution help
//          at the @pinescript chat room (special mention to @RicardoSantos
//      + "Morphic Numbers" (PHI & Plastic) Pine Script addaptation
//          from it's algebraic generation formulas by @XeL_Arjona
//      + "Fractal Deviation Bands" idea by @XeL_Arjona.
//      + Color Cloud Fill Condition algorithm by @ChrisMoody
//
//      WHAT IS THIS?
//
//      The following indicators try to acknowledge in a K-I-S-S
//      approach to the eye (Keep-It-Simple-Stupid), the two most
//      important aspects of nearly every trading vehicle:
//           -- PRICE ACTION IN RELATION BY IT'S VOLUME --
//         << THEIR USE MUST BE CONSIDERED AS EXPERIMENTAL !! >>
//
//         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/Distribution Cloud with Morphic Bands by @XeL_Arjona", shorttitle="ADC_XeL", overlay=true)
p = input(title="Lookback Periods:", defval=45)
vref = input(false, title="Use Reference Symbol for Volume:")
vsym = input('QUANDL:YAHOO/INDEX_NYA', title="Reference Volume Symbol:", type=symbol)
novol = input(false, title="Calculate Pressures without Volume:")
pb = input(true, title="Show Bands:")
pbs = input(true, title="Use Fractal Deviation Bands:")
ha = input(false, title="Hide Average Line:")
colb = input(false, title="Color Trend on price bars:")
// MAIN GENERAL VARIABLES/FUNCTIONS
TR = atr(1)
// N Root Function
nroot(index,number) =>
    cond_r = index == 0 or number == 0 or number < 0
    If_True = 0
    If_False = (exp((1/index) * log(number)))
    iff(cond_r, If_True, If_False)
// nExponential Weighted Moving Average
nema(array,periods,K) =>
    nEmaK = K/(periods+1)
    nmEma = na(nmEma[1]) ? 0 : (array*nEmaK)+(nmEma[1]*(1-nEmaK))
// 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
// Workaround condition for non-reported volume securities.
evol = vref ? security(vsym,period,volume) : volume
vol = na(evol) ? 1 : iff(evol <= 0, 1, evol)
//Algebraic Constants for general calculations.
_phi = (1+sqrt(5))/2  // Phi Number (Fibonacci Seq.)
_pn = (nroot(3,(108 + 12*sqrt(69))) + nroot(3,(108 - 12*sqrt(69))))/6  // Plastic Number (Podovan Seq.)
// 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
BPV = novol ? BP/TP : (BP/TP)*vol
SPV = novol ? SP/TP : (SP/TP)*vol
TPV = BPV+SPV
// Volume Pressures Weighted Averages (Volatility nEMA)
Ptrr = ((TR)/atr(9))*_phi
bpMavg = nema(BPV*close,p,Ptrr) / nema(TPV,p,Ptrr)*2
spMavg = nema(SPV*close,p,Ptrr) / nema(TPV,p,Ptrr)*2
VPMavg = (bpMavg+spMavg)/2
// Fractal Deviation Bands (Morphic Multiplier)
FDBvt = BolTop(VPMavg,p,_phi)   // Add As many layers
FDB1t = BolTop(FDBvt,p,_phi)    //  of fractal bands at
FDB2t = BolTop(FDB1t,p,_phi)    //  will.  Each band
FDBvb = BolBot(VPMavg,p,_phi)   //  is calculated having
FDB1b = BolBot(FDBvb,p,_phi)    //  as base the last one and
FDB2b = BolBot(FDB1b,p,_phi)    //  multiplied by morphic const.
// PLOT DIRECTIVES
//Cloud coloring method by @ChrisMoody
BPAbove = bpMavg >= spMavg ? 1 : na
SPBelow = bpMavg <= spMavg ? 1 : na
BPplotU = BPAbove ? bpMavg : na
SPplotU = BPAbove ? spMavg : na
BPplotD = SPBelow ? bpMavg : na
SPplotD = SPBelow ? spMavg : na
// Standard Line TREND Coloring (Based on VolumePressure Balance)
CondCol = bpMavg > spMavg ? green : red
//Center Avg Line
plot(ha?na:VPMavg, color=CondCol, title='VPMA', style=line, linewidth=2)
//Cloud Lines Plot Statements - ***linebr to create rules for change in Shading
p1 = plot(pb and BPplotU and not pbs ? BPplotU  : na, title = 'BP/SP', style=linebr, linewidth=1, color=CondCol)
p2 = plot(pb and SPplotU and not pbs ? SPplotU  : na, title = 'SP/BP', style=linebr, linewidth=1, color=CondCol)
p3 = plot(pb and BPplotD and not pbs ? BPplotD  : na, title = 'BP/SP', style=linebr, linewidth=1, color=CondCol)
p4 = plot(pb and SPplotD and not pbs ? SPplotD  : na, title = 'SP/BP', style=linebr, linewidth=1, color=CondCol)
plot(pb and bpMavg and not pbs ? bpMavg : pb and pbs ? FDBvt : na, title = 'BPavg', style=line, linewidth=1, color=green)
plot(pb and spMavg and not pbs ? spMavg : pb and pbs ? FDBvb : na, title = 'SPavg', style=line, linewidth=1, color=red)
fill(p1, p2, color=green, transp=90, title='PCloud')
fill(p3, p4, color=red, transp=90, title='PCloud')
// Fractal Deviation Bands
plot(pb and pbs ? FDBvt : na, title = '0T', style=line, linewidth=1, transp=0, color=green)
plot(pb and pbs ? FDB1t : na, title = '1T', style=line, linewidth=1, transp=0, color=green)
plot(pb and pbs ? FDB2t : na, title = '2T', style=line, linewidth=1, transp=0, color=green)
plot(pb and pbs ? FDBvb : na, title = '0B', style=line, linewidth=1, transp=0, color=red)
plot(pb and pbs ? FDB1b : na, title = '1B', style=line, linewidth=1, transp=0, color=red)
plot(pb and pbs ? FDB2b : na, title = '2B', style=line, linewidth=1, transp=0, color=red)
barcolor(colb ? CondCol:na, editable=false)