ProRealCode - Trading & Coding with ProRealTime™
Ho visto l’indicatore su Tradingview e mi sembra interessante.
Chiedo su si può tradurre per PRT.
Grazie
LOKI H1 Zones V5 indicator:
Here are two indicators:
1) LOKI Dashboard — Apply it on a 1-minute chart. It reads trend bias across 9 timeframes (M1, M3, M5, M15, M30, H1, H3, H4, D) and displays a panel in the top-right corner with BUY/SELL/WAIT for each one.
//----------------------------------------------------------------------//
// PRC_LOKI Dashboard 1m
// version = 0
// 16.03.2026
// Iván González @ www.prorealcode.com
// Sharing ProRealTime knowledge
//----------------------------------------------------------------------//
// Multi-timeframe trend panel (M1 to Daily)
// MUST be applied on M1 chart to access all higher TFs
//----------------------------------------------------------------------//
defparam drawonlastbaronly = true
//----------------------------------------------------------------------//
// ============ TREND LOGIC PER TIMEFRAME ============
// Pattern: bearish engulfing → resistance level
// bullish engulfing → support level
// Close > lastRes → BUY | Close < lastSup → SELL | else → WAIT
// Each TF has its own lastRes, lastSup, trend variables
//----------------------------------------------------------------------//
// M1 (default timeframe)
//----------------------------------------------------------------------//
m1BT1 = max(close[1], open[1])
m1BB1 = min(close[1], open[1])
m1BT2 = max(close[2], open[2])
m1BB2 = min(close[2], open[2])
IF close[2] > open[2] AND close[1] < open[1] THEN
lastResM1 = max(m1BT1, m1BT2)
ENDIF
IF close[2] < open[2] AND close[1] > open[1] THEN
lastSupM1 = min(m1BB1, m1BB2)
ENDIF
IF lastResM1 > 0 AND close > lastResM1 THEN
trendM1 = 1
ELSIF lastSupM1 > 0 AND close < lastSupM1 THEN
trendM1 = -1
ENDIF
//----------------------------------------------------------------------//
// M3
//----------------------------------------------------------------------//
TIMEFRAME(3 minutes)
m3BT1 = max(close[1], open[1])
m3BB1 = min(close[1], open[1])
m3BT2 = max(close[2], open[2])
m3BB2 = min(close[2], open[2])
m3IsRes = close[2] > open[2] AND close[1] < open[1]
m3IsSup = close[2] < open[2] AND close[1] > open[1]
IF m3IsRes THEN
lastResM3 = max(m3BT1, m3BT2)
ENDIF
IF m3IsSup THEN
lastSupM3 = min(m3BB1, m3BB2)
ENDIF
clM3 = close
TIMEFRAME(default)
IF lastResM3 > 0 AND clM3 > lastResM3 THEN
trendM3 = 1
ELSIF lastSupM3 > 0 AND clM3 < lastSupM3 THEN
trendM3 = -1
ENDIF
//----------------------------------------------------------------------//
// M5
//----------------------------------------------------------------------//
TIMEFRAME(5 minutes)
m5BT1 = max(close[1], open[1])
m5BB1 = min(close[1], open[1])
m5BT2 = max(close[2], open[2])
m5BB2 = min(close[2], open[2])
m5IsRes = close[2] > open[2] AND close[1] < open[1]
m5IsSup = close[2] < open[2] AND close[1] > open[1]
IF m5IsRes THEN
lastResM5 = max(m5BT1, m5BT2)
ENDIF
IF m5IsSup THEN
lastSupM5 = min(m5BB1, m5BB2)
ENDIF
clM5 = close
TIMEFRAME(default)
IF lastResM5 > 0 AND clM5 > lastResM5 THEN
trendM5 = 1
ELSIF lastSupM5 > 0 AND clM5 < lastSupM5 THEN
trendM5 = -1
ENDIF
//----------------------------------------------------------------------//
// M15
//----------------------------------------------------------------------//
TIMEFRAME(15 minutes)
m15BT1 = max(close[1], open[1])
m15BB1 = min(close[1], open[1])
m15BT2 = max(close[2], open[2])
m15BB2 = min(close[2], open[2])
m15IsRes = close[2] > open[2] AND close[1] < open[1]
m15IsSup = close[2] < open[2] AND close[1] > open[1]
IF m15IsRes THEN
lastResM15 = max(m15BT1, m15BT2)
ENDIF
IF m15IsSup THEN
lastSupM15 = min(m15BB1, m15BB2)
ENDIF
clM15 = close
TIMEFRAME(default)
IF lastResM15 > 0 AND clM15 > lastResM15 THEN
trendM15 = 1
ELSIF lastSupM15 > 0 AND clM15 < lastSupM15 THEN
trendM15 = -1
ENDIF
//----------------------------------------------------------------------//
// M30
//----------------------------------------------------------------------//
TIMEFRAME(30 minutes)
m30BT1 = max(close[1], open[1])
m30BB1 = min(close[1], open[1])
m30BT2 = max(close[2], open[2])
m30BB2 = min(close[2], open[2])
m30IsRes = close[2] > open[2] AND close[1] < open[1]
m30IsSup = close[2] < open[2] AND close[1] > open[1]
IF m30IsRes THEN
lastResM30 = max(m30BT1, m30BT2)
ENDIF
IF m30IsSup THEN
lastSupM30 = min(m30BB1, m30BB2)
ENDIF
clM30 = close
TIMEFRAME(default)
IF lastResM30 > 0 AND clM30 > lastResM30 THEN
trendM30 = 1
ELSIF lastSupM30 > 0 AND clM30 < lastSupM30 THEN
trendM30 = -1
ENDIF
//----------------------------------------------------------------------//
// H1
//----------------------------------------------------------------------//
TIMEFRAME(1 hour)
h1BT1 = max(close[1], open[1])
h1BB1 = min(close[1], open[1])
h1BT2 = max(close[2], open[2])
h1BB2 = min(close[2], open[2])
h1IsRes = close[2] > open[2] AND close[1] < open[1]
h1IsSup = close[2] < open[2] AND close[1] > open[1]
IF h1IsRes THEN
lastResH1 = max(h1BT1, h1BT2)
ENDIF
IF h1IsSup THEN
lastSupH1 = min(h1BB1, h1BB2)
ENDIF
clH1 = close
TIMEFRAME(default)
IF lastResH1 > 0 AND clH1 > lastResH1 THEN
trendH1 = 1
ELSIF lastSupH1 > 0 AND clH1 < lastSupH1 THEN
trendH1 = -1
ENDIF
//----------------------------------------------------------------------//
// H3
//----------------------------------------------------------------------//
TIMEFRAME(3 hours)
h3BT1 = max(close[1], open[1])
h3BB1 = min(close[1], open[1])
h3BT2 = max(close[2], open[2])
h3BB2 = min(close[2], open[2])
h3IsRes = close[2] > open[2] AND close[1] < open[1]
h3IsSup = close[2] < open[2] AND close[1] > open[1]
IF h3IsRes THEN
lastResH3 = max(h3BT1, h3BT2)
ENDIF
IF h3IsSup THEN
lastSupH3 = min(h3BB1, h3BB2)
ENDIF
clH3 = close
TIMEFRAME(default)
IF lastResH3 > 0 AND clH3 > lastResH3 THEN
trendH3 = 1
ELSIF lastSupH3 > 0 AND clH3 < lastSupH3 THEN
trendH3 = -1
ENDIF
//----------------------------------------------------------------------//
// H4
//----------------------------------------------------------------------//
TIMEFRAME(4 hours)
h4BT1 = max(close[1], open[1])
h4BB1 = min(close[1], open[1])
h4BT2 = max(close[2], open[2])
h4BB2 = min(close[2], open[2])
h4IsRes = close[2] > open[2] AND close[1] < open[1]
h4IsSup = close[2] < open[2] AND close[1] > open[1]
IF h4IsRes THEN
lastResH4 = max(h4BT1, h4BT2)
ENDIF
IF h4IsSup THEN
lastSupH4 = min(h4BB1, h4BB2)
ENDIF
clH4 = close
TIMEFRAME(default)
IF lastResH4 > 0 AND clH4 > lastResH4 THEN
trendH4 = 1
ELSIF lastSupH4 > 0 AND clH4 < lastSupH4 THEN
trendH4 = -1
ENDIF
//----------------------------------------------------------------------//
// D
//----------------------------------------------------------------------//
TIMEFRAME(daily)
dBT1 = max(close[1], open[1])
dBB1 = min(close[1], open[1])
dBT2 = max(close[2], open[2])
dBB2 = min(close[2], open[2])
dIsRes = close[2] > open[2] AND close[1] < open[1]
dIsSup = close[2] < open[2] AND close[1] > open[1]
IF dIsRes THEN
lastResD = max(dBT1, dBT2)
ENDIF
IF dIsSup THEN
lastSupD = min(dBB1, dBB2)
ENDIF
clD = close
TIMEFRAME(default)
IF lastResD > 0 AND clD > lastResD THEN
trendD = 1
ELSIF lastSupD > 0 AND clD < lastSupD THEN
trendD = -1
ENDIF
//----------------------------------------------------------------------//
// ============ DASHBOARD PANEL ============
//----------------------------------------------------------------------//
IF islastbarupdate THEN
// Header
drawtext("TF BIAS", -200, -60) anchor(topright, xshift, yshift) coloured(255, 255, 255)
// ── M1 ──
IF trendM1 = 1 THEN
drawtext("M1 BUY", -200, -80) anchor(topright, xshift, yshift) coloured(0, 230, 118)
ELSIF trendM1 = -1 THEN
drawtext("M1 SELL", -200, -80) anchor(topright, xshift, yshift) coloured(255, 23, 68)
ELSE
drawtext("M1 WAIT", -200, -80) anchor(topright, xshift, yshift) coloured(128, 128, 128)
ENDIF
// ── M3 ──
IF trendM3 = 1 THEN
drawtext("M3 BUY", -200, -95) anchor(topright, xshift, yshift) coloured(0, 230, 118)
ELSIF trendM3 = -1 THEN
drawtext("M3 SELL", -200, -95) anchor(topright, xshift, yshift) coloured(255, 23, 68)
ELSE
drawtext("M3 WAIT", -200, -95) anchor(topright, xshift, yshift) coloured(128, 128, 128)
ENDIF
// ── M5 ──
IF trendM5 = 1 THEN
drawtext("M5 BUY", -200, -110) anchor(topright, xshift, yshift) coloured(0, 230, 118)
ELSIF trendM5 = -1 THEN
drawtext("M5 SELL", -200, -110) anchor(topright, xshift, yshift) coloured(255, 23, 68)
ELSE
drawtext("M5 WAIT", -200, -110) anchor(topright, xshift, yshift) coloured(128, 128, 128)
ENDIF
// ── M15 ──
IF trendM15 = 1 THEN
drawtext("M15 BUY", -200, -125) anchor(topright, xshift, yshift) coloured(0, 230, 118)
ELSIF trendM15 = -1 THEN
drawtext("M15 SELL", -200, -125) anchor(topright, xshift, yshift) coloured(255, 23, 68)
ELSE
drawtext("M15 WAIT", -200, -125) anchor(topright, xshift, yshift) coloured(128, 128, 128)
ENDIF
// ── M30 ──
IF trendM30 = 1 THEN
drawtext("M30 BUY", -200, -140) anchor(topright, xshift, yshift) coloured(0, 230, 118)
ELSIF trendM30 = -1 THEN
drawtext("M30 SELL", -200, -140) anchor(topright, xshift, yshift) coloured(255, 23, 68)
ELSE
drawtext("M30 WAIT", -200, -140) anchor(topright, xshift, yshift) coloured(128, 128, 128)
ENDIF
// ── H1 ──
IF trendH1 = 1 THEN
drawtext("H1 BUY", -200, -155) anchor(topright, xshift, yshift) coloured(0, 230, 118)
ELSIF trendH1 = -1 THEN
drawtext("H1 SELL", -200, -155) anchor(topright, xshift, yshift) coloured(255, 23, 68)
ELSE
drawtext("H1 WAIT", -200, -155) anchor(topright, xshift, yshift) coloured(128, 128, 128)
ENDIF
// ── H3 ──
IF trendH3 = 1 THEN
drawtext("H3 BUY", -200, -170) anchor(topright, xshift, yshift) coloured(0, 230, 118)
ELSIF trendH3 = -1 THEN
drawtext("H3 SELL", -200, -170) anchor(topright, xshift, yshift) coloured(255, 23, 68)
ELSE
drawtext("H3 WAIT", -200, -170) anchor(topright, xshift, yshift) coloured(128, 128, 128)
ENDIF
// ── H4 ──
IF trendH4 = 1 THEN
drawtext("H4 BUY", -200, -185) anchor(topright, xshift, yshift) coloured(0, 230, 118)
ELSIF trendH4 = -1 THEN
drawtext("H4 SELL", -200, -185) anchor(topright, xshift, yshift) coloured(255, 23, 68)
ELSE
drawtext("H4 WAIT", -200, -185) anchor(topright, xshift, yshift) coloured(128, 128, 128)
ENDIF
// ── D ──
IF trendD = 1 THEN
drawtext("D BUY", -200, -200) anchor(topright, xshift, yshift) coloured(0, 230, 118)
ELSIF trendD = -1 THEN
drawtext("D SELL", -200, -200) anchor(topright, xshift, yshift) coloured(255, 23, 68)
ELSE
drawtext("D WAIT", -200, -200) anchor(topright, xshift, yshift) coloured(128, 128, 128)
ENDIF
ENDIF
//----------------------------------------------------------------------//
RETURN
2) LOKI H1 Zones — Apply it on H1 or any lower timeframe. It detects resistance and support zones from H1 engulfing patterns and draws them on the chart. Zones are automatically removed when price breaks through. Up to 8 zones per side.
//----------------------------------------------------------------------//
// PRC_LOKI H1 Zones
// version = 0
// 16.03.2026
// Iván González @ www.prorealcode.com
// Sharing ProRealTime knowledge
//----------------------------------------------------------------------//
defparam drawonlastbaronly = true
//----------------------------------------------------------------------//
// ============ SETTINGS ============
//----------------------------------------------------------------------//
zoneHeightPts = 100
maxSlots = 100
roundStp = 10
//----------------------------------------------------------------------//
// Zone height in price units
zoneHeight = zoneHeightPts * pointsize
//----------------------------------------------------------------------//
// ============ H1 DATA ============
//----------------------------------------------------------------------//
TIMEFRAME(1 hour)
h1C1 = close[1]
h1O1 = open[1]
h1C2 = close[2]
h1O2 = open[2]
TIMEFRAME(default)
//----------------------------------------------------------------------//
// Detect engulfing patterns on H1
//----------------------------------------------------------------------//
// Resistance: bullish[2] + bearish[1]
h1IsRes = h1C2 > h1O2 AND h1C1 < h1O1
// Support: bearish[2] + bullish[1]
h1IsSup = h1C2 < h1O2 AND h1C1 > h1O1
// Body extremes of H1 candles [1] and [2]
bt1 = max(h1C1, h1O1)
bb1 = min(h1C1, h1O1)
bt2 = max(h1C2, h1O2)
bb2 = min(h1C2, h1O2)
h1BodyHigh = max(bt1, bt2)
h1BodyLow = min(bb1, bb2)
//----------------------------------------------------------------------//
// Detect new H1 bar completion
//----------------------------------------------------------------------//
IF h1C1 <> h1C1[1] THEN
newH1 = 1
ELSE
newH1 = 0
ENDIF
// Rounded zone base levels
resRound = CEIL(h1BodyHigh / roundStp, 0) * roundStp
supRound = FLOOR(h1BodyLow / roundStp, 0) * roundStp
//----------------------------------------------------------------------//
// ============ ZONE STORAGE ============
//----------------------------------------------------------------------//
// $resBase[i] = base level (bottom edge of res zone)
// $resValid[i] = 1 if zone active, 0 if broken
// $resBar[i] = bar where zone was created
// Same for $supBase, $supValid, $supBar
// Circular buffer pointers
once resPtr = 0
once supPtr = 0
// Initialize arrays on first bar
IF barindex = 0 THEN
FOR i = 0 TO maxSlots - 1 DO
$resBase[i] = 0
$resValid[i] = 0
$resBar[i] = 0
$supBase[i] = 0
$supValid[i] = 0
$supBar[i] = 0
NEXT
ENDIF
//----------------------------------------------------------------------//
// ============ ADD NEW ZONES ============
//----------------------------------------------------------------------//
IF newH1 = 1 THEN
// New resistance zone
IF h1IsRes AND h1BodyHigh > 0 THEN
$resBase[resPtr] = resRound
$resValid[resPtr] = 1
$resBar[resPtr] = barindex
resPtr = (resPtr + 1) MOD maxSlots
ENDIF
// New support zone
IF h1IsSup AND h1BodyLow > 0 THEN
$supBase[supPtr] = supRound
$supValid[supPtr] = 1
$supBar[supPtr] = barindex
supPtr = (supPtr + 1) MOD maxSlots
ENDIF
ENDIF
//----------------------------------------------------------------------//
// ============ INVALIDATE BROKEN ZONES ============
//----------------------------------------------------------------------//
FOR i = 0 TO maxSlots - 1 DO
// Resistance broken: close pierces above base level
IF $resValid[i] = 1 AND close > $resBase[i] THEN
$resValid[i] = 0
ENDIF
// Support broken: close pierces below base level
IF $supValid[i] = 1 AND close < $supBase[i] THEN
$supValid[i] = 0
ENDIF
NEXT
//----------------------------------------------------------------------//
// === COUNT ACTIVE ZONES (for info) ===
//----------------------------------------------------------------------//
resCount = 0
supCount = 0
FOR i = 0 TO maxSlots - 1 DO
IF $resValid[i] = 1 THEN
resCount = resCount + 1
ENDIF
IF $supValid[i] = 1 THEN
supCount = supCount + 1
ENDIF
NEXT
//----------------------------------------------------------------------//
// ============ DRAW ZONES ============
//----------------------------------------------------------------------//
IF islastbarupdate THEN
FOR i = 0 TO maxSlots - 1 DO
// Draw valid resistance zones (red)
IF $resValid[i] = 1 THEN
resTop = $resBase[i] + zoneHeight
drawrectangle($resBar[i], resTop, barindex + 3, $resBase[i]) coloured("red") fillcolor("red", 90)
drawtext("H1 RES", $resBar[i], resTop) coloured(255, 255, 255)
ENDIF
// Draw valid support zones (green)
IF $supValid[i] = 1 THEN
supBot = $supBase[i] - zoneHeight
drawrectangle($supBar[i], $supBase[i], barindex + 3, supBot) coloured("green") fillcolor("green", 90)
drawtext("H1 SUP", $supBar[i], supBot) coloured(255, 255, 255)
ENDIF
NEXT
// Info panel
drawtext("RES: #resCount# | SUP: #supCount#", -150, -20) anchor(topright, xshift, yshift)
ENDIF
//----------------------------------------------------------------------//
RETURN
Both indicators can run together or speratly
This topic contains 1 reply,
has 2 voices, and was last updated by
Iván González
10 hours, 14 minutes ago.
| Forum: | TradingView to ProRealTime Translation Center Forum |
| Started: | 03/16/2026 |
| Status: | Active |
| Attachments: | No files |
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.