o1638614593

//@version=5 indicator("xau m5 ddang alfm (Wyckoff)", overlay=

FOREXCOM:XAUUSD   Vàng / Đô la Mỹ
//@version=5

indicator("xau m5 ddang alfm (Wyckoff)", overlay= true, scale= scale.none, max_labels_count= 1)
// ———————————————————— Inputs {
color decvol = input.color(#000000FF, "Hollow Candle (Decreasing Volume)", group= "The Lie Detector")
color hivolup = input(color.new(#00FF00, 0), "Up Candle (Increasing Volume + Over VolumeMA)", group= "The Lie Detector")
color hivoldn = input.color(color.new(#FF0000, 0), "Dn Candle (Increasing Volume + Over VolumeMA)", group= "The Lie Detector")
int length = input.int(20, "VolumeMA length", inline= "01", group= "The Lie Detector")
bool useEma = input.bool(true, "Use EMA", inline= "01", group= "The Lie Detector")
color vMAclr = input.color(color.blue, "  ", inline= "01", group= "The Lie Detector")

float f = input.float(1.4, "Factor for Volume Density ", inline= "00", group= "Volume Analysis", step= 0.1)
color vpclr = color.white//input.color(color.white, "", inline= "00", group= "Volume Analysis")
// }

// ———————————————————— Global Date {
vol = volume
hl = high - low
vp = vol/hl // volume density
var float scaleMax = array.new_float() // not varip
// }

// ———————————————————— Functions {
// ----- Bar coloring cal (The Lie Detector)
upVol = ta.rising(vol, 1)
upBar = close > open

vMA = useEma ? ta.ema(vol, length) : ta.sma(vol, length)
volOverMa = vol > vMA // to decide Large volume

hollowBgdBlack = not upVol
upVolUpMaUpBar = upVol and volOverMa and upBar
upVolUpMaDnBar = upVol and volOverMa and not upBar

chollowBgdBlack = hollowBgdBlack ? decvol : na
cUpVolUpMaUpBar = upVolUpMaUpBar ? hivolup : na
cUpVolUpMaDnBar = upVolUpMaDnBar ? hivoldn : na
volumeclr = hollowBgdBlack ? color(na) : upBar ? upVolUpMaUpBar ? hivolup : color.new(hivolup, 70) : upVolUpMaDnBar ? hivoldn : color.new(hivoldn, 70)

// ------ Volume Density Cal
vpMA = useEma ? ta.ema(vp, length) : ta.sma(vp, length) // use VolumeMAtype and VolumeMA length
vpS = vp > vpMA * f and vp <= vpMA * f * f ? vol : na // small vp
vpL = vp > vpMA * f * f ? vol : na // large vp

// ------ Scale Adjustment Cal
array.push(scaleMax, vol)
if array.size(scaleMax) > length * 4
array.shift(scaleMax)

scalebase = array.max(scaleMax) // get max large volume
upperline = scalebase * 4 // max large volume become 1/4 position
// }

// ———————————————————— Outputs {
barcolor(hollowBgdBlack ? chollowBgdBlack : na, title= "Hollow candle")
barcolor(upVolUpMaUpBar ? cUpVolUpMaUpBar : na, title= "Up candle")
barcolor(upVolUpMaDnBar ? cUpVolUpMaDnBar : na, title= "Dn candle")

plot(vol, color= close > open ? hivolup : hivoldn, style= plot.style_stepline, linewidth= 1, title= "Volume")
plot(vol, style= plot.style_columns, color= volumeclr, title= "Enough and Large Volume")

plot(vMA, color= vMAclr, title= "VolumeMA")
// }



// ========================= Volume Flow ============================
float x = input.float(5, "Factor for Volume Spike ", inline= "02", group= "Volume Analysis", step= 0.1)

// Bull and Bear Volume Cal
bull = upVol and upBar ? vol : 0 // not include decreasing upBar volume
bear = upVol and not upBar ? vol : 0 // not include decreasing upBar volume

//Bull and Bear MA Cal
bullma = useEma ? ta.ema(bull, length) : ta.sma(bull, length)
bearma = useEma ? ta.ema(bear, length) : ta.sma(bear, length)

// MA dif
vf_dif = bullma - bearma
vf_absolute = vf_dif > 0 ? vf_dif : vf_dif * (-1)

// Volume Spikes
gsig= ta.crossover(bull, bullma * x) ? vol : na
rsig = ta.crossover(bear, bearma * x) ? vol : na

// Color Cal
vdClr = vf_dif > 0 ? color.new(hivolup, 50) : color.new(hivoldn, 50)

plot(vf_absolute, style= plot.style_area, color= vdClr, title= "Volume Flow")
plotchar(gsig, char= "💡", color= hivolup, location= location.absolute, title= "Bull Vol Spike")
plotchar(rsig, char= "💡", color= hivoldn, location= location.absolute, title= "Bear Vol Spike")

// ================================================================

plotchar(vpS, char= "⬜", color= color.new(vpclr, 50), location= location.bottom, title= "Volume Density(small)")
plotchar(vpL, char= "⬜", color= vpclr, location= location.bottom, title= "Volume Density(large)")

plot(upperline, color= color(na), title= "Scale Adjustment")


// Tính toán EMA 100
ema100 = ta.ema(close, 27)
ema8 = ta.ema(close, 8)
ema10 = ta.ema(close, 6)
sma5 = ta.sma(close,8)
emamax = ta.ema(close, 68*6)
//plot(sma5, color=sma5 < sma5 ? color.rgb(255, 65, 65) : color.rgb(255, 255, 255), linewidth=1)
// Tạo biến màu
var color emaColor = na

// So sánh giá trị EMA hiện tại và EMA trước đó
if ema100 > ema100
emaColor := color.green
else if ema100 < ema100
emaColor := color.red
var float stoplossbuy = 0.0
var float stoplosssell = 0.0
var float thannen = 0.0
var float raunentren = 0.0
var float raunenduoi = 0.0
if close > open
raunentren := high - close
raunenduoi := open - low
if close < open
raunentren := high - open
raunenduoi := close - low
thannen := math.abs(close - open)
spread = math.abs(high - low)
var int sos = 0
var int sow = 0
//điểm mạnh :
//1. Down Thrust ( Lực đẩy xuống)
SDownThrust = raunenduoi >= 3*thannen and volume > volume and volume > volume and low <= ta.lowest(4) and spread > ta.sma(spread,5) and raunentren < raunenduoi/2 and volume > vMA
if SDownThrust
sos := sos + 1
//2. Selling Climax ( Cao trào bán)
SSellingClimax = close<open and thannen > thannen and thannen + raunenduoi >= ta.highest(ta.sma(thannen+raunenduoi,5),12) and (raunenduoi<thannen and raunenduoi>0.25*thannen) and volume > 1.4*vMA and volume > volume and volume > volume
if SSellingClimax
sos := sos + 1
//3. Nỗ lực giảm giá nhỏ hơn kết quả giảm giá
Seffortresultmanh = close<open and ((volume < volume and close < open and thannen>thannen and thannen>= ta.sma(thannen,4)) or (volume < volume and thannen>= ta.sma(thannen,4) and thannen > thannen and close < open))
if Seffortresultmanh
sos := sos + 1
//4. Nỗ lực giảm giá > kết quả giảm giá
Sresulteffortmanh = close<open and raunenduoi<thannen and raunentren < thannen and ((volume > volume and thannen < thannen and close < open and thannen>= ta.highest(ta.sma(thannen,5),5)) or (volume > volume and thannen < thannen and volume > vMA and close < open))
if Sresulteffortmanh
sos := sos + 1
//5. Không có nguồn cung ( No Supply Bar) tiếp diễn xu hướng
SNoSupplyBar = close < open and not rsig and thannen <= 0.5*ta.sma(thannen,5) and raunenduoi > raunentren and volume<volume and volume<volume and ema100 - ema100 > 0 and vf_dif > 0
if SNoSupplyBar
sos := sos + 1
//6. Nến giả lực đẩy xuống ( Pseudo downthrust bar)
SPseudodownthrustbar = close < open and not SNoSupplyBar and not rsig and thannen <= ta.lowest(ta.sma(thannen,5),5) and raunentren > raunenduoi and volume<volume and volume<volume and ema100 - ema100 > 0 and vf_dif > 0
if SPseudodownthrustbar
sos := sos + 1
//7. Nến giả lực đẩy xuống đảo ngược ( Pseudo Inverse downthrust)
SPseudoInversedownthrust = close < open and not SNoSupplyBar and not rsig and thannen <= ta.lowest(ta.sma(thannen,5),5) and raunenduoi > raunentren and volume<volume and volume<volume and ema100 - ema100 > 0 and vf_dif > 0

//8. Nến lực đẩy xuống ngược ( Inverse Down Thrust)
SInverseDownThrust = raunentren >= 3*thannen and vf_dif < 0 and ((volume > volume and volume > volume and volume > vMA) or volume > 1.4*vMA) and spread > ta.sma(spread,5) and raunenduoi < raunentren/2
if SInverseDownThrust
sos := sos + 1
//9. Nỗ lực thất bại của cao trào bán ( Failed effort Selling Climax)
SFailedeffortSellingClimax = SSellingClimax and (close< open or close< open) and (thannen<thannen or thannen<thannen) and close>open and close>open and volume>vMA and volume>vMA and volume>vMA and (volume>vMA or volume>vMA) and (volume>volume or volume>volume)
if SFailedeffortSellingClimax
sos := sos + 1
//điểm yếu
//1. UpThrust ( Lực đẩy lên)
WUpThrust = raunentren >= 3*thannen and volume > 1.2 * volume and volume > volume and high >= ta.highest(6) and raunenduoi < raunentren/2 and volume > vMA
if WUpThrust
sow := sow + 1
//2. Buying Climax ( Cao trào mua)
WBuyingClimax = close>open and thannen > thannen and thannen + raunentren>= ta.highest(ta.sma(thannen+raunentren,5),12) and (raunentren<thannen*0.7 and raunentren>0.25*thannen) and ((volume > 1.4*vMA ) )
if WBuyingClimax
sow := sow + 1
//3. Nỗ lực tăng giá < Kết Quả tăng giá ( Bullish effort < Bullish result)
Wresulteffortyeu = close>open and ((volume < volume and thannen > thannen and close > open and thannen>= ta.sma(thannen,5)) or (volume < volume and thannen>= ta.sma(thannen,6) and thannen > thannen and volume > vMA and close > open))
if Wresulteffortyeu
sow := sow + 1
//4. Nỗ Lực tăng giá > Kết quả tăng giá ( Bullish effort > Bullish result)
Weffortresultyeu = close>open and raunentren<thannen and ((volume > volume and thannen < thannen and close > open and thannen>= ta.highest(ta.sma(thannen,5),5)) or (volume > volume and thannen < thannen and volume > vMA and close > open))
// sau khi mở lệnh nếu nến sau đó không phá được thân nến hoặc không giảm 1 mức tương đối thì đóng lệnh
if Weffortresultyeu
sow := sow + 1
//5. Không có nhu cầu ( No Demand Bar)
WNoDemandBar = close > open and not gsig and thannen <= 0.7*ta.sma(thannen,5) and raunentren > raunenduoi and ((volume<volume and volume<volume) or (volume<volume and volume<volume)) and ema100 - ema100 < 0 and vf_dif < 0
//loại bỏ tín hiệu nếu trước đó liền kề là bull spike hoặc trong xu hướng tăng lớn hoặc đảo chiều từ tiichs lũy sang tăng
if WNoDemandBar
sow := sow + 1
//6. Lực đẩy lên giả ( Pseudo Upthrust)
WPseudoUpthrust = close > open and close > open and not gsig and not gsig and thannen <= ta.lowest(ta.sma(thannen,5),5) and raunenduoi > raunentren and ((volume<volume and volume<volume) or (volume<volume and volume<volume)) and ema100 - ema100 < 0 and vf_dif < 0
if WPseudoUpthrust
sow := sow + 1
//7. Lực đẩy tăng giả ngược ( Inverse Pseudo Upthrust )
WInversePseudoUpthrust = close > open and not WNoDemandBar and not gsig and not gsig and thannen <= ta.lowest(ta.sma(thannen,5),5) and raunentren > raunenduoi and ((volume<volume and volume<volume) or (volume<volume and volume<volume)) and ema100 - ema100 < 0 and vf_dif < 0
if WInversePseudoUpthrust
sow := sow + 1
//8. Inverse Upthrust ( Lực đẩy tăng ngược)
WInverseUpthrust = raunenduoi >= 3*thannen and vf_dif > 0 and ((volume > volume and volume > volume and volume > vMA) or volume > 1.4*vMA) and spread > ta.sma(spread,5) and raunentren < raunenduoi/2
if WInverseUpthrust
sow := sow + 1
//9. Cao trào mua thất bại ( Failed Buying Climax)
WFailedBuyingClimax = WBuyingClimax and (close> open or close> open) and (thannen<thannen or thannen<thannen) and close<open and close<open and volume>vMA and volume>vMA and volume>vMA and (volume>vMA or volume>vMA) and (volume>volume or volume>volume)
if WFailedBuyingClimax
sow := sow + 1
// tin hieu SOS
plotshape(SDownThrust, style=shape.labeldown, location=location.abovebar, color=color.new(#046ff9, 50), size=size.small, text='1', textcolor=color.new(color.white, 0))
plotshape(SSellingClimax , style=shape.labeldown, location=location.abovebar, color=color.new(#046ff9, 50), size=size.small, text='2', textcolor=color.new(color.white, 0))
// buylimit tại low
plotshape(Seffortresultmanh, style=shape.labeldown, location=location.abovebar, color=color.new(#046ff9, 50), size=size.small, text='3', textcolor=color.new(color.white, 0))
plotshape(Sresulteffortmanh, style=shape.labeldown, location=location.abovebar, color=color.new(#046ff9, 50), size=size.small, text='4', textcolor=color.new(color.white, 0))
plotshape(SNoSupplyBar, style=shape.labeldown, location=location.abovebar, color=color.new(#046ff9, 50), size=size.small, text='5', textcolor=color.new(color.white, 0))
plotshape(SPseudodownthrustbar, style=shape.labeldown, location=location.abovebar, color=color.new(#046ff9, 50), size=size.small, text='6', textcolor=color.new(color.white, 0))
plotshape(SPseudoInversedownthrust, style=shape.labeldown, location=location.abovebar, color=color.new(#046ff9, 50), size=size.small, text='7', textcolor=color.new(color.white, 0))
// 6 dễ sai
plotshape(SInverseDownThrust, style=shape.labeldown, location=location.abovebar, color=color.new(#046ff9, 50), size=size.small, text='8', textcolor=color.new(color.white, 0))
plotshape(SFailedeffortSellingClimax , style=shape.labeldown, location=location.abovebar, color=color.new(#046ff9, 50), size=size.small, text='9', textcolor=color.new(color.white, 0))
SOSsignal1 = SDownThrust or SSellingClimax or Sresulteffortmanh or Seffortresultmanh or SNoSupplyBar or SPseudoInversedownthrust or SInverseDownThrust or SFailedeffortSellingClimax
SOSsignal2 = SSellingClimax or Sresulteffortmanh or Seffortresultmanh
//tin hieu SOW
plotshape( WUpThrust, style=shape.labeldown, location=location.abovebar, color=color.new(#f90404, 50), size=size.small, text='1', textcolor=color.new(color.white, 0))
plotshape( WBuyingClimax, style=shape.labeldown, location=location.abovebar, color=color.new(#f90404, 50), size=size.small, text='2', textcolor=color.new(color.white, 0))
// selllimit tai high
plotshape( Wresulteffortyeu, style=shape.labeldown, location=location.abovebar, color=color.new(#f90404, 50), size=size.small, text='3', textcolor=color.new(color.white, 0))
plotshape( Weffortresultyeu, style=shape.labeldown, location=location.abovebar, color=color.new(#f90404, 50), size=size.small, text='4', textcolor=color.new(color.white, 0))
plotshape( WNoDemandBar, style=shape.labeldown, location=location.abovebar, color=color.new(#f90404, 50), size=size.small, text='5', textcolor=color.new(color.white, 0))
plotshape( WPseudoUpthrust, style=shape.labeldown, location=location.abovebar, color=color.new(#f90404, 50), size=size.small, text='6', textcolor=color.new(color.white, 0))
plotshape( WInversePseudoUpthrust, style=shape.labeldown, location=location.abovebar, color=color.new(#f90404, 50), size=size.small, text='7', textcolor=color.new(color.white, 0))
plotshape( WInverseUpthrust, style=shape.labeldown, location=location.abovebar, color=color.new(#f90404, 50), size=size.small, text='8', textcolor=color.new(color.white, 0))
plotshape( SFailedeffortSellingClimax, style=shape.labeldown, location=location.abovebar, color=color.new(#f90404, 50), size=size.small, text='9', textcolor=color.new(color.white, 0))
SOWsignal1 = WUpThrust or WBuyingClimax or Wresulteffortyeu or Weffortresultyeu or WNoDemandBar or WInverseUpthrust or SFailedeffortSellingClimax
SOWsignal2 = WBuyingClimax or Wresulteffortyeu or Weffortresultyeu

Thông báo miễn trừ trách nhiệm

Thông tin và ấn phẩm không có nghĩa là và không cấu thành, tài chính, đầu tư, kinh doanh, hoặc các loại lời khuyên hoặc khuyến nghị khác được cung cấp hoặc xác nhận bởi TradingView. Đọc thêm trong Điều khoản sử dụng.