Conversion TrendType de Tradingview
Forums › ProRealTime forum Français › Support ProBuilder › Conversion TrendType de Tradingview
- This topic has 2 replies, 2 voices, and was last updated 9 months ago by Sofitech.
Viewing 3 posts - 1 through 3 (of 3 total)
-
-
07/09/2023 at 5:36 PM #217469
Bonjour à tous. J’aimerais savoir si quelqu’un, Nicolas ou un autre expert serait en mesure de traduire / convertir ce code tradingview pour Prorealtime.
Je joins une capture d’écran ainsi que le code dans son intégralité.Vous remerciant par avance pour votre aide.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/// © BobRivera990//@version=4study(title = "Trend Type Indicator by BobRivera990", overlay = false)//==========================================================================[Inputs]==========================================================================useAtr = input(true, title = "Use ATR to detect Sideways Movements") // Use Average True Range (ATR) to detect Sideways MovementsatrLen = input(14, minval = 1, title = "ATR Length") // length of the Average True Range (ATR) used to detect Sideways MovementsatrMaType = input("SMA", options = ["SMA", "EMA"],title = "ATR Moving Average Type") // Type of the moving average of the ATR used to detect Sideways MovementsatrMaLen = input(20, minval = 1, title = "ATR MA Length") // length of the moving average of the ATR used to detect Sideways MovementsuseAdx = input(true, title = "Use ADX to detect Sideways Movements") // Use Average Directional Index (ADX) to detect Sideways MovementsadxLen = input(14, minval = 1, maxval = 50, title = "ADX Smoothing") // length of the Average Directional Index (ADX) used to detect Sideways MovementsdiLen = input(14, minval = 1, title = "DI Length") // length of the Plus and Minus Directional Indicators (+DI & -DI) used to determine the direction of the trendadxLim = input(25, minval = 1, title = "ADX Limit") // A level of ADX used as the boundary between Trend Market and Sideways Marketsmooth = input(3, minval = 1, maxval = 5, title = "Smoothing Factor") // Factor used for smoothing the oscillatorlag = input(8, minval = 0, maxval = 15, title = "Lag") // lag used to match indicator and chart//============================================================================================================================================================//===================================================================[Initial Calculations]===================================================================atr = atr(atrLen) // Calculate the Average True Range (ATR)atrMa = atrMaType == "EMA" ? ema(atr, atrMaLen) : sma(atr, atrMaLen) // Calculate the moving average of the ATRup = change(high) // Calculate parameter related to ADX, +DI and -DIdown = -change(low) // Calculate parameter related to ADX, +DI and -DIplusDM = na(up) ? na : (up > down and up > 0 ? up : 0) // Calculate parameter related to ADX, +DI and -DIminusDM = na(down) ? na : (down > up and down > 0 ? down : 0) // Calculate parameter related to ADX, +DI and -DItrur = rma(tr, diLen) // Calculate parameter related to ADX, +DI and -DIplus = fixnan(100 * rma(plusDM, diLen) / trur) // Calculate Plus Directional Indicator (+DI)minus = fixnan(100 * rma(minusDM, diLen) / trur) // Calculate Minus Directional Indicator (-DI)sum = plus + minus // Calculate parameter related to ADXadx = 100 * rma(abs(plus - minus) / (sum == 0 ? 1 : sum), adxLen) // Calculate Average Directional Index (ADX)//============================================================================================================================================================//========================================================================[Conditions]========================================================================cndNa = na(atr) or na(adx) or na(plus) or na(minus) or na(atrMaLen) // Conditions for lack of sufficient data for calculationscndSidwayss1 = useAtr and atr <= atrMa // Sideways Movement condition (based on ATR)cndSidwayss2 = useAdx and adx <= adxLim // Sideways Movement condition (based on ADX)cndSidways = cndSidwayss1 or cndSidwayss2 // General Sideways Movement conditioncndUp = plus > minus // uptrend conditioncndDown = minus >= plus // downtrend conditiontrendType = cndNa ? na : cndSidways ? 0 : cndUp ? 2 : -2 // Determine the type of trendsmoothType = na(trendType) ? na : round(sma(trendType, smooth) / 2) * 2 // Calculate the smoothed trend type oscillator//============================================================================================================================================================//=========================================================================[Drawing]==========================================================================colGreen30 = color.new(color.green, 30) // Define the color used in the drawingscolGreen90 = color.new(color.green, 90) // Define the color used in the drawingscolGray = color.new(color.gray, 20) // Define the color used in the drawingscolWhite90 = color.new(color.white, 90) // Define the color used in the drawingscolRed30 = color.new(color.red, 30) // Define the color used in the drawingscolRed90 = color.new(color.red, 90) // Define the color used in the drawingsband3 = plot(+3, title = "Band_3", color=color.black) // Draw the upper limit of the uptrend areaband2 = plot(+1, title = "Band_2", color=color.black) // Draw the boundary between Sideways and Uptrend areasband1 = plot(-1, title = "Band_1", color=color.black) // Draw the boundary between Sideways and Downtrend areasband0 = plot(-3, title = "Band_0", color=color.black) // Draw the lower limit of the downtrend areafill(band2, band3, title = "Uptrend area", color = colGreen90) // Highlight the Uptrend areafill(band1, band2, title = "Sideways area", color = colWhite90) // Highlight the Sideways areafill(band0, band1, title = "Downtrend area", color = colRed90) // Highlight the Downtrend areavar label lblUp = nalabel.delete(lblUp)lblUp := label.new(x = time, y = 2, text = "UP",color = color.new(color.green, 100), textcolor = color.black,style = label.style_label_left, xloc = xloc.bar_time,yloc = yloc.price, size=size.normal, textalign = text.align_left) // Show Uptrend area labelvar label lblSideways = nalabel.delete(lblSideways)lblSideways := label.new(x = time, y = 0, text = "SIDEWAYS",color = color.new(color.green, 100), textcolor = color.black,style = label.style_label_left, xloc = xloc.bar_time,yloc = yloc.price, size = size.normal, textalign = text.align_left) // Show Sideways area labelvar label lblDown = nalabel.delete(lblDown)lblDown := label.new(x = time, y = -2, text = "DOWN",color = color.new(color.green, 100), textcolor = color.black,style = label.style_label_left, xloc = xloc.bar_time,yloc = yloc.price, size = size.normal, textalign = text.align_left) // Show Downtrend area labelvar label lblCurrentType = nalabel.delete(lblCurrentType)lblCurrentType := label.new(x = time, y = smoothType,color = color.new(color.blue, 30), style = label.style_label_right,xloc = xloc.bar_time, yloc = yloc.price, size = size.small) // Show the latest status labeltrendCol = smoothType == 2 ? colGreen30 : smoothType == 0 ? colGray : colRed30 // Determine the color of the oscillator in different conditionsplot(smoothType, title = "Trend Type Oscillator", color = trendCol,linewidth = 3, offset = -lag, style = plot.style_stepline) // Draw the trend type oscillator02/02/2024 at 2:52 PM #227323Salut!
Vous pouvez vérifier le code dans le post suivant.
https://www.prorealcode.com/prorealtime-indicators/trend-type-indicator/
Salutations!1 user thanked author for this post.
02/03/2024 at 6:39 PM #227358 -
AuthorPosts
Viewing 3 posts - 1 through 3 (of 3 total)
Find exclusive trading pro-tools on
Similar topics: