ProRealCode - Trading & Coding with ProRealTime™
Here we have the Signal Forge indicator (LuxAlgo).
Multi-Indicator Signal Engine with Built-in Performance Tracking
//----------------------------------------------------------//
//PRC_Signal Forge (by LuxAlgo)
//version = 0
//11.06.26
//Iván González @ www.prorealcode.com
//Sharing ProRealTime knowledge
//----------------------------------------------------------//
//-----Signal logic------------------------------------------//
requireAll = 1 // 1 = ALL enabled indicators must align / 0 = ANY enabled indicator triggers
//-----Risk management (ATR)---------------------------------//
atrLen = 14 // ATR length
enableSl = 0 // stop loss on/off
slMult = 1.5 // SL multiplier
enableTp = 0 // take profit on/off
tpMult = 2.0 // TP multiplier
enableTs = 0 // trailing stop on/off
tsMult = 1.0 // TS multiplier
//-----Visuals-----------------------------------------------//
showOrbs = 1 // entry orbs + WR labels on/off
orbDist = 1.5 // orb distance (ATR units)
showDash = 1 // dashboards on/off
//-----Indicator toggles & settings--------------------------//
enableSma = 1 // SMA crossover
smaFastLen = 10
smaSlowLen = 20
enableRsi = 0 // RSI filter
rsiLen = 14
rsiLongLevel = 50
rsiShortLevel = 50
enableMacd = 0 // MACD crossover
macdFastLen = 12
macdSlowLen = 26
macdSigLen = 9
enableSt = 0 // Supertrend
stFactor = 3.0
stLen = 10
enableStoch = 0 // Stochastic (%K vs 50)
stochLen = 14
stochSmooth = 3
enableBb = 0 // Bollinger trend (close vs middle band)
bbLen = 20
enableEma = 0 // EMA crossover
emaFastLen = 10
emaSlowLen = 20
enableAo = 0 // Awesome Oscillator
enableSar = 0 // Parabolic SAR
sarStart = 0.02
sarInc = 0.02
sarMax = 0.2
enableCci = 0 // CCI filter
cciLen = 20
cciLongLevel = 0
cciShortLevel = 0
enableAdx = 0 // ADX filter
adxLen = 14 // ADX smoothing
diLen = 14 // DI length
adxThreshold = 20
//-----Colors------------------------------------------------//
bullR = 8
bullG = 153
bullB = 129
bearR = 242
bearG = 54
bearB = 69
tsR = 41
tsG = 98
tsB = 255
neuR = 128
neuG = 128
neuB = 128
txtR = 219
txtG = 219
txtB = 219
//----------------------------------------------------------//
//-----Indicator calculations--------------------------------//
atrV = averagetruerange[atrLen]
// 1. SMA crossover
smaFast = average[smaFastLen](close)
smaSlow = average[smaSlowLen](close)
smaBull = smaFast > smaSlow
smaBear = smaFast < smaSlow
// 2. RSI filter
rsiV = rsi[rsiLen](close)
rsiBull = rsiV > rsiLongLevel
rsiBear = rsiV < rsiShortLevel
// 3. MACD crossover
macdL = macdline[macdFastLen,macdSlowLen,macdSigLen](close)
macdS = macdsignal[macdFastLen,macdSlowLen,macdSigLen](close)
macdBull = macdL > macdS
macdBear = macdL < macdS
// 4. Supertrend
stV = supertrend[stFactor,stLen]
stBull = close > stV
stBear = close < stV
// 5. Stochastic (smoothed %K, upper/lower half)
stochK = stochastic[stochLen,stochSmooth](close)
stochBull = stochK > 50
stochBear = stochK < 50
// 6. Bollinger trend (close vs middle band)
bbMid = average[bbLen](close)
bbBull = close > bbMid
bbBear = close < bbMid
// 7. EMA crossover
emaFast = average[emaFastLen,1](close)
emaSlow = average[emaSlowLen,1](close)
emaBull = emaFast > emaSlow
emaBear = emaFast < emaSlow
// 8. Awesome Oscillator
medPrice = (high + low) / 2
aoV = average[5](medPrice) - average[34](medPrice)
aoBull = aoV > 0
aoBear = aoV < 0
// 9. Parabolic SAR
sarV = sar[sarStart,sarInc,sarMax]
sarBull = close > sarV
sarBear = close < sarV
// 10. CCI filter
cciV = cci[cciLen](close)
cciBull = cciV > cciLongLevel
cciBear = cciV < cciShortLevel
// 11. ADX filter
adxV = adx[adxLen]
diP = diplus[diLen](close)
diM = diminus[diLen](close)
adxBull = adxV > adxThreshold and diP > diM
adxBear = adxV > adxThreshold and diM > diP
//----------------------------------------------------------//
//-----Standalone performance tracking-----------------------//
// one virtual trade book per indicator (always computed,
// independent of toggles) -> feeds dashboard WR column
$bullA[0] = smaBull
$bullA[1] = rsiBull
$bullA[2] = macdBull
$bullA[3] = stBull
$bullA[4] = stochBull
$bullA[5] = bbBull
$bullA[6] = emaBull
$bullA[7] = aoBull
$bullA[8] = sarBull
$bullA[9] = cciBull
$bullA[10] = adxBull
$bearA[0] = smaBear
$bearA[1] = rsiBear
$bearA[2] = macdBear
$bearA[3] = stBear
$bearA[4] = stochBear
$bearA[5] = bbBear
$bearA[6] = emaBear
$bearA[7] = aoBear
$bearA[8] = sarBear
$bearA[9] = cciBear
$bearA[10] = adxBear
if not isset($indState[0]) then
for j = 0 to 10 do
$indState[j] = 0
$indEntry[j] = 0
$indSl[j] = 0
$indTp[j] = 0
$indTs[j] = 0
$indTotal[j] = 0
$indWin[j] = 0
$prevBull[j] = 0
$prevBear[j] = 0
next
endif
for i = 0 to 10 do
bullI = $bullA[i]
bearI = $bearA[i]
stateI = $indState[i]
exitL = 0
exitS = 0
pxOut = 0
// exits (SL -> TP -> TS -> opposite signal)
if stateI = 1 then
if enableSl = 1 and low <= $indSl[i] then
exitL = 1
pxOut = $indSl[i]
elsif enableTp = 1 and high >= $indTp[i] then
exitL = 1
pxOut = $indTp[i]
elsif enableTs = 1 and low <= $indTs[i] then
exitL = 1
pxOut = $indTs[i]
elsif bearI = 1 then
exitL = 1
pxOut = close
endif
endif
if stateI = -1 then
if enableSl = 1 and high >= $indSl[i] then
exitS = 1
pxOut = $indSl[i]
elsif enableTp = 1 and low <= $indTp[i] then
exitS = 1
pxOut = $indTp[i]
elsif enableTs = 1 and high >= $indTs[i] then
exitS = 1
pxOut = $indTs[i]
elsif bullI = 1 then
exitS = 1
pxOut = close
endif
endif
// book closed trades
if exitL = 1 then
retI = (pxOut - $indEntry[i]) / $indEntry[i] * 100
$indTotal[i] = $indTotal[i] + 1
if retI > 0 then
$indWin[i] = $indWin[i] + 1
endif
$indState[i] = 0
$indSl[i] = 0
$indTp[i] = 0
$indTs[i] = 0
stateI = 0
endif
if exitS = 1 then
retI = ($indEntry[i] - pxOut) / $indEntry[i] * 100
$indTotal[i] = $indTotal[i] + 1
if retI > 0 then
$indWin[i] = $indWin[i] + 1
endif
$indState[i] = 0
$indSl[i] = 0
$indTp[i] = 0
$indTs[i] = 0
stateI = 0
endif
// entries on signal edge (state change vs previous bar)
entL = 0
if bullI = 1 and $prevBull[i] = 0 and stateI <> 1 then
entL = 1
endif
entS = 0
if bearI = 1 and $prevBear[i] = 0 and stateI <> -1 then
entS = 1
endif
if entL = 1 then
$indState[i] = 1
$indEntry[i] = close
if enableSl = 1 then
$indSl[i] = close - atrV * slMult
endif
if enableTp = 1 then
$indTp[i] = close + atrV * tpMult
endif
if enableTs = 1 then
$indTs[i] = close - atrV * tsMult
endif
endif
if entS = 1 then
$indState[i] = -1
$indEntry[i] = close
if enableSl = 1 then
$indSl[i] = close + atrV * slMult
endif
if enableTp = 1 then
$indTp[i] = close - atrV * tpMult
endif
if enableTs = 1 then
$indTs[i] = close + atrV * tsMult
endif
endif
// trailing stop ratchet
if stateI = 1 and entL = 0 and enableTs = 1 then
$indTs[i] = max($indTs[i], close - atrV * tsMult)
endif
if stateI = -1 and entS = 0 and enableTs = 1 then
$indTs[i] = min($indTs[i], close + atrV * tsMult)
endif
$prevBull[i] = bullI
$prevBear[i] = bearI
next
//----------------------------------------------------------//
//-----Combined signal logic---------------------------------//
enabledN = enableSma + enableRsi + enableMacd + enableSt + enableStoch + enableBb + enableEma + enableAo + enableSar + enableCci + enableAdx
bullN = enableSma * smaBull + enableRsi * rsiBull + enableMacd * macdBull + enableSt * stBull + enableStoch * stochBull + enableBb * bbBull + enableEma * emaBull + enableAo * aoBull + enableSar * sarBull + enableCci * cciBull + enableAdx * adxBull
bearN = enableSma * smaBear + enableRsi * rsiBear + enableMacd * macdBear + enableSt * stBear + enableStoch * stochBear + enableBb * bbBear + enableEma * emaBear + enableAo * aoBear + enableSar * sarBear + enableCci * cciBear + enableAdx * adxBear
longCond = 0
shortCond = 0
if enabledN > 0 then
if requireAll = 1 then
if bullN = enabledN then
longCond = 1
endif
if bearN = enabledN then
shortCond = 1
endif
else
if bullN > 0 then
longCond = 1
endif
if bearN > 0 then
shortCond = 1
endif
endif
endif
//----------------------------------------------------------//
//-----Internal backtester (combined signal)-----------------//
once tradeState = 0
once entryPx = 0
once slLvl = 0
once tpLvl = 0
once tsLvl = 0
once totalTrades = 0
once winTrades = 0
once netPnl = 0
once gProfit = 0
once gLoss = 0
outLong = 0
outShort = 0
outLongPx = 0
outShortPx = 0
// 1. evaluate exits (SL -> TP -> TS -> opposite signal)
if tradeState = 1 then
if enableSl = 1 and low <= slLvl then
outLong = 1
outLongPx = slLvl
elsif enableTp = 1 and high >= tpLvl then
outLong = 1
outLongPx = tpLvl
elsif enableTs = 1 and low <= tsLvl then
outLong = 1
outLongPx = tsLvl
elsif shortCond = 1 then
outLong = 1
outLongPx = close
endif
endif
if tradeState = -1 then
if enableSl = 1 and high >= slLvl then
outShort = 1
outShortPx = slLvl
elsif enableTp = 1 and low <= tpLvl then
outShort = 1
outShortPx = tpLvl
elsif enableTs = 1 and high >= tsLvl then
outShort = 1
outShortPx = tsLvl
elsif longCond = 1 then
outShort = 1
outShortPx = close
endif
endif
// 2. process exits & update metrics
if outLong = 1 then
tradeRet = (outLongPx - entryPx) / entryPx * 100
netPnl = netPnl + tradeRet
totalTrades = totalTrades + 1
if tradeRet > 0 then
winTrades = winTrades + 1
gProfit = gProfit + tradeRet
else
gLoss = gLoss + abs(tradeRet)
endif
tradeState = 0
slLvl = 0
tpLvl = 0
tsLvl = 0
endif
if outShort = 1 then
tradeRet = (entryPx - outShortPx) / entryPx * 100
netPnl = netPnl + tradeRet
totalTrades = totalTrades + 1
if tradeRet > 0 then
winTrades = winTrades + 1
gProfit = gProfit + tradeRet
else
gLoss = gLoss + abs(tradeRet)
endif
tradeState = 0
slLvl = 0
tpLvl = 0
tsLvl = 0
endif
// 3. new entries on signal edge
goLong = 0
if longCond = 1 and longCond[1] <> 1 and tradeState <> 1 then
goLong = 1
endif
goShort = 0
if shortCond = 1 and shortCond[1] <> 1 and tradeState <> -1 then
goShort = 1
endif
if goLong = 1 then
tradeState = 1
entryPx = close
if enableSl = 1 then
slLvl = close - atrV * slMult
endif
if enableTp = 1 then
tpLvl = close + atrV * tpMult
endif
if enableTs = 1 then
tsLvl = close - atrV * tsMult
endif
endif
if goShort = 1 then
tradeState = -1
entryPx = close
if enableSl = 1 then
slLvl = close + atrV * slMult
endif
if enableTp = 1 then
tpLvl = close - atrV * tpMult
endif
if enableTs = 1 then
tsLvl = close + atrV * tsMult
endif
endif
// 4. trailing stop ratchet for ongoing trades
if tradeState = 1 and goLong = 0 and enableTs = 1 then
tsLvl = max(tsLvl, close - atrV * tsMult)
endif
if tradeState = -1 and goShort = 0 and enableTs = 1 then
tsLvl = min(tsLvl, close + atrV * tsMult)
endif
//----------------------------------------------------------//
//-----Entry visuals (glow orbs + WR label, event class)-----//
if totalTrades > 0 then
wrNow = round(winTrades / totalTrades * 100, 1)
else
wrNow = 0
endif
if goLong = 1 then
glowY = low - atrV * orbDist
if showOrbs = 1 then
drawsegment(barindex, low, barindex, glowY) coloured(bullR, bullG, bullB, 60) style(line, 2)
drawpoint(barindex, glowY, 5) coloured(bullR, bullG, bullB, 50)
drawpoint(barindex, glowY, 3) coloured(bullR, bullG, bullB, 130)
drawpoint(barindex, glowY, 2) coloured(bullR, bullG, bullB, 255)
drawtext("#wrNow#%", barindex, glowY - atrV * 0.6) coloured(bullR, bullG, bullB)
endif
endif
if goShort = 1 then
glowY = high + atrV * orbDist
if showOrbs = 1 then
drawsegment(barindex, high, barindex, glowY) coloured(bearR, bearG, bearB, 60) style(line, 2)
drawpoint(barindex, glowY, 5) coloured(bearR, bearG, bearB, 50)
drawpoint(barindex, glowY, 3) coloured(bearR, bearG, bearB, 130)
drawpoint(barindex, glowY, 2) coloured(bearR, bearG, bearB, 255)
drawtext("#wrNow#%", barindex, glowY + atrV * 0.6) coloured(bearR, bearG, bearB)
endif
endif
// exit marks (skipped if immediately reversed)
if outLong = 1 and goShort = 0 then
drawtext("x", barindex, high + atrV * 0.5) coloured(bearR, bearG, bearB)
endif
if outShort = 1 and goLong = 0 then
drawtext("x", barindex, low - atrV * 0.5) coloured(bullR, bullG, bullB)
endif
//----------------------------------------------------------//
//-----Active trade levels (plots)---------------------------//
slPlot = undefined
tpPlot = undefined
tsPlot = undefined
closePlot = undefined
inEntryBar = 0
if goLong = 1 or goShort = 1 then
inEntryBar = 1
endif
if tradeState <> 0 and inEntryBar = 0 then
if enableSl = 1 then
slPlot = slLvl
endif
if enableTp = 1 then
tpPlot = tpLvl
endif
if enableTs = 1 then
tsPlot = tsLvl
closePlot = close
endif
endif
// trailing stop shading (price vs trailing level)
colorbetween(tsPlot, closePlot, tsR, tsG, tsB)
//----------------------------------------------------------//
//-----Dashboards (last bar only)----------------------------//
if islastbarupdate and showDash = 1 then
// ===== Indicator dashboard (top right corner) =====
drawrectangle(-465, -15, -85, -370) anchor(topright, xshift, yshift) fillcolor("black", 60)
drawtext("SIGNAL FORGE", -240, -28) anchor(topright, xshift, yshift) coloured(txtR, txtG, txtB)
drawtext("Indicator", -420, -52) anchor(topright, xshift, yshift) coloured(neuR, neuG, neuB)
drawtext("Status", -300, -52) anchor(topright, xshift, yshift) coloured(neuR, neuG, neuB)
drawtext("WR (trades)", -180, -52) anchor(topright, xshift, yshift) coloured(neuR, neuG, neuB)
drawtext("On", -45, -52) anchor(topright, xshift, yshift) coloured(neuR, neuG, neuB)
// --- row 1: SMA Cross (y=-77)
tt = $indTotal[0]
if tt > 0 then
wrI = round($indWin[0] / tt * 100, 1)
else
wrI = 0
endif
drawtext("SMA Cross", -420, -77) anchor(topright, xshift, yshift) coloured(txtR, txtG, txtB)
if smaBull = 1 then
drawtext("Bullish", -300, -77) anchor(topright, xshift, yshift) coloured(bullR, bullG, bullB)
elsif smaBear = 1 then
drawtext("Bearish", -300, -77) anchor(topright, xshift, yshift) coloured(bearR, bearG, bearB)
else
drawtext("Neutral", -300, -77) anchor(topright, xshift, yshift) coloured(neuR, neuG, neuB)
endif
if tt = 0 then
drawtext("n/a", -180, -77) anchor(topright, xshift, yshift) coloured(neuR, neuG, neuB)
elsif wrI >= 50 then
drawtext("#wrI#% (#tt#)", -180, -77) anchor(topright, xshift, yshift) coloured(bullR, bullG, bullB)
else
drawtext("#wrI#% (#tt#)", -180, -77) anchor(topright, xshift, yshift) coloured(bearR, bearG, bearB)
endif
if enableSma = 1 then
drawtext("ON", -45, -77) anchor(topright, xshift, yshift) coloured(bullR, bullG, bullB)
else
drawtext("OFF", -45, -77) anchor(topright, xshift, yshift) coloured(neuR, neuG, neuB)
endif
// --- row 2: RSI (y=-102)
tt = $indTotal[1]
if tt > 0 then
wrI = round($indWin[1] / tt * 100, 1)
else
wrI = 0
endif
drawtext("RSI", -420, -102) anchor(topright, xshift, yshift) coloured(txtR, txtG, txtB)
if rsiBull = 1 then
drawtext("Bullish", -300, -102) anchor(topright, xshift, yshift) coloured(bullR, bullG, bullB)
elsif rsiBear = 1 then
drawtext("Bearish", -300, -102) anchor(topright, xshift, yshift) coloured(bearR, bearG, bearB)
else
drawtext("Neutral", -300, -102) anchor(topright, xshift, yshift) coloured(neuR, neuG, neuB)
endif
if tt = 0 then
drawtext("n/a", -180, -102) anchor(topright, xshift, yshift) coloured(neuR, neuG, neuB)
elsif wrI >= 50 then
drawtext("#wrI#% (#tt#)", -180, -102) anchor(topright, xshift, yshift) coloured(bullR, bullG, bullB)
else
drawtext("#wrI#% (#tt#)", -180, -102) anchor(topright, xshift, yshift) coloured(bearR, bearG, bearB)
endif
if enableRsi = 1 then
drawtext("ON", -45, -102) anchor(topright, xshift, yshift) coloured(bullR, bullG, bullB)
else
drawtext("OFF", -45, -102) anchor(topright, xshift, yshift) coloured(neuR, neuG, neuB)
endif
// --- row 3: MACD (y=-127)
tt = $indTotal[2]
if tt > 0 then
wrI = round($indWin[2] / tt * 100, 1)
else
wrI = 0
endif
drawtext("MACD", -420, -127) anchor(topright, xshift, yshift) coloured(txtR, txtG, txtB)
if macdBull = 1 then
drawtext("Bullish", -300, -127) anchor(topright, xshift, yshift) coloured(bullR, bullG, bullB)
elsif macdBear = 1 then
drawtext("Bearish", -300, -127) anchor(topright, xshift, yshift) coloured(bearR, bearG, bearB)
else
drawtext("Neutral", -300, -127) anchor(topright, xshift, yshift) coloured(neuR, neuG, neuB)
endif
if tt = 0 then
drawtext("n/a", -180, -127) anchor(topright, xshift, yshift) coloured(neuR, neuG, neuB)
elsif wrI >= 50 then
drawtext("#wrI#% (#tt#)", -180, -127) anchor(topright, xshift, yshift) coloured(bullR, bullG, bullB)
else
drawtext("#wrI#% (#tt#)", -180, -127) anchor(topright, xshift, yshift) coloured(bearR, bearG, bearB)
endif
if enableMacd = 1 then
drawtext("ON", -45, -127) anchor(topright, xshift, yshift) coloured(bullR, bullG, bullB)
else
drawtext("OFF", -45, -127) anchor(topright, xshift, yshift) coloured(neuR, neuG, neuB)
endif
// --- row 4: Supertrend (y=-152)
tt = $indTotal[3]
if tt > 0 then
wrI = round($indWin[3] / tt * 100, 1)
else
wrI = 0
endif
drawtext("Supertrend", -420, -152) anchor(topright, xshift, yshift) coloured(txtR, txtG, txtB)
if stBull = 1 then
drawtext("Bullish", -300, -152) anchor(topright, xshift, yshift) coloured(bullR, bullG, bullB)
elsif stBear = 1 then
drawtext("Bearish", -300, -152) anchor(topright, xshift, yshift) coloured(bearR, bearG, bearB)
else
drawtext("Neutral", -300, -152) anchor(topright, xshift, yshift) coloured(neuR, neuG, neuB)
endif
if tt = 0 then
drawtext("n/a", -180, -152) anchor(topright, xshift, yshift) coloured(neuR, neuG, neuB)
elsif wrI >= 50 then
drawtext("#wrI#% (#tt#)", -180, -152) anchor(topright, xshift, yshift) coloured(bullR, bullG, bullB)
else
drawtext("#wrI#% (#tt#)", -180, -152) anchor(topright, xshift, yshift) coloured(bearR, bearG, bearB)
endif
if enableSt = 1 then
drawtext("ON", -45, -152) anchor(topright, xshift, yshift) coloured(bullR, bullG, bullB)
else
drawtext("OFF", -45, -152) anchor(topright, xshift, yshift) coloured(neuR, neuG, neuB)
endif
// --- row 5: Stochastic (y=-177)
tt = $indTotal[4]
if tt > 0 then
wrI = round($indWin[4] / tt * 100, 1)
else
wrI = 0
endif
drawtext("Stochastic", -420, -177) anchor(topright, xshift, yshift) coloured(txtR, txtG, txtB)
if stochBull = 1 then
drawtext("Bullish", -300, -177) anchor(topright, xshift, yshift) coloured(bullR, bullG, bullB)
elsif stochBear = 1 then
drawtext("Bearish", -300, -177) anchor(topright, xshift, yshift) coloured(bearR, bearG, bearB)
else
drawtext("Neutral", -300, -177) anchor(topright, xshift, yshift) coloured(neuR, neuG, neuB)
endif
if tt = 0 then
drawtext("n/a", -180, -177) anchor(topright, xshift, yshift) coloured(neuR, neuG, neuB)
elsif wrI >= 50 then
drawtext("#wrI#% (#tt#)", -180, -177) anchor(topright, xshift, yshift) coloured(bullR, bullG, bullB)
else
drawtext("#wrI#% (#tt#)", -180, -177) anchor(topright, xshift, yshift) coloured(bearR, bearG, bearB)
endif
if enableStoch = 1 then
drawtext("ON", -45, -177) anchor(topright, xshift, yshift) coloured(bullR, bullG, bullB)
else
drawtext("OFF", -45, -177) anchor(topright, xshift, yshift) coloured(neuR, neuG, neuB)
endif
// --- row 6: Bollinger (y=-202)
tt = $indTotal[5]
if tt > 0 then
wrI = round($indWin[5] / tt * 100, 1)
else
wrI = 0
endif
drawtext("Bollinger", -420, -202) anchor(topright, xshift, yshift) coloured(txtR, txtG, txtB)
if bbBull = 1 then
drawtext("Bullish", -300, -202) anchor(topright, xshift, yshift) coloured(bullR, bullG, bullB)
elsif bbBear = 1 then
drawtext("Bearish", -300, -202) anchor(topright, xshift, yshift) coloured(bearR, bearG, bearB)
else
drawtext("Neutral", -300, -202) anchor(topright, xshift, yshift) coloured(neuR, neuG, neuB)
endif
if tt = 0 then
drawtext("n/a", -180, -202) anchor(topright, xshift, yshift) coloured(neuR, neuG, neuB)
elsif wrI >= 50 then
drawtext("#wrI#% (#tt#)", -180, -202) anchor(topright, xshift, yshift) coloured(bullR, bullG, bullB)
else
drawtext("#wrI#% (#tt#)", -180, -202) anchor(topright, xshift, yshift) coloured(bearR, bearG, bearB)
endif
if enableBb = 1 then
drawtext("ON", -45, -202) anchor(topright, xshift, yshift) coloured(bullR, bullG, bullB)
else
drawtext("OFF", -45, -202) anchor(topright, xshift, yshift) coloured(neuR, neuG, neuB)
endif
// --- row 7: EMA Cross (y=-227)
tt = $indTotal[6]
if tt > 0 then
wrI = round($indWin[6] / tt * 100, 1)
else
wrI = 0
endif
drawtext("EMA Cross", -420, -227) anchor(topright, xshift, yshift) coloured(txtR, txtG, txtB)
if emaBull = 1 then
drawtext("Bullish", -300, -227) anchor(topright, xshift, yshift) coloured(bullR, bullG, bullB)
elsif emaBear = 1 then
drawtext("Bearish", -300, -227) anchor(topright, xshift, yshift) coloured(bearR, bearG, bearB)
else
drawtext("Neutral", -300, -227) anchor(topright, xshift, yshift) coloured(neuR, neuG, neuB)
endif
if tt = 0 then
drawtext("n/a", -180, -227) anchor(topright, xshift, yshift) coloured(neuR, neuG, neuB)
elsif wrI >= 50 then
drawtext("#wrI#% (#tt#)", -180, -227) anchor(topright, xshift, yshift) coloured(bullR, bullG, bullB)
else
drawtext("#wrI#% (#tt#)", -180, -227) anchor(topright, xshift, yshift) coloured(bearR, bearG, bearB)
endif
if enableEma = 1 then
drawtext("ON", -45, -227) anchor(topright, xshift, yshift) coloured(bullR, bullG, bullB)
else
drawtext("OFF", -45, -227) anchor(topright, xshift, yshift) coloured(neuR, neuG, neuB)
endif
// --- row 8: AO (y=-252)
tt = $indTotal[7]
if tt > 0 then
wrI = round($indWin[7] / tt * 100, 1)
else
wrI = 0
endif
drawtext("AO", -420, -252) anchor(topright, xshift, yshift) coloured(txtR, txtG, txtB)
if aoBull = 1 then
drawtext("Bullish", -300, -252) anchor(topright, xshift, yshift) coloured(bullR, bullG, bullB)
elsif aoBear = 1 then
drawtext("Bearish", -300, -252) anchor(topright, xshift, yshift) coloured(bearR, bearG, bearB)
else
drawtext("Neutral", -300, -252) anchor(topright, xshift, yshift) coloured(neuR, neuG, neuB)
endif
if tt = 0 then
drawtext("n/a", -180, -252) anchor(topright, xshift, yshift) coloured(neuR, neuG, neuB)
elsif wrI >= 50 then
drawtext("#wrI#% (#tt#)", -180, -252) anchor(topright, xshift, yshift) coloured(bullR, bullG, bullB)
else
drawtext("#wrI#% (#tt#)", -180, -252) anchor(topright, xshift, yshift) coloured(bearR, bearG, bearB)
endif
if enableAo = 1 then
drawtext("ON", -45, -252) anchor(topright, xshift, yshift) coloured(bullR, bullG, bullB)
else
drawtext("OFF", -45, -252) anchor(topright, xshift, yshift) coloured(neuR, neuG, neuB)
endif
// --- row 9: SAR (y=-277)
tt = $indTotal[8]
if tt > 0 then
wrI = round($indWin[8] / tt * 100, 1)
else
wrI = 0
endif
drawtext("SAR", -420, -277) anchor(topright, xshift, yshift) coloured(txtR, txtG, txtB)
if sarBull = 1 then
drawtext("Bullish", -300, -277) anchor(topright, xshift, yshift) coloured(bullR, bullG, bullB)
elsif sarBear = 1 then
drawtext("Bearish", -300, -277) anchor(topright, xshift, yshift) coloured(bearR, bearG, bearB)
else
drawtext("Neutral", -300, -277) anchor(topright, xshift, yshift) coloured(neuR, neuG, neuB)
endif
if tt = 0 then
drawtext("n/a", -180, -277) anchor(topright, xshift, yshift) coloured(neuR, neuG, neuB)
elsif wrI >= 50 then
drawtext("#wrI#% (#tt#)", -180, -277) anchor(topright, xshift, yshift) coloured(bullR, bullG, bullB)
else
drawtext("#wrI#% (#tt#)", -180, -277) anchor(topright, xshift, yshift) coloured(bearR, bearG, bearB)
endif
if enableSar = 1 then
drawtext("ON", -45, -277) anchor(topright, xshift, yshift) coloured(bullR, bullG, bullB)
else
drawtext("OFF", -45, -277) anchor(topright, xshift, yshift) coloured(neuR, neuG, neuB)
endif
// --- row 10: CCI (y=-302)
tt = $indTotal[9]
if tt > 0 then
wrI = round($indWin[9] / tt * 100, 1)
else
wrI = 0
endif
drawtext("CCI", -420, -302) anchor(topright, xshift, yshift) coloured(txtR, txtG, txtB)
if cciBull = 1 then
drawtext("Bullish", -300, -302) anchor(topright, xshift, yshift) coloured(bullR, bullG, bullB)
elsif cciBear = 1 then
drawtext("Bearish", -300, -302) anchor(topright, xshift, yshift) coloured(bearR, bearG, bearB)
else
drawtext("Neutral", -300, -302) anchor(topright, xshift, yshift) coloured(neuR, neuG, neuB)
endif
if tt = 0 then
drawtext("n/a", -180, -302) anchor(topright, xshift, yshift) coloured(neuR, neuG, neuB)
elsif wrI >= 50 then
drawtext("#wrI#% (#tt#)", -180, -302) anchor(topright, xshift, yshift) coloured(bullR, bullG, bullB)
else
drawtext("#wrI#% (#tt#)", -180, -302) anchor(topright, xshift, yshift) coloured(bearR, bearG, bearB)
endif
if enableCci = 1 then
drawtext("ON", -45, -302) anchor(topright, xshift, yshift) coloured(bullR, bullG, bullB)
else
drawtext("OFF", -45, -302) anchor(topright, xshift, yshift) coloured(neuR, neuG, neuB)
endif
// --- row 11: ADX Filter (y=-327)
tt = $indTotal[10]
if tt > 0 then
wrI = round($indWin[10] / tt * 100, 1)
else
wrI = 0
endif
drawtext("ADX Filter", -420, -327) anchor(topright, xshift, yshift) coloured(txtR, txtG, txtB)
if adxBull = 1 then
drawtext("Bullish", -300, -327) anchor(topright, xshift, yshift) coloured(bullR, bullG, bullB)
elsif adxBear = 1 then
drawtext("Bearish", -300, -327) anchor(topright, xshift, yshift) coloured(bearR, bearG, bearB)
else
drawtext("Neutral", -300, -327) anchor(topright, xshift, yshift) coloured(neuR, neuG, neuB)
endif
if tt = 0 then
drawtext("n/a", -180, -327) anchor(topright, xshift, yshift) coloured(neuR, neuG, neuB)
elsif wrI >= 50 then
drawtext("#wrI#% (#tt#)", -180, -327) anchor(topright, xshift, yshift) coloured(bullR, bullG, bullB)
else
drawtext("#wrI#% (#tt#)", -180, -327) anchor(topright, xshift, yshift) coloured(bearR, bearG, bearB)
endif
if enableAdx = 1 then
drawtext("ON", -45, -327) anchor(topright, xshift, yshift) coloured(bullR, bullG, bullB)
else
drawtext("OFF", -45, -327) anchor(topright, xshift, yshift) coloured(neuR, neuG, neuB)
endif
// --- current combined signal (y=-352)
drawtext("Current Signal", -407, -352) anchor(topright, xshift, yshift) coloured(neuR, neuG, neuB)
if longCond = 1 then
drawtext("LONG", -50, -352) anchor(topright, xshift, yshift) coloured(bullR, bullG, bullB)
elsif shortCond = 1 then
drawtext("SHORT", -52, -352) anchor(topright, xshift, yshift) coloured(bearR, bearG, bearB)
else
drawtext("NEUTRAL", -58, -352) anchor(topright, xshift, yshift) coloured(neuR, neuG, neuB)
endif
// ===== Performance dashboard (bottom right corner) =====
// borde derecho alineado con el panel superior (x=-85): la franja
// 0..-85 px queda bajo el eje de precios y no se ve
drawrectangle(-445, 95, -85, 15) anchor(bottomright, xshift, yshift) fillcolor("black", 60)
drawtext("BACKTEST RESULTS", -265, 80) anchor(bottomright, xshift, yshift) coloured(txtR, txtG, txtB)
drawtext("Trades", -405, 55) anchor(bottomright, xshift, yshift) coloured(neuR, neuG, neuB)
drawtext("Wins", -345, 55) anchor(bottomright, xshift, yshift) coloured(neuR, neuG, neuB)
drawtext("Losses", -285, 55) anchor(bottomright, xshift, yshift) coloured(neuR, neuG, neuB)
drawtext("WR", -220, 55) anchor(bottomright, xshift, yshift) coloured(neuR, neuG, neuB)
drawtext("PF", -170, 55) anchor(bottomright, xshift, yshift) coloured(neuR, neuG, neuB)
drawtext("PnL%", -115, 55) anchor(bottomright, xshift, yshift) coloured(neuR, neuG, neuB)
lossTrades = totalTrades - winTrades
drawtext("#totalTrades#", -405, 30) anchor(bottomright, xshift, yshift) coloured(txtR, txtG, txtB)
drawtext("#winTrades#", -345, 30) anchor(bottomright, xshift, yshift) coloured(txtR, txtG, txtB)
drawtext("#lossTrades#", -285, 30) anchor(bottomright, xshift, yshift) coloured(txtR, txtG, txtB)
if totalTrades > 0 then
wrAll = round(winTrades / totalTrades * 100, 2)
if wrAll >= 50 then
drawtext("#wrAll#%", -220, 30) anchor(bottomright, xshift, yshift) coloured(bullR, bullG, bullB)
else
drawtext("#wrAll#%", -220, 30) anchor(bottomright, xshift, yshift) coloured(bearR, bearG, bearB)
endif
else
drawtext("n/a", -220, 30) anchor(bottomright, xshift, yshift) coloured(neuR, neuG, neuB)
endif
if gLoss > 0 then
pfV = round(gProfit / gLoss, 2)
if pfV > 1 then
drawtext("#pfV#", -170, 30) anchor(bottomright, xshift, yshift) coloured(bullR, bullG, bullB)
else
drawtext("#pfV#", -170, 30) anchor(bottomright, xshift, yshift) coloured(bearR, bearG, bearB)
endif
elsif gProfit > 0 then
drawtext("MAX", -170, 30) anchor(bottomright, xshift, yshift) coloured(bullR, bullG, bullB)
else
drawtext("0", -170, 30) anchor(bottomright, xshift, yshift) coloured(neuR, neuG, neuB)
endif
pnlV = round(netPnl, 2)
if pnlV > 0 then
drawtext("#pnlV#%", -115, 30) anchor(bottomright, xshift, yshift) coloured(bullR, bullG, bullB)
elsif pnlV < 0 then
drawtext("#pnlV#%", -115, 30) anchor(bottomright, xshift, yshift) coloured(bearR, bearG, bearB)
else
drawtext("#pnlV#%", -115, 30) anchor(bottomright, xshift, yshift) coloured(neuR, neuG, neuB)
endif
endif
//----------------------------------------------------------//
return slPlot as "Stop Loss" coloured(bearR, bearG, bearB) style(line, 1), tpPlot as "Take Profit" coloured(bullR, bullG, bullB) style(line, 1), tsPlot as "Trailing Stop" coloured(tsR, tsG, tsB) style(line, 2), closePlot as "Price (TS zone)" coloured(0, 0, 0, 0)
The information collected on this form is stored in a computer file by ProRealCode to create and access your ProRealCode profile. This data is kept in a secure database for the duration of the member's membership. They will be kept as long as you use our services and will be automatically deleted after 3 years of inactivity. Your personal data is used to create your private profile on ProRealCode. This data is maintained by SAS ProRealCode, 407 rue Freycinet, 59151 Arleux, France. If you subscribe to our newsletters, your email address is provided to our service provider "MailChimp" located in the United States, with whom we have signed a confidentiality agreement. This company is also compliant with the EU/Swiss Privacy Shield, and the GDPR. For any request for correction or deletion concerning your data, you can directly contact the ProRealCode team by email at privacy@prorealcode.com If you would like to lodge a complaint regarding the use of your personal data, you can contact your data protection supervisory authority.