PHP Code:
// Predicta Futures - Next Candle Predictor
// Version 2.1 (UI/UX Improved)
// by Predicta Futures
//@version=6
indicator(".", overlay=true, max_boxes_count=100, max_lines_count=100, max_labels_count=100)
// ============================================================================
// INPUT SETTINGS
// ============================================================================
grp_main = "Main Settings"
atrLength = input.int(5, "ATR Period", minval=5, maxval=50, group=grp_main)
stFactor = input.float(1.0, "Supertrend Factor", minval=1.0, maxval=5.0, step=0.1, group=grp_main)
stPeriod = input.int(5, "Supertrend Period", minval=5, maxval=30, group=grp_main)
grp_confluence = "Confluence Settings"
minConfluence = input.int(2, "Minimum Confluence Score", minval=2, maxval=6, group=grp_confluence)
minVolumeRatio = input.float(0.8, "Minimum Volume Ratio", minval=0.5, maxval=2.0, step=0.1, group=grp_confluence)
grp_vis = "Visual Settings"
showTable = input.bool(true, "Show Analysis Table", group=grp_vis)
showProjection = input.bool(true, "Show Prediction Candles", group=grp_vis)
// ============================================================================
// COLORS
// ============================================================================
colLong = #089981
colShort = #f23645
colFTBackground = #FCD0AF
colBg = #1e222d
colBgDark = #131722
colBlack = #000000
colText = #ffffff
colGray = #787b86
colYellow = #f0b90b
// ============================================================================
// TECHNICAL CALCULATIONS
// ============================================================================
atr = ta.atr(atrLength)
[supertrend, stDirection] = ta.supertrend(stFactor, stPeriod)
ema8 = ta.ema(close, 2)
ema21 = ta.ema(close, 5)
ema50 = ta.ema(close, 9)
rsi = ta.rsi(close, 14)
[macdLine, signalLine, macdHist] = ta.macd(close, 12, 26, 9)
volSma = ta.sma(volume, 20)
volRatio = nz(volume / volSma, 1.0)
avgBody = ta.sma(math.abs(close - open), 5)
isUptrend = stDirection == -1
isDowntrend = stDirection == 1
// Stochastic
stochK = ta.stoch(close, high, low, 14)
stochD = ta.sma(stochK, 3)
// ADX
adxLen = 14
[diPlus, diMinus, adxValue] = ta.dmi(adxLen, adxLen)
// Bollinger Width
bbMid = ta.sma(close, 20)
bbStd = ta.stdev(close, 20)
bbWidth = (bbMid + 2 * bbStd - (bbMid - 2 * bbStd)) / bbMid
// ============================================================================
// DYNAMIC THRESHOLD (ADX Based)
// ============================================================================
dynamicThreshold = adxValue > 25 ? 60 : adxValue > 20 ? 65 : 70
// ============================================================================
// SCORING SYSTEM
// ============================================================================
macdScoreLong = macdLine > signalLine and macdHist > 0 ? 100 : macdLine > signalLine ? 70 : macdHist > 0 ? 50 : 20
rsiScoreLong = rsi < 30 ? 100 : rsi < 40 ? 80 : rsi < 50 ? 60 : rsi < 60 ? 40 : 20
stochScoreLong = stochK > stochD and stochK < 20 ? 100 : stochK > stochD ? 70 : 30
volScore = volRatio > 2.0 ? 100 : volRatio > 1.5 ? 80 : volRatio > 1.0 ? 60 : 40
adxScore = adxValue > 30 ? 100 : adxValue > 25 ? 80 : adxValue > 20 ? 60 : 40
trendScoreLong = isUptrend and ema8 > ema21 and ema21 > ema50 ? 100 : isUptrend and ema8 > ema21 ? 80 : isUptrend ? 60 : 0
macdScoreShort = macdLine < signalLine and macdHist < 0 ? 100 : macdLine < signalLine ? 70 : macdHist < 0 ? 50 : 20
rsiScoreShort = rsi > 70 ? 100 : rsi > 60 ? 80 : rsi > 50 ? 60 : rsi > 40 ? 40 : 20
stochScoreShort = stochK < stochD and stochK > 80 ? 100 : stochK < stochD ? 70 : 30
trendScoreShort = isDowntrend and ema8 < ema21 and ema21 < ema50 ? 100 : isDowntrend and ema8 < ema21 ? 80 : isDowntrend ? 60 : 0
longScore = math.round((macdScoreLong * 0.20 + rsiScoreLong * 0.15 + stochScoreLong * 0.15 + volScore * 0.15 + trendScoreLong * 0.25 + adxScore * 0.10))
shortScore = math.round((macdScoreShort * 0.20 + rsiScoreShort * 0.15 + stochScoreShort * 0.15 + volScore * 0.15 + trendScoreShort * 0.25 + adxScore * 0.10))
totalRaw = longScore + shortScore
longPct = totalRaw > 0 ? math.round(longScore / totalRaw * 100) : 50
shortPct = 100 - longPct
// ============================================================================
// CONFLUENCE SCORE (0-6)
// ============================================================================
confluenceLong = 0
confluenceLong += isUptrend ? 1 : 0
confluenceLong += ema8 > ema21 ? 1 : 0
confluenceLong += macdLine > signalLine ? 1 : 0
confluenceLong += stochK > stochD ? 1 : 0
confluenceLong += volRatio >= minVolumeRatio ? 1 : 0
confluenceLong += adxValue > 20 ? 1 : 0
confluenceShort = 0
confluenceShort += isDowntrend ? 1 : 0
confluenceShort += ema8 < ema21 ? 1 : 0
confluenceShort += macdLine < signalLine ? 1 : 0
confluenceShort += stochK < stochD ? 1 : 0
confluenceShort += volRatio >= minVolumeRatio ? 1 : 0
confluenceShort += adxValue > 20 ? 1 : 0
volumeOk = volRatio >= minVolumeRatio
// ============================================================================
// PERFECT TIME
// ============================================================================
longPerfect = isUptrend and longPct >= dynamicThreshold and confluenceLong >= minConfluence and volumeOk
shortPerfect = isDowntrend and shortPct >= dynamicThreshold and confluenceShort >= minConfluence and volumeOk
// ============================================================================
// HELPER FUNCTIONS - ASCII LOADING BAR
// ============================================================================
getAsciiBar(score) =>
filled = math.round(score / 10)
filled := math.max(0, math.min(10, filled))
"[" + str.repeat("â–ˆ", filled) + str.repeat("â–‘", 10 - filled) + "]"
getMacdText(isLongParam) =>
if isLongParam
macdLine > signalLine and macdHist > 0 ? "BOGA " : macdLine > signalLine ? "BOGA" : "AYI"
else
macdLine < signalLine and macdHist < 0 ? "AYI " : macdLine < signalLine ? "AYI" : "BOGA"
getRsiText() =>
"(" + str.tostring(math.round(rsi)) + ")"
getStochText(isLongParam) =>
if isLongParam
stochK < 20 ? "SATIS" : stochK > stochD ? "BOGA" : "AYI"
else
stochK > 80 ? "ALIS" : stochK < stochD ? "AYI" : "BOGA"
getVolText() =>
str.tostring(math.round(volRatio, 1)) + "x"
getTrendText(isLongParam) =>
if isLongParam
isUptrend and ema8 > ema21 ? "YUKSELIS" : isUptrend ? "+" : "-"
else
isDowntrend and ema8 < ema21 ? "DUSUS" : isDowntrend ? "-" : "+"
getAdxText() =>
str.tostring(math.round(adxValue))
// ============================================================================
// ANALYSIS TABLE - IMPROVED UI
// ============================================================================
var table analysisTable = table.new(position.bottom_center, 50, 50, bgcolor=colBgDark, border_width=0, frame_width=2, frame_color=colGray)
if barstate.islast and showTable
// ===== LONG SECTION =====
table.cell(analysisTable, 0, 0, "BOGA ", text_color=colText, bgcolor=colLong, text_size=size.normal, text_halign=text.align_left)
table.cell(analysisTable, 1, 0, "OLASILIK " + str.tostring(longPct) + "%", text_color=colText, bgcolor=colLong, text_size=size.normal, text_halign=text.align_right)
// MACD
table.cell(analysisTable, 0, 1, "MACD", text_color=colText, bgcolor=colBg, text_size=size.small, text_halign=text.align_left)
macdBarColorL = macdScoreLong >= 70 ? colLong : colGray
table.cell(analysisTable, 1, 1, getAsciiBar(macdScoreLong) + " " + getMacdText(true), text_color=macdBarColorL, bgcolor=colBg, text_size=size.small, text_halign=text.align_left)
// RSI
table.cell(analysisTable, 0, 2, "RSI", text_color=colText, bgcolor=colBg, text_size=size.small, text_halign=text.align_left)
rsiBarColorL = rsiScoreLong >= 60 ? colLong : colGray
table.cell(analysisTable, 1, 2, getAsciiBar(rsiScoreLong) + " " + getRsiText(), text_color=rsiBarColorL, bgcolor=colBg, text_size=size.small, text_halign=text.align_left)
// STOCH
table.cell(analysisTable, 0, 3, "STCH", text_color=colText, bgcolor=colBg, text_size=size.small, text_halign=text.align_left)
stochBarColorL = stochScoreLong >= 70 ? colLong : colGray
table.cell(analysisTable, 1, 3, getAsciiBar(stochScoreLong) + " " + getStochText(true), text_color=stochBarColorL, bgcolor=colBg, text_size=size.small, text_halign=text.align_left)
// VOLUME
table.cell(analysisTable, 0, 4, "HACIM", text_color=colText, bgcolor=colBg, text_size=size.small, text_halign=text.align_left)
volBarColor = volScore >= 60 ? colLong : colGray
table.cell(analysisTable, 1, 4, getAsciiBar(volScore) + " " + getVolText(), text_color=volBarColor, bgcolor=colBg, text_size=size.small, text_halign=text.align_left)
// TREND
table.cell(analysisTable, 0, 5, "TREND", text_color=colText, bgcolor=colBg, text_size=size.small, text_halign=text.align_left)
trendBarColorL = trendScoreLong >= 60 ? colLong : colGray
table.cell(analysisTable, 1, 5, getAsciiBar(trendScoreLong) + " " + getTrendText(true), text_color=trendBarColorL, bgcolor=colBg, text_size=size.small, text_halign=text.align_left)
// ADX
table.cell(analysisTable, 0, 6, "ADX", text_color=colText, bgcolor=colBg, text_size=size.small, text_halign=text.align_left)
adxBarColor = adxScore >= 60 ? colLong : colGray
table.cell(analysisTable, 1, 6, getAsciiBar(adxScore) + " " + getAdxText(), text_color=adxBarColor, bgcolor=colBg, text_size=size.small, text_halign=text.align_left)
// CONFLUENCE
confLongColor = confluenceLong >= minConfluence ? colLong : colGray
table.cell(analysisTable, 0, 7, "SONUC", text_color=colYellow, bgcolor=colBg, text_size=size.small, text_halign=text.align_left)
table.cell(analysisTable, 1, 7, str.tostring(confluenceLong) + " / 6", text_color=confLongColor, bgcolor=colBg, text_size=size.small, text_halign=text.align_left)
// LONG STATUS
longStatusText = longPerfect ? "YAP" : "BEKLE"
longStatusColor = longPerfect ? colLong : colGray
table.cell(analysisTable, 0, 8, "BOGA", text_color=colLong, bgcolor=colBlack, text_size=size.normal, text_halign=text.align_center)
table.cell(analysisTable, 1, 8, longStatusText, text_color=longStatusColor, bgcolor=colBlack, text_size=size.normal, text_halign=text.align_center)
// ===== SHORT SECTION =====
table.cell(analysisTable, 0, 9, "AYI ", text_color=colText, bgcolor=colShort, text_size=size.normal, text_halign=text.align_left)
table.cell(analysisTable, 1, 9, "OLASILIK " + str.tostring(shortPct) + "%", text_color=colText, bgcolor=colShort, text_size=size.normal, text_halign=text.align_right)
// MACD
table.cell(analysisTable, 0, 10, "MACD", text_color=colText, bgcolor=colBg, text_size=size.small, text_halign=text.align_left)
macdBarColorS = macdScoreShort >= 70 ? colShort : colGray
table.cell(analysisTable, 1, 10, getAsciiBar(macdScoreShort) + " " + getMacdText(false), text_color=macdBarColorS, bgcolor=colBg, text_size=size.small, text_halign=text.align_left)
// RSI
table.cell(analysisTable, 0, 11, "RSI", text_color=colText, bgcolor=colBg, text_size=size.small, text_halign=text.align_left)
rsiBarColorS = rsiScoreShort >= 60 ? colShort : colGray
table.cell(analysisTable, 1, 11, getAsciiBar(rsiScoreShort) + " " + getRsiText(), text_color=rsiBarColorS, bgcolor=colBg, text_size=size.small, text_halign=text.align_left)
// STOCH
table.cell(analysisTable, 0, 12, "STCH", text_color=colText, bgcolor=colBg, text_size=size.small, text_halign=text.align_left)
stochBarColorS = stochScoreShort >= 70 ? colShort : colGray
table.cell(analysisTable, 1, 12, getAsciiBar(stochScoreShort) + " " + getStochText(false), text_color=stochBarColorS, bgcolor=colBg, text_size=size.small, text_halign=text.align_left)
// VOLUME
table.cell(analysisTable, 0, 13, "HACIM", text_color=colText, bgcolor=colBg, text_size=size.small, text_halign=text.align_left)
table.cell(analysisTable, 1, 13, getAsciiBar(volScore) + " " + getVolText(), text_color=volBarColor, bgcolor=colBg, text_size=size.small, text_halign=text.align_left)
// TREND
table.cell(analysisTable, 0, 14, "TREND", text_color=colText, bgcolor=colBg, text_size=size.small, text_halign=text.align_left)
trendBarColorS = trendScoreShort >= 60 ? colShort : colGray
table.cell(analysisTable, 1, 14, getAsciiBar(trendScoreShort) + " " + getTrendText(false), text_color=trendBarColorS, bgcolor=colBg, text_size=size.small, text_halign=text.align_left)
// ADX
table.cell(analysisTable, 0, 15, "ADX", text_color=colText, bgcolor=colBg, text_size=size.small, text_halign=text.align_left)
adxBarColorS = adxScore >= 60 ? colShort : colGray
table.cell(analysisTable, 1, 15, getAsciiBar(adxScore) + " " + getAdxText(), text_color=adxBarColorS, bgcolor=colBg, text_size=size.small, text_halign=text.align_left)
// CONFLUENCE
confShortColor = confluenceShort >= minConfluence ? colShort : colGray
table.cell(analysisTable, 0, 16, "SONUC", text_color=colYellow, bgcolor=colBg, text_size=size.small, text_halign=text.align_left)
table.cell(analysisTable, 1, 16, str.tostring(confluenceShort) + " / 6", text_color=confShortColor, bgcolor=colBg, text_size=size.small, text_halign=text.align_left)
// SHORT STATUS
shortStatusText = shortPerfect ? "YAP" : "BEKLE"
shortStatusColor = shortPerfect ? colShort : colGray
table.cell(analysisTable, 0, 17, "AYI", text_color=colShort, bgcolor=colBlack, text_size=size.normal, text_halign=text.align_center)
table.cell(analysisTable, 1, 17, shortStatusText, text_color=shortStatusColor, bgcolor=colBlack, text_size=size.normal, text_halign=text.align_center)
// ============================================================================
// SUPERTREND LINE (No Fill - Clean Look)
// ============================================================================
stColor = isUptrend ? colLong : colShort
plot(supertrend, "STOP", color=stColor, linewidth=1)
// ============================================================================
// PROJECTION CANDLES
// ============================================================================
var line projDashLine = na
var box projZoneBox = na
var box longProjBody = na
var line longProjWickUp = na
var line longProjWickDown = na
var label longProjLabel = na
var box shortProjBody = na
var line shortProjWickUp = na
var line shortProjWickDown = na
var label shortProjLabel = na
if barstate.islast and showProjection
line.delete(projDashLine)
box.delete(projZoneBox)
box.delete(longProjBody)
line.delete(longProjWickUp)
line.delete(longProjWickDown)
label.delete(longProjLabel)
box.delete(shortProjBody)
line.delete(shortProjWickUp)
line.delete(shortProjWickDown)
label.delete(shortProjLabel)
zoneTop = ta.highest(high, 30) + atr * 1.5
zoneBottom = ta.lowest(low, 30) - atr * 1.5
projDashLine := line.new(bar_index + 1, zoneTop, bar_index + 1, zoneBottom, color=colGray, width=1, style=line.style_dashed)
projZoneBox := box.new(bar_index + 1, zoneTop, bar_index + 8, zoneBottom, bgcolor=color.new(colFTBackground, 70), border_color=color.new(colFTBackground, 50), border_width=1)
maxHeight = atr * 2 * (1 + bbWidth)
longHeight = maxHeight * (longPct / 100)
shortHeight = maxHeight * (shortPct / 100)
wickLen = avgBody * 0.4
longProjBody := box.new(bar_index + 3, close + longHeight, bar_index + 4, close, bgcolor=colLong, border_color=colLong, border_width=1)
longProjWickUp := line.new(bar_index + 3, close + longHeight, bar_index + 3, close + longHeight + wickLen, color=colLong, width=2)
longProjWickDown := line.new(bar_index + 3, close, bar_index + 3, close - wickLen, color=colLong, width=2)
longProjLabel := label.new(bar_index + 3, close + longHeight + wickLen + atr * 0.15, "L " + str.tostring(longPct) + "%", style=label.style_label_down, color=colLong, textcolor=colText, size=size.normal)
shortProjBody := box.new(bar_index + 5, close, bar_index + 6, close - shortHeight, bgcolor=colShort, border_color=colShort, border_width=1)
shortProjWickUp := line.new(bar_index + 5, close, bar_index + 5, close + wickLen, color=colShort, width=2)
shortProjWickDown := line.new(bar_index + 5, close - shortHeight, bar_index + 5, close - shortHeight - wickLen, color=colShort, width=2)
shortProjLabel := label.new(bar_index + 5, close - shortHeight - wickLen - atr * 0.15, "S " + str.tostring(shortPct) + "%", style=label.style_label_up, color=colShort, textcolor=colText, size=size.normal)
// ============================================================================
// BUY / SELL SIGNALS WITH LABELS
// ============================================================================
bullSignal = ta.crossover(ema8, ema21) and isUptrend
bearSignal = ta.crossunder(ema8, ema21) and isDowntrend
plotshape(bullSignal, "BUY Signal", shape.labelup, location.belowbar, colLong, text="AL", textcolor=color.white, size=size.small)
plotshape(bearSignal, "SELL Signal", shape.labeldown, location.abovebar, colShort, text="SAT", textcolor=color.white, size=size.small)
// ============================================================================
// ALERTS
// ============================================================================
alertcondition(longPerfect, "LONG Perfect Time", "LONG Perfect Time detected")
alertcondition(shortPerfect, "SHORT Perfect Time", "SHORT Perfect Time detected")
alertcondition(bullSignal, "BUY Signal", "BUY Signal detected")
alertcondition(bearSignal, "SELL Signal", "SELL Signal detected")
//////////////////////////////////////////////////
// ─── INPUTS ────────────────────────────────────────────────────────────────────
string GRP_CALC = "Calculation Settings"
int rsiLength = input.int(14, "RSI Length", minval = 5, maxval = 30, group = GRP_CALC)
int macdFast = input.int(12, "MACD Fast", minval = 5, maxval = 30, group = GRP_CALC)
int macdSlow = input.int(26, "MACD Slow", minval = 10, maxval = 50, group = GRP_CALC)
int macdSignal = input.int(9, "MACD Signal", minval = 3, maxval = 20, group = GRP_CALC)
int adxLength = input.int(14, "ADX Length", minval = 5, maxval = 30, group = GRP_CALC)
int maLength = input.int(50, "MA Length", minval = 20, maxval = 200, group = GRP_CALC)
string GRP_MTF = "Multi-Timeframe"
bool useMTF = input.bool(true, "Enable Multi-Timeframe", group = GRP_MTF)
string tf2 = input.timeframe("60", "Timeframe 2", group = GRP_MTF)
string tf3 = input.timeframe("240", "Timeframe 3", group = GRP_MTF)
string tf4 = input.timeframe("D", "Timeframe 4", group = GRP_MTF)
string GRP_VIS = "Visual Settings"
color bullColor = input.color(#00E676, "Bullish Color", group = GRP_VIS)
color bearColor = input.color(#FF5252, "Bearish Color", group = GRP_VIS)
color neutralColor = input.color(#9E9E9E, "Neutral Color", group = GRP_VIS)
bool showMA = input.bool(true, "Show Trend MA", group = GRP_VIS)
bool showDashboard = input.bool(true, "Show Dashboard", group = GRP_VIS)
string dashPos = input.string("Top Right", "Dashboard Position",
options = ["Top Right", "Top Left", "Bottom Right", "Bottom Left"], group = GRP_VIS)
// ─── FUNCTIONS ─────────────────────────────────────────────────────────────────
// Calculate ADX
calcADX(int len) =>
float trueRange = math.max(high - low, math.max(math.abs(high - close[1]), math.abs(low - close[1])))
float atr = ta.rma(trueRange, len)
float upMove = high - high[1]
float downMove = low[1] - low
float plusDM = upMove > downMove and upMove > 0 ? upMove : 0
float minusDM = downMove > upMove and downMove > 0 ? downMove : 0
float plusDI = 100 * ta.rma(plusDM, len) / atr
float minusDI = 100 * ta.rma(minusDM, len) / atr
float dx = math.abs(plusDI - minusDI) / (plusDI + minusDI) * 100
float adx = ta.rma(dx, len)
[adx, plusDI, minusDI]
// Calculate all indicators for a given timeframe
calcTrendScore() =>
// RSI Score (-1 to 1)
float rsi = ta.rsi(close, rsiLength)
float rsiScore = (rsi - 50) / 50
// MACD Score (-1 to 1)
[macdLine, signalLine, histLine] = ta.macd(close, macdFast, macdSlow, macdSignal)
float macdNorm = ta.stdev(macdLine, 100)
float macdScore = macdNorm != 0 ? math.max(-1, math.min(1, macdLine / (macdNorm * 2))) : 0
// ADX Score (0 to 1 for strength, direction from DI)
[adx, plusDI, minusDI] = calcADX(adxLength)
float adxStrength = math.min(adx / 50, 1)
float adxDir = plusDI > minusDI ? 1 : -1
float adxScore = adxStrength * adxDir
// MA Score (-1 to 1)
float ma = ta.sma(close, maLength)
float maScore = close > ma ? 1 : -1
float maStrength = math.abs(close - ma) / ma * 10
float maScoreWeighted = math.max(-1, math.min(1, maScore * math.min(maStrength, 1)))
// Composite Score
float composite = (rsiScore * 0.25 + macdScore * 0.25 + adxScore * 0.25 + maScoreWeighted * 0.25)
[rsiScore, macdScore, adxScore, maScoreWeighted, composite, rsi, adx, plusDI > minusDI]
// ─── CURRENT TIMEFRAME CALCULATIONS ────────────────────────────────────────────
[rsiScore1, macdScore1, adxScore1, maScore1, composite1, rsi1, adx1, bullDI1] = calcTrendScore()
// ─── MULTI-TIMEFRAME CALCULATIONS ──────────────────────────────────────────────
[rsiScore2, macdScore2, adxScore2, maScore2, composite2, rsi2, adx2, bullDI2] = request.security(syminfo.tickerid, tf2, calcTrendScore(), lookahead = barmerge.lookahead_off)
[rsiScore3, macdScore3, adxScore3, maScore3, composite3, rsi3, adx3, bullDI3] = request.security(syminfo.tickerid, tf3, calcTrendScore(), lookahead = barmerge.lookahead_off)
[rsiScore4, macdScore4, adxScore4, maScore4, composite4, rsi4, adx4, bullDI4] = request.security(syminfo.tickerid, tf4, calcTrendScore(), lookahead = barmerge.lookahead_off)
// Overall Multi-Timeframe Score
float mtfScore = useMTF ? (composite1 * 0.4 + composite2 * 0.25 + composite3 * 0.2 + composite4 * 0.15) : composite1
// Trend Direction and Strength
bool isBullish = mtfScore > 0.2
bool isBearish = mtfScore < -0.2
float trendStrength = math.abs(mtfScore)
// ─── COLORING ──────────────────────────────────────────────────────────────────
color trendColor = mtfScore > 0.2 ? bullColor : mtfScore < -0.2 ? bearColor : neutralColor
color maColor = close > ta.sma(close, maLength) ? bullColor : bearColor
// Score to color helper
scoreToColor(float score) =>
color result = neutralColor
if score > 0.5
result := bullColor
else if score > 0.2
result := color.new(bullColor, 40)
else if score < -0.5
result := bearColor
else if score < -0.2
result := color.new(bearColor, 40)
result
// ─── PLOTTING ──────────────────────────────────────────────────────────────────
// Trend MA
float trendMA = ta.sma(close, maLength)
//plot(showMA ? trendMA : na, "Trend MA", maColor, 2)
// Trend background
//bgcolor(color.new(trendColor, 95), title = "Trend Background")
// Trend change markers
bool trendUp = mtfScore > 0.2 and mtfScore[1] <= 0.2
bool trendDn = mtfScore < -0.2 and mtfScore[1] >= -0.2
//plotshape(trendUp, "Bullish Shift", shape.triangleup, location.belowbar, bullColor, size = size.small, text = "BULL")
//plotshape(trendDn, "Bearish Shift", shape.triangledown, location.abovebar, bearColor, size = size.small, text = "BEAR")
// ─── DASHBOARD ─────────────────────────────────────────────────────────────────
if showDashboard and barstate.islast
// Position mapping
string tablePos = switch dashPos
"Top Right" => position.top_right
"Top Left" => position.top_left
"Bottom Right" => position.bottom_right
"Bottom Left" => position.bottom_left
=> position.top_right
var table dash = table.new(tablePos, 6, 6,
bgcolor = color.new(#1E1E1E, 5),
frame_width = 1,
frame_color = color.new(color.white, 70),
border_width = 1,
border_color = color.new(color.white, 85))
// Header Row
table.cell(dash, 0, 0, "Trend ", text_color = color.white, text_size = size.small, bgcolor = color.new(#2962FF, 30))
table.cell(dash, 1, 0, "RSI", text_color = color.white, text_size = size.tiny, bgcolor = color.new(#2962FF, 30))
table.cell(dash, 2, 0, "MACD", text_color = color.white, text_size = size.tiny, bgcolor = color.new(#2962FF, 30))
table.cell(dash, 3, 0, "ADX", text_color = color.white, text_size = size.tiny, bgcolor = color.new(#2962FF, 30))
table.cell(dash, 4, 0, "MA", text_color = color.white, text_size = size.tiny, bgcolor = color.new(#2962FF, 30))
table.cell(dash, 5, 0, "SONUC", text_color = color.white, text_size = size.tiny, bgcolor = color.new(#2962FF, 30))
// Current Timeframe Row
string tfLabel = timeframe.period
table.cell(dash, 0, 1, tfLabel, text_color = color.white, text_size = size.tiny)
table.cell(dash, 1, 1, str.tostring(rsi1, "#"), text_color = color.white, text_size = size.tiny, bgcolor = scoreToColor(rsiScore1))
table.cell(dash, 2, 1, macdScore1 > 0 ? "+" : "-", text_color = color.white, text_size = size.tiny, bgcolor = scoreToColor(macdScore1))
table.cell(dash, 3, 1, str.tostring(adx1, "#"), text_color = color.white, text_size = size.tiny, bgcolor = scoreToColor(adxScore1))
table.cell(dash, 4, 1, maScore1 > 0 ? "+" : "-", text_color = color.white, text_size = size.tiny, bgcolor = scoreToColor(maScore1))
table.cell(dash, 5, 1, str.tostring(composite1 * 100, "#") + "%", text_color = color.white, text_size = size.tiny, bgcolor = scoreToColor(composite1))
if useMTF
// TF2 Row
table.cell(dash, 0, 2, tf2, text_color = color.white, text_size = size.tiny)
table.cell(dash, 1, 2, str.tostring(rsi2, "#"), text_color = color.white, text_size = size.tiny, bgcolor = scoreToColor(rsiScore2))
table.cell(dash, 2, 2, macdScore2 > 0 ? "+" : "-", text_color = color.white, text_size = size.tiny, bgcolor = scoreToColor(macdScore2))
table.cell(dash, 3, 2, str.tostring(adx2, "#"), text_color = color.white, text_size = size.tiny, bgcolor = scoreToColor(adxScore2))
table.cell(dash, 4, 2, maScore2 > 0 ? "+" : "-", text_color = color.white, text_size = size.tiny, bgcolor = scoreToColor(maScore2))
table.cell(dash, 5, 2, str.tostring(composite2 * 100, "#") + "%", text_color = color.white, text_size = size.tiny, bgcolor = scoreToColor(composite2))
// TF3 Row
table.cell(dash, 0, 3, tf3, text_color = color.white, text_size = size.tiny)
table.cell(dash, 1, 3, str.tostring(rsi3, "#"), text_color = color.white, text_size = size.tiny, bgcolor = scoreToColor(rsiScore3))
table.cell(dash, 2, 3, macdScore3 > 0 ? "+" : "-", text_color = color.white, text_size = size.tiny, bgcolor = scoreToColor(macdScore3))
table.cell(dash, 3, 3, str.tostring(adx3, "#"), text_color = color.white, text_size = size.tiny, bgcolor = scoreToColor(adxScore3))
table.cell(dash, 4, 3, maScore3 > 0 ? "+" : "-", text_color = color.white, text_size = size.tiny, bgcolor = scoreToColor(maScore3))
table.cell(dash, 5, 3, str.tostring(composite3 * 100, "#") + "%", text_color = color.white, text_size = size.tiny, bgcolor = scoreToColor(composite3))
// TF4 Row
table.cell(dash, 0, 4, tf4, text_color = color.white, text_size = size.tiny)
table.cell(dash, 1, 4, str.tostring(rsi4, "#"), text_color = color.white, text_size = size.tiny, bgcolor = scoreToColor(rsiScore4))
table.cell(dash, 2, 4, macdScore4 > 0 ? "+" : "-", text_color = color.white, text_size = size.tiny, bgcolor = scoreToColor(macdScore4))
table.cell(dash, 3, 4, str.tostring(adx4, "#"), text_color = color.white, text_size = size.tiny, bgcolor = scoreToColor(adxScore4))
table.cell(dash, 4, 4, maScore4 > 0 ? "+" : "-", text_color = color.white, text_size = size.tiny, bgcolor = scoreToColor(maScore4))
table.cell(dash, 5, 4, str.tostring(composite4 * 100, "#") + "%", text_color = color.white, text_size = size.tiny, bgcolor = scoreToColor(composite4))
// Overall Score Row
string overallText = mtfScore > 0.5 ? "+++BOGA" : mtfScore > 0.2 ? "BOGA" :
mtfScore < -0.5 ? "---AYI" : mtfScore < -0.2 ? "AYI" : "NOTR"
table.cell(dash, 0, 5, "SINYAL", text_color = color.white, text_size = size.tiny, bgcolor = color.new(trendColor, 30))
table.merge_cells(dash, 1, 5, 4, 5)
table.cell(dash, 1, 5, overallText, text_color = color.white, text_size = size.small, bgcolor = color.new(trendColor, 30))
table.cell(dash, 5, 5, str.tostring(mtfScore * 100, "#") + "%", text_color = color.white, text_size = size.small, bgcolor = color.new(trendColor, 30))
// ─── ALERTS ────────────────────────────────────────────────────────────────────
alertcondition(trendUp, "TSM Bullish Shift", "Trend Strength Matrix shifted BULLISH on {{ticker}}")
alertcondition(trendDn, "TSM Bearish Shift", "Trend Strength Matrix shifted BEARISH on {{ticker}}")
alertcondition(mtfScore > 0.5 and mtfScore[1] <= 0.5, "TSM Strong Bull", "Strong bullish trend confirmed on {{ticker}}")
alertcondition(mtfScore < -0.5 and mtfScore[1] >= -0.5, "TSM Strong Bear", "Strong bearish trend confirmed on {{ticker}}")
/////////////////////////////////////
scalping
Yer İmleri