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:
CHANGE LOG:
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
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
// * 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)
Related Ideas
Alphaoptions
I would seem that looking at directional volume coinciding with the levels and your would be important? Can it be a stand alone sub-panel rather than building into the main script? Is the BSVP script available to also do similar analysis?
Reply
xel_arjona
Alphaoptions
@Alphaoptions Indeed, Im in the process of separate each element from this indicators (which I personally use) The BSVP contains the main Buyers(GreenBars)/Sellers(RedBars) Pressure algorithm (Without the FRACTAL BANDS derived from a constructed "average" from both buy and Sell pressure algorithm by Vadim Gimelfarb -Accumulation/Distribution-) to display in RAW data the Volume (Effort from each side) expressed in relationship of the movement of price (Result given by such effort) in candles (Open as LastClose-HLC) as a ratio of Winners (+0) from Lossers (-0). This BSVP script have the option to render this information with a smoothed factor or averages in the form of an Oscillator. The original script have evolved and only shows an histogram of the "Convergence/Divergence" from the averages of the Buying Pressure / Selling P.
Reply
Alphaoptions
xel_arjona
I am following your work and eagerly anticipate the release of whatever you feel able to share. We can learn and follow along with you as you make progress. Feel free to share the pieces as you go because those of us following you will be able to do so incrementally. Even if not perfected in each shared piece or beta, we can still track thorough the various stages. I feel using the AccumDistrib in bands is brilliant and quite novel approach. So now we need other indicators to assess what happens at each successive band - then we learn to trade them as breakthroughs or fades of the various levels. I ma thinking fading volume is a fade and building is trade through, especially on retest, but since this is so new I am not really sure. I am also wondering if these emerge to be not only support-resistance but also targets / magnets. It looks like your BSVP does a reasonable job too. Great job!
Reply
xel_arjona
Alphaoptions
@Alphaoptions WOW... Cheers Man! Thanks for your words! Im a fan of "Open approach" of doing things, like in the Free Software foundation! If technology (as ideas) are not shared, they cannot be improved (evolve). In fact the BSVP was the genesis of the bands, and U touch the point! As I planed to use the GoldenRatio (and the Plastic number to) as the multiplication factor of the distribution in form of Standard Deviations in a fractal way in favor of replicate nature (each one as the genesis of the newer ones), at first sight they act like "Magnets" when price tend to swing or rest more than hard support or resistance lines. My current work is to fetch for what could be the best harmonic first line (VORTEX) of genesis for the Fractal Deviation Bands; and as far as I notice from other lines (Simple, Exponential's, McGinley and currently coding FRAMA), the BuyToSell Pressure Mid line, which is just the average of the Buy to Sell cloud conformed by averages of buying pressure and selling pressure lines, currently shows me the most harmonic "magnets" on the bands for nearly every timeframe and securities. Anyway, that's why I like to share this work in favor to have feedback of observation from all of you guys! Next work will be focused on acceleration/deceleration factor of the bands in terms of an oscillator.... Then, I think will time to rest for new ideas and time to observation to find Patterns from this indicators! :D
Reply
fahadx9
thanks man
Reply
AdamSragovicz
PRO
Nice - what is the BSVP_XeL study on the bottom?
Reply
xel_arjona
AdamSragovicz
It's an oscillator derived from my core "Accumulation/Distribution" algorithm in which this indicator is constructed:
Reply
coondawg71
PRO
nice work!
Reply
xel_arjona
coondawg71
Thanks...! @coondawg71
Reply
IvanLabrie
PRO
xel_arjona
Indeed, looks interesting.
Reply