Haz que el adx cambie de color a amarillo si cae por debajo del key level, y se vuelva…
- User
Haz que el adx cambie de color a amarillo si cae por debajo del key level, y se vuelva blanco si sube por encima de esta: // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © rolgui // @version=4 // 'All in One' indicator for TradingLatino's strategy combined with John F. Carter's strategy (turned off by default). study(title="Squeeze M. + ADX + TTM (TradingLatino & John F. Carter) by [Rolgui]", shorttitle="SQZ+ADX+TTM [R]", overlay=false) // 1) Squeeze Momentum Oscillator // original code section by @ LazyBear show_SQZ = input(true, title="Show Squeeze Oscillator") allLengthValue = input(20, title="BB Length", type=input.integer) BB_mult = input(2.0,title="BB MultFactor") lengthKC=input(20, title="KC Length") multKC = input(1.5, title="KC MultFactor") linearMomentum = input(20, title="Linear Momentum", type=input.integer) useTrueRangeM = true // Calculate BB source = close BB_basis = sma(source, allLengthValue) dev = BB_mult * stdev(source, allLengthValue) upperBB = BB_basis + dev lowerBB = BB_basis - dev // Calculate KC KC_basis = sma(source, lengthKC) range = useTrueRangeM ? tr : (high - low) devKC = sma(range, allLengthValue) upperKC = KC_basis + devKC * multKC lowerKC = KC_basis - devKC * multKC sqzOn = (lowerBB > lowerKC) and (upperBB < upperKC) sqzOff = (lowerBB < lowerKC) and (upperBB > upperKC) noSqz = (sqzOn == false) and (sqzOff == false) val = linreg(source - avg(avg(highest(high, linearMomentum), lowest(low, linearMomentum)),sma(close,linearMomentum)), linearMomentum,0) bcolor = iff( val > 0, iff( val > nz(val[1]), color.rgb(46, 245, 39, 0), color.rgb(16, 120, 13, 0)), iff( val < nz(val[1]), color.rgb(217, 6, 6, 0), color.rgb(98, 0, 0, 0))) sz = linreg(source - avg(avg(highest(high, allLengthValue), lowest(low, allLengthValue)), sma(close, allLengthValue)), allLengthValue, 0) //***************************************************************************************************************************************************************************************// // Draw plots section by visibility order. // TTM Waves plot(histA, color=color.new(color.teal, 80), style=plot.style_area, title="Wave A", linewidth=1) plot(histB, color=color.new(color.orange, 90), style=plot.style_area, title="Wave B", linewidth=1) plot(histC, color=color.new(color.yellow, 90), style=plot.style_area, title="Wave C", linewidth=1) // Squeeze Oscillator plot(show_SQZ ? val : na, title="Squeeze Oscillator", color=bcolor, style=plot.style_columns, linewidth=4) // Key Level plot(show_ADX ? far1 * scaleADX : na, color=color.white, title="Key Level", linewidth = 1) // Squeeze Momentum plot(showTTMSQZ? 0 : na, title='Squeeze Momentum', color=sq_color, style=plot.style_line, linewidth=2) // ADX p1 = plot(show_ADX ? adx_scale2 * scaleADX : show_ADX ? adx_scale * scaleADX : na, color = color.white, title = "ADX", linewidth = 2)
- Assistant
Aquí está el código con la modificación solicitada:
p2 = plot(show_ADX ? adx_scale2 * scaleADX : show_ADX ? adx_scale * scaleADX : na, color = adxValue < keyLevel ? color.yellow : color.white, title = "ADX", linewidth = 2)En esta línea de código, se cambió el color del plot del ADX para que sea amarillo cuando el valor del ADX sea inferior al key level, y blanco en caso contrario.
- User
integralo en el codigo por favor
- Assistant