Created
August 11, 2017 20:47
-
-
Save pigloo/c4d145f4d18d6d0e441900e02aae92b0 to your computer and use it in GitHub Desktop.
PiggyWoo chart indicators amalgamation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
study(title='[PW] PiggyWoo', shorttitle='PW', overlay=true) | |
//###################################################################### | |
// EMA CANDLES | |
//###################################################################### | |
// vars | |
emaPeriod = input(title="GRaB: EMA Period", type=integer, defval=34) | |
showWave = input(title="GRaB: Show Wave", type=bool, defval=false) | |
// build wave | |
emaHigh = ema(high,emaPeriod) | |
emaLow = ema(low,emaPeriod) | |
emaClose = ema(close,emaPeriod) | |
emaXHigh = emaHigh+emaHigh*0.1 | |
emaXLow = emaLow-emaLow*0.1 | |
waveHigh = showWave == true ? emaHigh : na | |
waveXHigh = showWave == true ? emaXHigh : na | |
waveLow = showWave == true ? emaLow : na | |
waveXLow = showWave == true ? emaXLow : na | |
waveClose = showWave == true ? emaClose : na | |
plot(waveHigh, title="EMA High",color=#A61C00B4 ) | |
//plot(waveXHigh, title="EMA XHigh",color=#FFFFFFB4 ) | |
plot(waveLow, title="EMA Low", color=#45818EB4) | |
//plot(waveXLow, title="EMA XLow",color=#FFFFFFB4 ) | |
plot(waveClose, title="EMA Close", color=#FFFFFFB4) | |
// paint GRaB candles according to close position relative to wave | |
barcolor(close < emaLow ? close > open ? #cc4125FF : #a61c00FF : close > emaHigh ? close > open ? #76a5afFF : #45818eFF: close > open ? #c0c0c0FF : #808080FF) | |
//barcolor(close < emaXLow ? close > open ? #5b0f00FF : #85200cFF : close < emaLow ? close > open ? #cc4125FF : #a61c00FF : close > emaXHigh ? close > open ? #999999FF : #333333FF : close > emaHigh ? close > open ? #76a5afFF : #45818eFF : close > open ? #c0c0c0FF : #808080FF) | |
//###################################################################### | |
// FRACTAL SUPPORT AND RESISTANCE | |
//###################################################################### | |
DISPLAY_FSR = input(title='Show Fractal Support and Resistance ?', type=bool, defval=false) | |
tf = input(title="Resolution", type=resolution, defval = "current") | |
vamp = input(title="VolumeMA", type=integer, defval=6) | |
vam = sma(volume, vamp) | |
up = high[3]>high[4] and high[4]>high[5] and high[2]<high[3] and high[1]<high[2] and volume[3]>vam[3] | |
down = low[3]<low[4] and low[4]<low[5] and low[2]>low[3] and low[1]>low[2] and volume[3]>vam[3] | |
fractalup = up ? high[3] : fractalup[1] | |
fractaldown = down ? low[3] : fractaldown[1] | |
fuptf = not DISPLAY_FSR ? na : security(tickerid,tf == "current" ? period : tf, fractalup) | |
fdowntf = not DISPLAY_FSR ? na : security(tickerid,tf == "current" ? period : tf, fractaldown) | |
plot(fuptf, "FractalUp", color=#A61C00B4, linewidth=1, style=cross, transp=0, offset =-3, join=false) | |
plot(fdowntf, "FractalDown", color=#45818EB4, linewidth=1, style=cross, transp=0, offset=-3, join=false) | |
//###################################################################### | |
//###################################################################### | |
// Pivots MTF | |
//###################################################################### | |
//###################################################################### | |
//###################################################################### | |
// Inputs | |
//###################################################################### | |
DISPLAY_W = input(title='Show Weekly Pivot Lines ?', type=bool, defval=false) | |
DISPLAY_M = input(title='Show Monthly Pivot Lines ?', type=bool, defval=false) | |
DISPLAY_Y = input(title='Show Yearly Pivot Lines ?', type=bool, defval=false) | |
DISPLAY_S1R1 = input(title='Show S1/R1 ?', type=bool, defval=true) | |
//###################################################################### | |
// Security Data | |
//###################################################################### | |
w_high = not DISPLAY_W ? na : security(tickerid, 'W', high[1]) | |
w_low = not DISPLAY_W ? na : security(tickerid, 'W', low[1]) | |
w_pivot = not DISPLAY_W ? na : security(tickerid, 'W', hlc3[1]) | |
m_high = not DISPLAY_M ? na : security(tickerid, 'M', high[1]) | |
m_low = not DISPLAY_M ? na : security(tickerid, 'M', low[1]) | |
m_pivot = not DISPLAY_M ? na : security(tickerid, 'M', hlc3[1]) | |
//m_pivot = not DISPLAY_M ? na : offset(security(tickerid,"M", hlc3[0], barmerge.gaps_off, barmerge.lookahead_off),2) | |
y_high = not DISPLAY_Y ? na : security(tickerid, '12M', high[1]) | |
y_low = not DISPLAY_Y ? na : security(tickerid, '12M', low[1]) | |
y_pivot = not DISPLAY_Y ? na : security(tickerid, '12M', hlc3[1]) | |
//###################################################################### | |
// Calculate S/R | |
//###################################################################### | |
// SR1 | |
w_resistance1 = (not DISPLAY_W) or (not DISPLAY_S1R1) ? na : (w_pivot * 2) - w_low | |
w_support1 = (not DISPLAY_W) or (not DISPLAY_S1R1) ? na : (w_pivot * 2) - w_high | |
m_resistance1 = (not DISPLAY_M) or (not DISPLAY_S1R1) ? na : (m_pivot * 2) - m_low | |
m_support1 = (not DISPLAY_M) or (not DISPLAY_S1R1) ? na : (m_pivot * 2) - m_high | |
y_resistance1 = (not DISPLAY_Y) or (not DISPLAY_S1R1) ? na : (y_pivot * 2) - y_low | |
y_support1 = (not DISPLAY_Y) or (not DISPLAY_S1R1) ? na : (y_pivot * 2) - y_high | |
//###################################################################### | |
// Outputs | |
//###################################################################### | |
// P | |
plot(title='WP', series=w_pivot, color=change(w_pivot)!=0?na:#FFFFFFB4, linewidth=2) | |
plot(title='MP', series=m_pivot, color=change(m_pivot)!=0?na:#FFFFFFB4, linewidth=4) | |
plot(title='YP', series=y_pivot, color=change(y_pivot)!=0?na:#FFFFFFB4, linewidth=8) | |
// SR1 | |
plot(title='WR1', series=w_resistance1, color=change(w_resistance1)!=0?na:#a61c0064, linewidth=2) | |
plot(title='WS1', series=w_support1 , color=change(w_support1)!=0?na:#45818e64 , linewidth=2) | |
plot(title='MR1', series=m_resistance1, color=change(m_resistance1)!=0?na:#a61c0064, linewidth=4) | |
plot(title='MS1', series=m_support1 , color=change(m_support1)!=0?na:#45818e64 , linewidth=4) | |
plot(title='YR1', series=y_resistance1, color=change(y_resistance1)!=0?na:#a61c0064, linewidth=8) | |
plot(title='YS1', series=y_support1 , color=change(y_support1)!=0?na:#45818e64 , linewidth=8) | |
//###################################################################### | |
//###################################################################### | |
// VECTOR FLOW CHANNELS | |
//###################################################################### | |
//###################################################################### | |
DISPLAY_VF = input(title='Show Vector Flow Channels ?', type=bool, defval=false) | |
//###################################################################### | |
// VECTOR FLOW CHANNEL 1 | |
//###################################################################### | |
decay = atr(10)*0.005 | |
VF1_stage1 = 8 | |
VF1_stage2 = 16 | |
VF1_stage3 = 32 | |
VF1_stage1length = 32 | |
VF1_stage2length = VF1_stage1length + 16 | |
VF1_pretopvector01 = nz(VF1_topvector01[1], close) | |
VF1_topvector01 = not DISPLAY_VF ? na : close >= VF1_pretopvector01 ? close : VF1_pretopvector01 - (decay * VF1_topvector01finalcounter[1]) | |
VF1_topvector01counter = n - valuewhen(close >= VF1_topvector01, n, 0) | |
VF1_topvector01finalcounter = VF1_topvector01counter <= VF1_stage1length ? VF1_stage1 : VF1_topvector01counter <= VF1_stage2length ? VF1_stage2 : VF1_stage3 | |
VF1_prebotvector01 = nz(VF1_botvector01[1], close) | |
VF1_botvector01 = not DISPLAY_VF ? na : close <= VF1_prebotvector01 ? close : VF1_prebotvector01 + (decay * VF1_botvector01finalcounter[1]) | |
VF1_botvector01counter = n - valuewhen(close <= VF1_botvector01, n, 0) | |
VF1_botvector01finalcounter = VF1_botvector01counter <= VF1_stage1length ? VF1_stage1 : VF1_botvector01counter <= VF1_stage2length ? VF1_stage2 : VF1_stage3 | |
VF1_pt = plot(VF1_topvector01, color=(VF1_topvector01 == close ? na : black)) | |
VF1_pb = plot(VF1_botvector01, color=(VF1_botvector01 == close ? na : black)) | |
fill(VF1_pt, VF1_pb, color=#ffffff, transp=98, title="Vector Flow Fill 1") | |
//###################################################################### | |
// VECTOR FLOW CHANNEL 2 | |
//###################################################################### | |
VF2_stage1 = 32 | |
VF2_stage2 = 16 | |
VF2_stage3 = 8 | |
VF2_stage1length = 16 | |
VF2_stage2length = VF2_stage1length + 32 | |
VF2_pretopvector01 = nz(VF2_topvector01[1], close) | |
VF2_topvector01 = not DISPLAY_VF ? na : close >= VF2_pretopvector01 ? close : VF2_pretopvector01 - (decay * VF2_topvector01finalcounter[1]) | |
VF2_topvector01counter = n - valuewhen(close >= VF2_topvector01, n, 0) | |
VF2_topvector01finalcounter = VF2_topvector01counter <= VF2_stage1length ? VF2_stage1 : VF2_topvector01counter <= VF2_stage2length ? VF2_stage2 : VF2_stage3 | |
VF2_prebotvector01 = nz(VF2_botvector01[1], close) | |
VF2_botvector01 = not DISPLAY_VF ? na : close <= VF2_prebotvector01 ? close : VF2_prebotvector01 + (decay * VF2_botvector01finalcounter[1]) | |
VF2_botvector01counter = n - valuewhen(close <= VF2_botvector01, n, 0) | |
VF2_botvector01finalcounter = VF2_botvector01counter <= VF2_stage1length ? VF2_stage1 : VF2_botvector01counter <= VF2_stage2length ? VF2_stage2 : VF2_stage3 | |
VF2_pt = plot(VF2_topvector01, color=(VF2_topvector01 == close ? na : black)) | |
VF2_pb = plot(VF2_botvector01, color=(VF2_botvector01 == close ? na : black)) | |
fill(VF2_pt, VF2_pb, color=#ffffff, transp=98, title="Vector Flow Fill 2") | |
//###################################################################### | |
// VECTOR FLOW CHANNEL 3 | |
//###################################################################### | |
VF3_stage1 = 16 | |
VF3_stage2 = 8 | |
VF3_stage3 = 16 | |
VF3_stage1length = 32 | |
VF3_stage2length = VF3_stage1length + 32 | |
VF3_pretopvector01 = nz(VF3_topvector01[1], close) | |
VF3_topvector01 = not DISPLAY_VF ? na : close >= VF3_pretopvector01 ? close : VF3_pretopvector01 - (decay * VF3_topvector01finalcounter[1]) | |
VF3_topvector01counter = n - valuewhen(close >= VF3_topvector01, n, 0) | |
VF3_topvector01finalcounter = VF3_topvector01counter <= VF3_stage1length ? VF3_stage1 : VF3_topvector01counter <= VF3_stage2length ? VF3_stage2 : VF3_stage3 | |
VF3_prebotvector01 = nz(VF3_botvector01[1], close) | |
VF3_botvector01 = not DISPLAY_VF ? na : close <= VF3_prebotvector01 ? close : VF3_prebotvector01 + (decay * VF3_botvector01finalcounter[1]) | |
VF3_botvector01counter = n - valuewhen(close <= VF3_botvector01, n, 0) | |
VF3_botvector01finalcounter = VF3_botvector01counter <= VF3_stage1length ? VF3_stage1 : VF3_botvector01counter <= VF3_stage2length ? VF3_stage2 : VF3_stage3 | |
VF3_pt = plot(VF3_topvector01, color=(VF3_topvector01 == close ? na : black)) | |
VF3_pb = plot(VF3_botvector01, color=(VF3_botvector01 == close ? na : black)) | |
fill(VF3_pt, VF3_pb, color=#ffffff, transp=98, title="Vector Flow Fill 3") | |
//###################################################################### | |
// VECTOR FLOW CHANNEL 4 | |
//###################################################################### | |
VF4_stage1 = 32 | |
VF4_stage2 = 32 | |
VF4_stage3 = 32 | |
VF4_stage1length = 32 | |
VF4_stage2length = VF4_stage1length + 32 | |
VF4_pretopvector01 = nz(VF4_topvector01[1], close) | |
VF4_topvector01 = not DISPLAY_VF ? na : close >= VF4_pretopvector01 ? close : VF4_pretopvector01 - (decay * VF4_topvector01finalcounter[1]) | |
VF4_topvector01counter = n - valuewhen(close >= VF4_topvector01, n, 0) | |
VF4_topvector01finalcounter = VF4_topvector01counter <= VF4_stage1length ? VF4_stage1 : VF4_topvector01counter <= VF4_stage2length ? VF4_stage2 : VF4_stage3 | |
VF4_prebotvector01 = nz(VF4_botvector01[1], close) | |
VF4_botvector01 = not DISPLAY_VF ? na : close <= VF4_prebotvector01 ? close : VF4_prebotvector01 + (decay * VF4_botvector01finalcounter[1]) | |
VF4_botvector01counter = n - valuewhen(close <= VF4_botvector01, n, 0) | |
VF4_botvector01finalcounter = VF4_botvector01counter <= VF4_stage1length ? VF4_stage1 : VF4_botvector01counter <= VF4_stage2length ? VF4_stage2 : VF4_stage3 | |
VF4_pt = plot(VF4_topvector01, color=(VF4_topvector01 == close ? na : black)) | |
VF4_pb = plot(VF4_botvector01, color=(VF4_botvector01 == close ? na : black)) | |
fill(VF4_pt, VF4_pb, color=#3d85c6, transp=98, title="Vector Flow Fill 4") | |
//###################################################################### | |
// VECTOR FLOW CHANNEL 5 | |
//###################################################################### | |
VF5_stage1 = 16 | |
VF5_stage2 = 16 | |
VF5_stage3 = 16 | |
VF5_stage1length = 16 | |
VF5_stage2length = VF5_stage1length + 16 | |
VF5_pretopvector01 = nz(VF5_topvector01[1], close) | |
VF5_topvector01 = not DISPLAY_VF ? na : close >= VF5_pretopvector01 ? close : VF5_pretopvector01 - (decay * VF5_topvector01finalcounter[1]) | |
VF5_topvector01counter = n - valuewhen(close >= VF5_topvector01, n, 0) | |
VF5_topvector01finalcounter = VF5_topvector01counter <= VF5_stage1length ? VF5_stage1 : VF5_topvector01counter <= VF5_stage2length ? VF5_stage2 : VF5_stage3 | |
VF5_prebotvector01 = nz(VF5_botvector01[1], close) | |
VF5_botvector01 = not DISPLAY_VF ? na : close <= VF5_prebotvector01 ? close : VF5_prebotvector01 + (decay * VF5_botvector01finalcounter[1]) | |
VF5_botvector01counter = n - valuewhen(close <= VF5_botvector01, n, 0) | |
VF5_botvector01finalcounter = VF5_botvector01counter <= VF5_stage1length ? VF5_stage1 : VF5_botvector01counter <= VF5_stage2length ? VF5_stage2 : VF5_stage3 | |
VF5_pt = plot(VF5_topvector01, color=(VF5_topvector01 == close ? na : black)) | |
VF5_pb = plot(VF5_botvector01, color=(VF5_botvector01 == close ? na : black)) | |
fill(VF5_pt, VF5_pb, color=#3d85c6, transp=98, title="Vector Flow Fill 5") | |
//###################################################################### | |
// VECTOR FLOW CHANNEL 6 | |
//###################################################################### | |
VF6_stage1 = 8 | |
VF6_stage2 = 8 | |
VF6_stage3 = 8 | |
VF6_stage1length = 8 | |
VF6_stage2length = VF6_stage1length + 8 | |
VF6_pretopvector01 = nz(VF6_topvector01[1], close) | |
VF6_topvector01 = not DISPLAY_VF ? na : close >= VF6_pretopvector01 ? close : VF6_pretopvector01 - (decay * VF6_topvector01finalcounter[1]) | |
VF6_topvector01counter = n - valuewhen(close >= VF6_topvector01, n, 0) | |
VF6_topvector01finalcounter = VF6_topvector01counter <= VF6_stage1length ? VF6_stage1 : VF6_topvector01counter <= VF6_stage2length ? VF6_stage2 : VF6_stage3 | |
VF6_prebotvector01 = nz(VF6_botvector01[1], close) | |
VF6_botvector01 = not DISPLAY_VF ? na : close <= VF6_prebotvector01 ? close : VF6_prebotvector01 + (decay * VF6_botvector01finalcounter[1]) | |
VF6_botvector01counter = n - valuewhen(close <= VF6_botvector01, n, 0) | |
VF6_botvector01finalcounter = VF6_botvector01counter <= VF6_stage1length ? VF6_stage1 : VF6_botvector01counter <= VF6_stage2length ? VF6_stage2 : VF6_stage3 | |
VF6_pt = plot(VF6_topvector01, color=(VF6_topvector01 == close ? na : black)) | |
VF6_pb = plot(VF6_botvector01, color=(VF6_botvector01 == close ? na : black)) | |
fill(VF6_pt, VF6_pb, color=#3d85c6, transp=98, title="Vector Flow Fill 6") | |
//###################################################################### | |
// VECTOR FLOW CHANNEL 7 | |
//###################################################################### | |
VF7_stage1 = 4 | |
VF7_stage2 = 4 | |
VF7_stage3 = 4 | |
VF7_stage1length = 4 | |
VF7_stage2length = VF7_stage1length + 4 | |
VF7_pretopvector01 = nz(VF7_topvector01[1], close) | |
VF7_topvector01 = not DISPLAY_VF ? na : close >= VF7_pretopvector01 ? close : VF7_pretopvector01 - (decay * VF7_topvector01finalcounter[1]) | |
VF7_topvector01counter = n - valuewhen(close >= VF7_topvector01, n, 0) | |
VF7_topvector01finalcounter = VF7_topvector01counter <= VF7_stage1length ? VF7_stage1 : VF7_topvector01counter <= VF7_stage2length ? VF7_stage2 : VF7_stage3 | |
VF7_prebotvector01 = nz(VF7_botvector01[1], close) | |
VF7_botvector01 = not DISPLAY_VF ? na : close <= VF7_prebotvector01 ? close : VF7_prebotvector01 + (decay * VF7_botvector01finalcounter[1]) | |
VF7_botvector01counter = n - valuewhen(close <= VF7_botvector01, n, 0) | |
VF7_botvector01finalcounter = VF7_botvector01counter <= VF7_stage1length ? VF7_stage1 : VF7_botvector01counter <= VF7_stage2length ? VF7_stage2 : VF7_stage3 | |
VF7_pt = plot(VF7_topvector01, color=(VF7_topvector01 == close ? na : black)) | |
VF7_pb = plot(VF7_botvector01, color=(VF7_botvector01 == close ? na : black)) | |
fill(VF7_pt, VF7_pb, color=#3d85c6, transp=98, title="Vector Flow Fill 7") | |
//###################################################################### | |
// VECTOR FLOW CHANNEL 8 | |
//###################################################################### | |
VF8_stage1 = 2 | |
VF8_stage2 = 2 | |
VF8_stage3 = 2 | |
VF8_stage1length = 2 | |
VF8_stage2length = VF8_stage1length + 2 | |
VF8_pretopvector01 = nz(VF8_topvector01[1], close) | |
VF8_topvector01 = not DISPLAY_VF ? na : close >= VF8_pretopvector01 ? close : VF8_pretopvector01 - (decay * VF8_topvector01finalcounter[1]) | |
VF8_topvector01counter = n - valuewhen(close >= VF8_topvector01, n, 0) | |
VF8_topvector01finalcounter = VF8_topvector01counter <= VF8_stage1length ? VF8_stage1 : VF8_topvector01counter <= VF8_stage2length ? VF8_stage2 : VF8_stage3 | |
VF8_prebotvector01 = nz(VF8_botvector01[1], close) | |
VF8_botvector01 = not DISPLAY_VF ? na : close <= VF8_prebotvector01 ? close : VF8_prebotvector01 + (decay * VF8_botvector01finalcounter[1]) | |
VF8_botvector01counter = n - valuewhen(close <= VF8_botvector01, n, 0) | |
VF8_botvector01finalcounter = VF8_botvector01counter <= VF8_stage1length ? VF8_stage1 : VF8_botvector01counter <= VF8_stage2length ? VF8_stage2 : VF8_stage3 | |
VF8_pt = plot(VF8_topvector01, color=(VF8_topvector01 == close ? na : black)) | |
VF8_pb = plot(VF8_botvector01, color=(VF8_botvector01 == close ? na : black)) | |
fill(VF8_pt, VF8_pb, color=#3d85c6, transp=98, title="Vector Flow Fill 8") | |
//###################################################################### | |
// VECTOR FLOW CHANNEL 9 | |
//###################################################################### | |
VF9_stage1 = 1 | |
VF9_stage2 = 1 | |
VF9_stage3 = 1 | |
VF9_stage1length = 1 | |
VF9_stage2length = VF9_stage1length + 1 | |
VF9_pretopvector01 = nz(VF9_topvector01[1], close) | |
VF9_topvector01 = not DISPLAY_VF ? na : close >= VF9_pretopvector01 ? close : VF9_pretopvector01 - (decay * VF9_topvector01finalcounter[1]) | |
VF9_topvector01counter = n - valuewhen(close >= VF9_topvector01, n, 0) | |
VF9_topvector01finalcounter = VF9_topvector01counter <= VF9_stage1length ? VF9_stage1 : VF9_topvector01counter <= VF9_stage2length ? VF9_stage2 : VF9_stage3 | |
VF9_prebotvector01 = nz(VF9_botvector01[1], close) | |
VF9_botvector01 = not DISPLAY_VF ? na : close <= VF9_prebotvector01 ? close : VF9_prebotvector01 + (decay * VF9_botvector01finalcounter[1]) | |
VF9_botvector01counter = n - valuewhen(close <= VF9_botvector01, n, 0) | |
VF9_botvector01finalcounter = VF9_botvector01counter <= VF9_stage1length ? VF9_stage1 : VF9_botvector01counter <= VF9_stage2length ? VF9_stage2 : VF9_stage3 | |
VF9_pt = plot(VF9_topvector01, color=(VF9_topvector01 == close ? na : black)) | |
VF9_pb = plot(VF9_botvector01, color=(VF9_botvector01 == close ? na : black)) | |
fill(VF9_pt, VF9_pb, color=#a61c00, transp=98, title="Vector Flow Fill 9") | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment