Home Article MACD Past Current Future MACD Past Current Future Software Technique Web Technique All Computer Language and Computer Language Practice Computer Educa September 16, 2026 0 Comments Share: Facebook Twitter Google+ Pinterest Whatsapp TREDING //@version=6 indicator("MACD Future Swing + Adjustable Curve", shorttitle="MACD FUTURE SWING", overlay=false, max_lines_count=500) //━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ // MACD SETTINGS //━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ fastLen = input.int(12, "Fast EMA", minval=1) slowLen = input.int(26, "Slow EMA", minval=2) signalLen = input.int(9, "Signal EMA", minval=1) //━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ // FUTURE SETTINGS //━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ futureBars = input.int(10, "Future Candles", minval=2, maxval=50) swingStrength = input.float( 1.0, "Swing Strength", minval=0.0, maxval=10.0, step=0.1 ) swingCycles = input.float( 2.0, "Swing Cycles", minval=0.25, maxval=6.0, step=0.25 ) curveBias = input.float( 0.0, "Curve Bias", minval=-5.0, maxval=5.0, step=0.1 ) slopeBars = input.int( 3, "Angle Slope Bars", minval=1, maxval=10 ) //━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ // DISPLAY //━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ showHistogram = input.bool(true, "Show Histogram") showFuture = input.bool(true, "Show Future Curve") //━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ // MACD //━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ fastEMA = ta.ema(close, fastLen) slowEMA = ta.ema(close, slowLen) macd = fastEMA - slowEMA signal = ta.ema(macd, signalLen) hist = macd - signal //━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ // HISTOGRAM //━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ histColor = hist >= 0 ? color.green : color.red plot( showHistogram ? hist : na, title="Histogram", style=plot.style_columns, color=histColor ) //━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ // ACTUAL MACD //━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ plot( macd, title="MACD Blue", color=color.blue, linewidth=3 ) plot( signal, title="Signal Red", color=color.red, linewidth=3 ) hline(0, "Zero Line", color=color.gray) //━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ // SLOPE //━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ macdSlope = (macd - macd[slopeBars]) / slopeBars signalSlope = (signal - signal[slopeBars]) / slopeBars //━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ // ANGLE //━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ macdAngle = math.atan(macdSlope) * 180.0 / math.pi signalAngle = math.atan(signalSlope) * 180.0 / math.pi //━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ // FUTURE LINES STORAGE //━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ var line[] blueLines = array.new_line() var line[] redLines = array.new_line() //━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ // FUTURE CURVE //━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ if barstate.islast and showFuture // Delete old blue lines if array.size(blueLines) > 0 for i = 0 to array.size(blueLines) - 1 line.delete(array.get(blueLines, i)) array.clear(blueLines) // Delete old red lines if array.size(redLines) > 0 for i = 0 to array.size(redLines) - 1 line.delete(array.get(redLines, i)) array.clear(redLines) //━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ // BLUE MACD FUTURE CURVE //━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ for i = 1 to futureBars prevX = bar_index + i - 1 currX = bar_index + i // Normal trend projection basePrev = macd + macdSlope * (i - 1) baseCurr = macd + macdSlope * i // Adjustable wave wavePrev = math.sin( ((i - 1) / futureBars) * math.pi * 2.0 * swingCycles ) * math.abs(macdSlope + 0.01) * swingStrength waveCurr = math.sin( (i / futureBars) * math.pi * 2.0 * swingCycles ) * math.abs(macdSlope + 0.01) * swingStrength // Curve bias biasPrev = curveBias * math.pow((i - 1) / futureBars, 2) biasCurr = curveBias * math.pow(i / futureBars, 2) yPrev = basePrev + wavePrev + biasPrev yCurr = baseCurr + waveCurr + biasCurr newBlue = line.new( x1=prevX, y1=yPrev, x2=currX, y2=yCurr, xloc=xloc.bar_index, extend=extend.none, color=color.blue, style=line.style_dotted, width=3 ) array.push(blueLines, newBlue) //━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ // RED SIGNAL FUTURE CURVE //━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ for i = 1 to futureBars prevX = bar_index + i - 1 currX = bar_index + i basePrev = signal + signalSlope * (i - 1) baseCurr = signal + signalSlope * i wavePrev = math.sin( ((i - 1) / futureBars) * math.pi * 2.0 * swingCycles ) * math.abs(signalSlope + 0.01) * swingStrength waveCurr = math.sin( (i / futureBars) * math.pi * 2.0 * swingCycles ) * math.abs(signalSlope + 0.01) * swingStrength biasPrev = curveBias * math.pow((i - 1) / futureBars, 2) biasCurr = curveBias * math.pow(i / futureBars, 2) yPrev = basePrev + wavePrev + biasPrev yCurr = baseCurr + waveCurr + biasCurr newRed = line.new( x1=prevX, y1=yPrev, x2=currX, y2=yCurr, xloc=xloc.bar_index, extend=extend.none, color=color.red, style=line.style_dotted, width=3 ) array.push(redLines, newRed) //━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ // DIRECTION //━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ bullish = macd > signal and macdSlope > 0 bearish = macd < signal and macdSlope < 0 direction = bullish ? "BULLISH" : bearish ? "BEARISH" : "SIDEWAYS" //━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ // STRENGTH //━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ angleAbs = math.abs(macdAngle) strength = angleAbs >= 40 ? "VERY STRONG" : angleAbs >= 25 ? "STRONG" : angleAbs >= 10 ? "NORMAL" : "WEAK" //━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ // TABLE //━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ var table t = table.new( position.top_right, 3, 7, border_width=1 ) if barstate.islast table.cell( t, 0, 0, "MACD", bgcolor=color.blue, text_color=color.white ) table.cell( t, 1, 0, "ANGLE", bgcolor=color.gray, text_color=color.white ) table.cell( t, 2, 0, "STATUS", bgcolor=color.gray, text_color=color.white ) // BLUE table.cell( t, 0, 1, "BLUE", bgcolor=color.blue, text_color=color.white ) table.cell( t, 1, 1, str.tostring(macdAngle, "#.0") + "°", text_color=color.white ) table.cell( t, 2, 1, strength, text_color=color.white ) // RED table.cell( t, 0, 2, "RED", bgcolor=color.red, text_color=color.white ) table.cell( t, 1, 2, str.tostring(signalAngle, "#.0") + "°", text_color=color.white ) table.cell( t, 2, 2, direction, text_color=color.white ) // FUTURE table.cell( t, 0, 3, "FUTURE", bgcolor=color.gray, text_color=color.white ) table.cell( t, 1, 3, str.tostring(futureBars), text_color=color.white ) table.cell( t, 2, 3, "CANDLES", text_color=color.white ) // SWING table.cell( t, 0, 4, "SWING", bgcolor=color.gray, text_color=color.white ) table.cell( t, 1, 4, str.tostring(swingStrength, "#.0"), text_color=color.white ) table.cell( t, 2, 4, str.tostring(swingCycles, "#.00") + " CYCLE", text_color=color.white ) // CURVE BIAS table.cell( t, 0, 5, "BIAS", bgcolor=color.gray, text_color=color.white ) table.cell( t, 1, 5, str.tostring(curveBias, "#.0"), text_color=color.white ) table.cell( t, 2, 5, curveBias > 0 ? "UP" : curveBias < 0 ? "DOWN" : "NEUTRAL", text_color=color.white ) // DISTANCE table.cell( t, 0, 6, "BLUE-RED", bgcolor=color.gray, text_color=color.white ) table.cell( t, 1, 6, str.tostring(macd - signal, "#.###"), text_color=color.white ) table.cell( t, 2, 6, macd > signal ? "BLUE > RED" : "RED > BLUE", text_color=color.white ) Copy Copied Text:
No comments