traduzione codice TW Median Proximity Percentile
Forums › ProRealTime forum Italiano › Supporto ProBuilder › traduzione codice TW Median Proximity Percentile
- This topic has 2 replies, 2 voices, and was last updated 2 months ago by Msport71.
-
-
09/11/2024 at 10:48 AM #237486
Buongiorno,
vorrei chiedere cortese traduzione di questo codice, che sono curioso di testare.
Grazie come sempre per l’aiuto.
https://it.tradingview.com/script/YEu4VVBj-Median-Proximity-Percentile-AlgoAlpha/
// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © AlgoAlpha//@version=5
indicator(“Median Proximity Percentile [AlgoAlpha]”, “AlgoAlpha – % Median Proximity Percentile”, overlay = false, timeframe = “”, timeframe_gaps = false)// Inputs
priceSource = input.source(close, “Source”)
lookbackLength = input.int(21, minval = 1, title = “Lookback Length”)
emaLookbackLength = input.int(20, minval = 1, title = “HMA Lookback Length”)
stdDevMultiplier = 1
noise = input.bool(true, “Noise Scatterplot”)
colorUp = input.color(#00ffbb, title = “Up Color”)
colorDown = input.color(#ff1100, title = “Down Color”)// Calculations
medianValue = ta.median(priceSource, lookbackLength)
priceDeviation = (priceSource – medianValue)
standardDeviation = ta.stdev(priceDeviation, 45)
normalizedValue = priceDeviation / (standardDeviation + standardDeviation)positiveValues = normalizedValue > 0 ? normalizedValue : 0
negativeValues = normalizedValue < 0 ? normalizedValue : 0upperBoundary = ta.ema(positiveValues, lookbackLength) + ta.stdev(positiveValues, lookbackLength) * stdDevMultiplier
lowerBoundary = ta.ema(negativeValues, lookbackLength) – ta.stdev(negativeValues, lookbackLength) * stdDevMultiplierpercentileValue = 100 * (normalizedValue – lowerBoundary)/(upperBoundary – lowerBoundary) – 50
emaValue = ta.hma(percentileValue, emaLookbackLength)
// Color Conditions
plotColor = percentileValue > 0 ? colorUp :
percentileValue < 0 ? colorDown : na// Plots
plot(noise ? percentileValue : na, color = color.new(plotColor, 50), style = plot.style_circles)
hmaPlot = plot(emaValue, color = color.new(emaValue > emaValue[1] ? colorUp : colorDown, 40), title = “Hull MA”)
hmaPlot1 = plot(emaValue[1], color = color.new(emaValue > emaValue[1] ? colorUp : colorDown, 40))
zeroLine = plot(0, color = color.gray, title = “Zero Line”)
plotchar(ta.crossover(emaValue,emaValue[1]) ? emaValue : na, “Bullish Swing”, char = “o”, location = location.absolute, color = colorUp, size = size.tiny)
plotchar(ta.crossover(emaValue[1],emaValue) ? emaValue : na, “Bearish Swing”, char = “o”, location = location.absolute, color = colorDown, size = size.tiny)
plotchar(ta.crossunder(emaValue,emaValue[1]) and emaValue[1] > 90 ? 160 : na, “Bearish Reversal”, char = “▼”, location = location.absolute, color = colorDown, size = size.tiny)
plotchar(ta.crossunder(emaValue[1],emaValue) and emaValue[1] < -90 ? -160 : na, “Bullish Reversal”, char = “▲”, location = location.absolute, color = colorUp, size = size.tiny)// Hidden Levels
maxLevelPlot = plot(150, display = display.none)
minLevelPlot = plot(-150, display = display.none)
upperMidLevelPlot = plot(90, display = display.none)
lowerMidLevelPlot = plot(-90, display = display.none)// Fills
fill(maxLevelPlot, upperMidLevelPlot, top_value = 150, bottom_value = 90, top_color = color.new(colorDown, 50), bottom_color = color.new(chart.bg_color, 90))
fill(minLevelPlot, lowerMidLevelPlot, top_value = -90, bottom_value = -150, top_color = color.new(chart.bg_color, 90), bottom_color = color.new(colorUp, 50))
fill(hmaPlot, hmaPlot1, color.new(emaValue > emaValue[1] ? colorUp : colorDown, 40))// Alerts
alertcondition(ta.crossover(emaValue, 0), “Bullish Trend Shift”, “Median Proximity Percentile Crossover Zero Line”)
alertcondition(ta.crossunder(emaValue, 0), “Bearish Trend Shift”, “Median Proximity Percentile Crossunder Zero Line”)
alertcondition(ta.crossover(emaValue,emaValue[1]), “Bullish Swing”, “Median Proximity Percentile Swinging Upwards”)
alertcondition(ta.crossover(emaValue[1],emaValue), “Bearish Swing”, “Median Proximity Percentile Swinging Downwards”)
alertcondition(ta.crossunder(emaValue,emaValue[1]) and emaValue[1] > 90, “Bearish Reversal”, “Median Proximity Percentile Bearish Reversal”)
alertcondition(ta.crossunder(emaValue[1],emaValue) and emaValue[1] < -90, “Bullish Reversal”, “Median Proximity Percentile Bullish Reversal”)09/12/2024 at 12:52 PM #237525Eccolo qui:
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107//-----------------------------------------------////PRC_Median Proximity Percent//version = 0//12.09.2024//Iván González @ www.prorealcode.com//Sharing ProRealTime knowledge//-----------------------------------------------////-----Inputs------------------------------------////-----------------------------------------------//priceSource=closelookbacklength=21emalookbacklength=20stdDevMultiplier=1noise=1//-----------------------------------------------////-----Calculations------------------------------////-----------------------------------------------////-Median ValueFOR X = 0 TO lookbacklength-1M = close[X]SmallPart = 0LargePart = 0FOR Y = 0 TO lookbacklength-1IF close[Y] < M THENSmallPart = SmallPart + 1ELSIF close[Y] > M THENLargePart = LargePart + 1ENDIFIF LargePart = SmallPart AND Y = lookbacklength-1 THENMedianvalue = MBREAKENDIFNEXTNEXT//-Price Deviationpricedeviation=priceSource-medianvalue//-Standard DeviationstandardDeviation=std[45](pricedeviation)//-Normalized ValuenormalizedValue=priceDeviation/(standardDeviation+standardDeviation)if normalizedValue>0 thenpositiveValues=normalizedValuenegativeValues=0elsif normalizedValue<0 thenpositiveValues=0negativeValues=normalizedValueendifupperBoundary=average[lookbacklength,1](positiveValues)+std[lookbacklength](positiveValues)*stdDevMultiplierlowerBoundary=average[lookbacklength,1](negativeValues)-std[lookbacklength](negativeValues)*stdDevMultiplierpercentileValue=100*(normalizedValue-lowerBoundary)/(upperBoundary-lowerBoundary)-50emaValue=HullAverage[emalookbacklength](percentileValue)//-----------------------------------------------////-----------------------------------------------////-----------------------------------------------//if percentileValue>0 thenr1=0g1=255b1=187elser1=255g1=17b1=0endifif noise thenpercentile=percentileValueelsepercentile=undefinedendifif emavalue>emavalue[1] thenr02=0g02=255b02=187elser02=255g02=17b02=0endifmaxLevelplot=150minlevelplot=-150upperMidlevelplot=90lowerMidlevelplot=-90colorbetween(maxLevelplot,upperMidlevelplot,255,17,0,50)colorbetween(minlevelplot,lowerMidlevelplot,0,255,187,50)colorbetween(emavalue,emavalue[1],r02,g02,b02,200)if emavalue crosses under emavalue[1] thendrawpoint(barindex,0.5*(emavalue+emavalue[1]),3)coloured("red",100)elsif emavalue crosses over emavalue[1] thendrawpoint(barindex,0.5*(emavalue+emavalue[1]),3)coloured("green",100)endifif emavalue crosses under emavalue[1] and emaValue[1]>90 thendrawtext("▼",barindex,maxLevelplot)coloured("red",255)elsif emavalue crosses over emavalue[1] and emaValue[1]<-90 thendrawtext("▲",barindex,minLevelplot)coloured("green",255)endif//-----------------------------------------------////-----------------------------------------------////-----------------------------------------------//return percentile as "Percentile" style(point)coloured(r1,g1,b1), 0 as "zero" coloured("grey"),emavalue as "Hull" style(line)coloured(r02,g02,b02),emavalue[1] as "Hull[1]" style(line)coloured(r02,g02,b02), maxLevelplot, minLevelplot1 user thanked author for this post.
09/12/2024 at 2:56 PM #237529 -
AuthorPosts
Find exclusive trading pro-tools on