traduzione codice TW Trend reversal Predictor
Forums › ProRealTime forum Italiano › Supporto ProBuilder › traduzione codice TW Trend reversal Predictor
- This topic has 2 replies, 2 voices, and was last updated 8 months ago by Msport71.
-
-
03/22/2024 at 7:28 AM #230240
Buongiorno a tutti,
vorrei provare questo interessante codice trovato su TW, abbastanza recente e che mi sembra interessante.
Un grande grazie per il consueto aiuto.
https://www.tradingview.com/script/T7AZI0z6-Trend-Reversal-Predictor/
//@version=5
indicator(“Danger Zones”, overlay=true)// Step 1: Trend Identification
length = input.int(200, minval=1)
src = input(close, title=”Source”)
hma = ta.wma(2 * ta.wma(src, length / 2) – ta.wma(src, length), math.floor(math.sqrt(length)))
start = input(0.02)
increment = input(0.02)
maximum = input(0.2, “Max Value”)
sar = ta.sar(start, increment, maximum)trendUp = close > hma and close > sar
trendDown = close < hma and close < sar
trendNeutral = not trendUp and not trendDown// Step 2: Danger Zone Identification
buyingVolumeSlowdownPeriod = input(5, title=”Buying Volume Slowdown Period”)
sellingVolumeSlowdownPeriod = input(5, title=”Selling Volume Slowdown Period”)
buyingVolumeRateOfChange = ta.change(volume, buyingVolumeSlowdownPeriod)
sellingVolumeRateOfChange = ta.change(volume, sellingVolumeSlowdownPeriod)
adrPeriod = input(14, title=”Average Daily Range (ADR) Period”)
adr = ta.atr(adrPeriod)// Calculate average volume rate of change and net price movement
averageBuyingVolumeRateOfChange = ta.sma(buyingVolumeRateOfChange, 5)
averageSellingVolumeRateOfChange = ta.sma(sellingVolumeRateOfChange, 5)
averageNetPriceMovement = ta.sma(close – close[1], 5)// RSI Integration
ma(source, length, type) =>
switch type
“SMA” => ta.sma(source, length)
“Bollinger Bands” => ta.sma(source, length)
“EMA” => ta.ema(source, length)
“SMMA (RMA)” => ta.rma(source, length)
“WMA” => ta.wma(source, length)
“VWMA” => ta.vwma(source, length)rsiLengthInput = input.int(14, minval=1, title=”RSI Length”, group=”RSI Settings”)
rsiSourceInput = input.source(close, “Source”, group=”RSI Settings”)
maTypeInput = input.string(“SMA”, title=”MA Type”, options=[“SMA”, “Bollinger Bands”, “EMA”, “SMMA (RMA)”, “WMA”, “VWMA”], group=”MA Settings”)
maLengthInput = input.int(14, title=”MA Length”, group=”MA Settings”)
bbMultInput = input.float(2.0, minval=0.001, maxval=50, title=”BB StdDev”, group=”MA Settings”)up = ta.rma(math.max(ta.change(rsiSourceInput), 0), rsiLengthInput)
down = ta.rma(-math.min(ta.change(rsiSourceInput), 0), rsiLengthInput)
rsi = down == 0 ? 100 : up == 0 ? 0 : 100 – (100 / (1 + up / down))
rsiMA = ma(rsi, maLengthInput, maTypeInput)
isBB = maTypeInput == “Bollinger Bands”
rsiBelowMA = rsi < rsiMA
rsiAboveMA = rsi > rsiMA// Step 3: Trend Ending Prediction
// Combine Conditions
uptrendDangerZone = trendUp and buyingVolumeRateOfChange <= averageBuyingVolumeRateOfChange and averageNetPriceMovement < 0 and rsiBelowMA
downtrendDangerZone = trendDown and sellingVolumeRateOfChange <= averageSellingVolumeRateOfChange and averageNetPriceMovement > 0 and rsiAboveMA
rsiConditionUp = trendUp and rsiBelowMA
rsiConditionDown = trendDown and rsiAboveMA
trendReversalConditionUp = uptrendDangerZone and rsiConditionUp
trendReversalConditionDown = downtrendDangerZone and rsiConditionDown// Final Trend Ending Prediction
trendEndingPredictionUp = trendReversalConditionUp and rsiBelowMA
trendEndingPredictionDown = trendReversalConditionDown and rsiAboveMAbgcolor(uptrendDangerZone ? color.orange : downtrendDangerZone ? color.blue : na, transp=70)
03/22/2024 at 11:27 AM #230268Ecco cosa hai:
https://www.prorealcode.com/prorealtime-indicators/danger-zones-indicator/PRC_Zone di pericolo1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980//PRC_Danger Zones//version = 0//22.03.24//Iván González @ www.prorealcode.com//Sharing ProRealTime knowledge////////////////////////////////////////////////////------Inputs: Trend Identification--------------------////----HMAlength = 200src = customclose//----SARstart = 0.02increment = 0.02maximum = 0.2//-------Inputs: Danger Zone Identification--------------////----VolumebuyingVolumeSlowdownPeriod = 5 //Buying Volume Slowdown PeriodsellingVolumeSlowdownPeriod = 5 //Selling Volume Slowdown Period//----Moving averagemaTypeInput = 0 // MA TypemaLengthInput = 14 // MA Length//----RSIrsiLengthInput = 14 // RSI LengthrsiSourceInput = close // Source//-------------------------------------------------------////-----Trend identification------------------------------//hma = hullaverage[length](src)psar = SAR[start,increment,maximum]trendup = close > hma and close > psartrenddown = close < hma and close < psartrendneutral = not trendup or not trenddown//-------------------------------------------------------////-------Danger Zone Identification----------------------//// Calculate average volume rate of changebuyingVolumeRateOfChange = Momentum[buyingVolumeSlowdownPeriod](volume)sellingVolumeRateOfChange = momentum[sellingVolumeSlowdownPeriod](volume)averageBuyingVolumeRateOfChange = average[5,0](buyingVolumeRateOfChange)averageSellingVolumeRateOfChange = average[5,0](sellingVolumeRateOfChange)// Calculate net price movementaverageNetPriceMovement = average[5,0](close-close[1])// RSI integrationsrc1 = max(momentum[1](rsiSourceInput),0)alpha1 = 1/rsiLengthInputif barindex = rsiLengthInput thenup = average[rsiLengthInput](src1)elseup = alpha1*src1 + (1-alpha1)*up[1]endifsrc2 = -min(momentum[1](rsiSourceInput),0)alpha2 = 1/rsiLengthInputif barindex = rsiLengthInput thendown = average[rsiLengthInput](src2)elsedown = alpha2*src2 + (1-alpha2)*down[1]endifif down = 0 thenmyrsi = 100elsif up = 0 thenmyrsi = 0elsemyrsi = 100-(100/(1+up/down))endifrsiMa = average[maLengthInput,maTypeInput](myrsi)rsibelowMA = myrsi < rsiMArsiaboveMA = myrsi > rsiMA//-----------------------------------------------------////-----Trend ending Prediction-------------------------//// Combine ConditionsuptrendDangerZone = trendUp and buyingVolumeRateOfChange <= averageBuyingVolumeRateOfChange and averageNetPriceMovement < 0 and rsiBelowMAdowntrendDangerZone = trendDown and sellingVolumeRateOfChange <= averageSellingVolumeRateOfChange and averageNetPriceMovement > 0 and rsiAboveMA//-----------------------------------------------------//if uptrendDangerZone thenbackgroundcolor(255,152,0,70)elsif downtrendDangerZone thenbackgroundcolor(33,150,243,70)endifreturn1 user thanked author for this post.
03/22/2024 at 2:43 PM #230277 -
AuthorPosts
Find exclusive trading pro-tools on