Iván González

Timeframe Master

Category: Indicators By: Iván González Created: November 27, 2026, 10:59 AM
November 27, 2026, 10:59 AM
Indicators
0 Comments
Timeframe Master

Introduction

 

Most traders look at two timeframes: the one they trade and the one above it. Switching charts to see the bigger candle breaks the flow, and a plain higher-timeframe box only tells you its open, high, low and close.

Timeframe Master draws the bigger candle right behind the chart: the hourly candle behind a 5-minute chart, the daily candle behind an hourly chart, the monthly candle behind a daily chart. Each bigger candle is drawn as a “lantern”: it is cut into rows from its low to its high, and each row glows according to how many of the chart’s bars traded there. The brightest rows are where price spent its time, and the busiest one, the core, is marked with a line.

Theory Behind the Indicator

 

Built from the chart’s own bars. The bigger candle is not requested from another timeframe. Its open is the open of its first bar, its close the close of its last bar, its high and low the extremes in between. Nothing looks ahead.

Choosing the bigger timeframe. In Auto mode the indicator picks the smallest of the usual timeframes (15 seconds, 1, 5, 15 and 30 minutes, 1, 2 and 4 hours, day, week, month, quarter, year) that holds at least ten of the chart’s bars and, inside the day, a whole number of them. A manual choice that holds fewer than four bars, not a whole number of them, or more than 1,500, falls back to Auto.

Where a bigger candle starts. Inside the day, blocks are counted from the first bar of the trading session. Daily candles follow the platform’s daily candle (the session, not the calendar date). Weeks, months, quarters and years start on the first session in which they change.

The lantern. Each bigger candle is cut into 8 to 18 rows, more when more bars went into it. For each row the indicator counts how many of the candle’s bars touched that price. The busiest row gets full brightness and the others are scaled down on a curve (power 1.6) into 16 steps of glow. Through the body the rows run the full width of the candle; through the wicks they are a narrow column down its middle. The core is the middle of the busiest row.

The candle still forming. It is drawn the same way, with its rows sized for the candle it is growing into so they do not jump, inside a dashed frame that reaches the bar where it is due to close.

Key Features at a Glance

 

  • The candle of the timeframe above drawn behind the chart, with no request to another timeframe.
  • Auto mode that picks a sensible bigger timeframe for any chart, from seconds to monthly.
  • Lantern rows that glow by time spent at each price, and a core line on the busiest row.
  • The live bigger candle with a dashed frame out to its expected close.
  • A quiet look (plain body lit at its close) for a cleaner chart.
  • Four colour themes, adjustable brightness.
  • A panel with the move of the current bigger candle, the time it has left, where price sits inside its range, its core and how the last one closed.

How to Read the Indicator

 

  • Bright rows: prices where most of the bigger candle’s bars traded. Dim rows were crossed quickly.
  • Core line: the busiest price of that candle. It is a record of the candle, not a level to trade from on its own.
  • Body outline and close line: the body runs from open to close; the brighter edge is the close.
  • Dashed frame: the part of the current bigger candle that has not happened yet.
  • Panel: “Up 0.75%” is the move from the bigger candle’s open to the current close; “Price is above its open, in the top third of its range” places the last price inside the bigger candle.

Practical Applications

 

  • Context for intraday trading: see at a glance whether the current hour or day is up or down, how far price is from its open and where most of the trading happened.
  • Reading acceptance: a close of the bigger candle far from its core means price moved away from where it spent its time; a close near the core is a balanced candle.
  • Multi-timeframe discipline: keep the trade direction of the small chart in line with the bigger candle without switching charts.

Indicator Configuration

 

  • tfIn (default 0): bigger timeframe. 0 Auto, 1 5 minutes, 2 15 minutes, 3 30 minutes, 4 1 hour, 5 2 hours, 6 4 hours, 7 day, 8 week, 9 month.
  • keepIn (default 120): how many bigger candles are drawn, counting the one still forming (4 to 120).
  • lanternIn (default 1): 1 = rows glow by time spent at each price; 0 = quiet look.
  • coreIn (default 1): 1 = core line on the busiest row (needs the lantern).
  • coreR / coreG / coreB (default 255, 209, 102): colour of the core line.
  • themeIn (default 0): 0 Mint and Pink, 1 Ice, 2 Neon, 3 Custom.
  • custUpR/G/B and custDnR/G/B: colours of the Custom theme.
  • brightIn (default 3): brightness from 1 to 5.
  • showPanel (default 1): 1 = panel in the bottom left corner.

The Code

 

//---------------------------------------------------------------
// PRC_Timeframe Master
// version = 0
// 27.11.2026
// Iván González @ www.prorealcode.com
// Author: SimpleAlgoAI
// Sharing ProRealTime knowledge
//--------------------------------------------------------------------//
// The candle one timeframe up, drawn behind the chart and built from the
// chart's own bars: open of the first bar, close of the last one, high and
// low in between. Each bigger candle is a "lantern": it is cut into rows
// from its low to its high and every row glows by how many of the bars
// inside it traded there. The busiest row is the core, marked with a line.
// The candle still forming is drawn inside a dashed frame out to where it
// is due to close.
//--------------------------------------------------------------------//
defparam drawonlastbaronly = true

// ---------------- parameters ----------------
tfIn = 0          // bigger timeframe: 0 Auto, 1 5 min, 2 15 min, 3 30 min, 4 1 hour, 5 2 hours, 6 4 hours, 7 day, 8 week, 9 month
keepIn = 120      // bigger candles drawn, counting the one still forming (4 to 120)
lanternIn = 1     // 1 = rows glow by time spent there; 0 = quiet look (plain body lit at its close)
coreIn = 1        // 1 = core line (needs the lantern)
coreR = 255       // core line colour
coreG = 209
coreB = 102
themeIn = 0       // 0 Mint and Pink, 1 Ice, 2 Neon, 3 Custom
custUpR = 0       // custom colours (theme 3)
custUpG = 255
custUpB = 163
custDnR = 255
custDnG = 61
custDnB = 113
brightIn = 3      // brightness 1 to 5
showPanel = 1     // 1 = panel at the bottom left

// ---------------- constants (first bar only) ----------------
ONCE glowSteps = 16
ONCE maxRows = 18
IF barindex = 0 THEN
   IF themeIn = 1 THEN
      upR = 125
      upG = 211
      upB = 252
      dnR = 110
      dnG = 120
      dnB = 135
   ELSIF themeIn = 2 THEN
      upR = 60
      upG = 60
      upB = 60
      dnR = 217
      dnG = 70
      dnB = 239
   ELSIF themeIn = 3 THEN
      upR = custUpR
      upG = custUpG
      upB = custUpB
      dnR = custDnR
      dnG = custDnG
      dnB = custDnB
   ELSE
      upR = 0
      upG = 255
      upB = 163
      dnR = 255
      dnG = 61
      dnB = 113
   ENDIF
   bright = 0.5 + 0.25 * (max(1, min(5, brightIn)) - 1)
   keepC = max(4, min(120, keepIn))

   // the bigger timeframe, in seconds, and its kind:
   // 0 inside a day, 1 day, 2 week, 3 month, 4 quarter, 5 year
   tfSec = GetTimeFrame
   secM = 2628000
   IF 15 >= tfSec * 10 THEN
      autoSec = 15
   ELSIF 60 >= tfSec * 10 AND (60 MOD tfSec) = 0 THEN
      autoSec = 60
   ELSIF 300 >= tfSec * 10 AND (300 MOD tfSec) = 0 THEN
      autoSec = 300
   ELSIF 900 >= tfSec * 10 AND (900 MOD tfSec) = 0 THEN
      autoSec = 900
   ELSIF 1800 >= tfSec * 10 AND (1800 MOD tfSec) = 0 THEN
      autoSec = 1800
   ELSIF 3600 >= tfSec * 10 AND (3600 MOD tfSec) = 0 THEN
      autoSec = 3600
   ELSIF 7200 >= tfSec * 10 AND (7200 MOD tfSec) = 0 THEN
      autoSec = 7200
   ELSIF 14400 >= tfSec * 10 AND (14400 MOD tfSec) = 0 THEN
      autoSec = 14400
   ELSIF 86400 >= tfSec * 10 THEN
      autoSec = 86400
   ELSIF 604800 >= tfSec * 10 THEN
      autoSec = 604800
   ELSIF secM >= tfSec * 10 THEN
      autoSec = secM
   ELSIF secM * 3 >= tfSec * 10 THEN
      autoSec = secM * 3
   ELSE
      autoSec = secM * 12
   ENDIF
   pickSec = autoSec
   IF tfIn = 1 THEN
      pickSec = 300
   ELSIF tfIn = 2 THEN
      pickSec = 900
   ELSIF tfIn = 3 THEN
      pickSec = 1800
   ELSIF tfIn = 4 THEN
      pickSec = 3600
   ELSIF tfIn = 5 THEN
      pickSec = 7200
   ELSIF tfIn = 6 THEN
      pickSec = 14400
   ELSIF tfIn = 7 THEN
      pickSec = 86400
   ELSIF tfIn = 8 THEN
      pickSec = 604800
   ELSIF tfIn = 9 THEN
      pickSec = secM
   ENDIF
   // a choice has to hold at least four chart bars, a whole number of them inside a day, and not far too many
   pickOk = 0
   IF pickSec >= tfSec * 4 AND pickSec <= tfSec * 1500 THEN
      IF pickSec >= 86400 THEN
         pickOk = 1
      ELSIF (pickSec MOD tfSec) = 0 THEN
         pickOk = 1
      ENDIF
   ENDIF
   IF pickOk = 1 THEN
      bigSec = pickSec
   ELSE
      bigSec = autoSec
   ENDIF
   IF bigSec < 86400 THEN
      bigKind = 0
   ELSIF bigSec < 604800 THEN
      bigKind = 1
   ELSIF bigSec < secM THEN
      bigKind = 2
   ELSIF bigSec < secM * 3 THEN
      bigKind = 3
   ELSIF bigSec < secM * 12 THEN
      bigKind = 4
   ELSE
      bigKind = 5
   ENDIF
ENDIF

// ---------------- start of a new bigger candle ----------------
// A new trading day is the platform's daily candle changing (the session,
// not the calendar date, which on futures changes in the middle of it).
// Blocks inside a day are counted from the first bar of the session.
secNow = floor(opentime / 10000) * 3600 + (floor(opentime / 100) - floor(opentime / 10000) * 100) * 60 + (opentime - floor(opentime / 100) * 100)
IF tfSec >= 86400 THEN
   newDay = 1
ELSE
   pdOpen = DOpen(1)
   pdClose = DClose(1)
   newDay = (pdOpen <> pdOpen[1] OR pdClose <> pdClose[1])
ENDIF

newBig = 0
IF barindex > 0 THEN
   IF newDay THEN
      IF bigKind <= 1 THEN
         newBig = 1
      ELSIF bigKind = 2 THEN
         IF OpenDayOfWeek < lastDow THEN
            newBig = 1
         ENDIF
      ELSIF bigKind = 3 THEN
         IF OpenMonth <> lastMon OR OpenYear <> lastYr THEN
            newBig = 1
         ENDIF
      ELSIF bigKind = 4 THEN
         IF floor((OpenMonth - 1) / 3) <> floor((lastMon - 1) / 3) OR OpenYear <> lastYr THEN
            newBig = 1
         ENDIF
      ELSE
         IF OpenYear <> lastYr THEN
            newBig = 1
         ENDIF
      ENDIF
   ELSIF bigKind = 0 THEN
      elap = secNow - sessStart
      IF elap < 0 THEN
         elap = elap + 86400
      ENDIF
      elapP = secNow[1] - sessStart
      IF elapP < 0 THEN
         elapP = elapP + 86400
      ENDIF
      IF floor(elap / bigSec) <> floor(elapP / bigSec) THEN
         newBig = 1
      ENDIF
   ENDIF
ENDIF
IF newDay OR barindex = 0 THEN
   sessStart = secNow
   lastDow = OpenDayOfWeek
   lastMon = OpenMonth
   lastYr = OpenYear
ENDIF

// ---------------- the bigger candle, bar by bar ----------------
// Finished candles go to arrays indexed by nC (plain assignments, so
// repeating them on every tick of the bar is harmless). The first candle
// of the history is skipped: it may have started before the chart did.
ONCE started = 0
ONCE nC = 0
IF newBig = 1 THEN
   IF started = 1 THEN
      nB = barindex - bigStart
      $cX0[nC] = bigStart
      $cX1[nC] = barindex - 1
      $cO[nC] = bigO
      $cH[nC] = bigH
      $cL[nC] = bigL
      $cC[nC] = close[1]
      nRw = max(8, min(maxRows, floor(nB * 0.6) + 3))
      $cRows[nC] = nRw
      // how many of the candle's bars touched each row, and each row's step of glow
      stepY = (bigH - bigL) / nRw
      base = nC * maxRows
      FOR r = 0 TO nRw - 1 DO
         $cnt[r] = 0
      NEXT
      IF stepY > 0 THEN
         FOR j = 1 TO nB DO
            ra = max(0, min(nRw - 1, floor((low[j] - bigL) / stepY + 0.000000001)))
            rb = max(0, min(nRw - 1, ceil((high[j] - bigL) / stepY - 0.000000001) - 1))
            IF rb >= ra THEN
               FOR r = ra TO rb DO
                  $cnt[r] = $cnt[r] + 1
               NEXT
            ENDIF
         NEXT
      ENDIF
      topCnt = 1
      rc = 0
      FOR r = 0 TO nRw - 1 DO
         IF $cnt[r] > topCnt THEN
            topCnt = $cnt[r]
         ENDIF
      NEXT
      bestCnt = -1
      FOR r = 0 TO nRw - 1 DO
         $cq[base + r] = round(pow($cnt[r] / topCnt, 1.6) * (glowSteps - 1))
         IF $cnt[r] > bestCnt THEN
            bestCnt = $cnt[r]
            rc = r
         ENDIF
      NEXT
      $cCore[nC] = bigL + (rc + 0.5) * stepY
      nC = nC + 1
      prevO = bigO
      prevH = bigH
      prevL = bigL
      prevC = close[1]
      prevBars = nB
   ENDIF
   started = 1
   bigO = open
   bigH = high
   bigL = low
   bigStart = barindex
ELSIF started = 1 THEN
   bigH = max(bigH, high)
   bigL = min(bigL, low)
ENDIF

// ---------------- drawing, on the last bar ----------------
IF islastbarupdate AND started = 1 THEN
   // the candle still forming takes slot nC of the arrays
   nNow = barindex - bigStart + 1
   elapB = secNow - sessStart
   IF elapB < 0 THEN
      elapB = elapB + 86400
   ENDIF
   barsLeft = 0
   IF bigKind = 0 THEN
      toEnd = (floor(elapB / bigSec) + 1) * bigSec - (elapB + tfSec)
      IF toEnd > 0 THEN
         barsLeft = ceil(toEnd / tfSec)
      ENDIF
   ELSIF prevBars > 0 THEN
      barsLeft = max(prevBars - nNow, 0)
   ENDIF
   $cX0[nC] = bigStart
   $cX1[nC] = barindex
   $cO[nC] = bigO
   $cH[nC] = bigH
   $cL[nC] = bigL
   $cC[nC] = close
   // rows are counted for the size it is growing into, so they do not jump as its bars arrive
   nRw = max(8, min(maxRows, floor(max(nNow, prevBars) * 0.6) + 3))
   $cRows[nC] = nRw
   stepY = (bigH - bigL) / nRw
   base = nC * maxRows
   FOR r = 0 TO nRw - 1 DO
      $cnt[r] = 0
   NEXT
   IF stepY > 0 THEN
      FOR j = 0 TO nNow - 1 DO
         ra = max(0, min(nRw - 1, floor((low[j] - bigL) / stepY + 0.000000001)))
         rb = max(0, min(nRw - 1, ceil((high[j] - bigL) / stepY - 0.000000001) - 1))
         IF rb >= ra THEN
            FOR r = ra TO rb DO
               $cnt[r] = $cnt[r] + 1
            NEXT
         ENDIF
      NEXT
   ENDIF
   topCnt = 1
   FOR r = 0 TO nRw - 1 DO
      IF $cnt[r] > topCnt THEN
         topCnt = $cnt[r]
      ENDIF
   NEXT
   bestCnt = -1
   rc = 0
   FOR r = 0 TO nRw - 1 DO
      $cq[base + r] = round(pow($cnt[r] / topCnt, 1.6) * (glowSteps - 1))
      IF $cnt[r] > bestCnt THEN
         bestCnt = $cnt[r]
         rc = r
      ENDIF
   NEXT
   coreNow = bigL + (rc + 0.5) * stepY
   coreOk = (lanternIn = 1 AND stepY > 0)
   $cCore[nC] = coreNow
   liveEnd = barindex + min(barsLeft, 400)

   firstK = max(0, nC - (keepC - 1))
   FOR k = firstK TO nC DO
      isLive = (k = nC)
      po = $cO[k]
      ph = $cH[k]
      pl = $cL[k]
      pc = $cC[k]
      x0 = $cX0[k]
      x1 = $cX1[k]
      IF isLive THEN
         xEnd = liveEnd
         gain = bright * 1.12
      ELSE
         xEnd = x1
         gain = bright
      ENDIF
      nRw = $cRows[k]
      base = k * maxRows
      IF pc >= po THEN
         cR = upR
         cG = upG
         cB = upB
      ELSE
         cR = dnR
         cG = dnG
         cB = dnB
      ENDIF
      blo = min(po, pc)
      bhi = max(po, pc)
      xm = floor((x0 + xEnd) / 2)
      stepY = (ph - pl) / nRw

      IF lanternIn = 1 THEN
         // the wick column: a narrow strip down the middle, lit only where bars have printed
         ww = max(1, round((xEnd - x0) * 0.22))
         xw0 = max(x0, xm - floor(ww / 2))
         xwF = xw0 + ww
         xw1 = min(xwF, x1)
         IF stepY > 0 THEN
            // three stretches drawn row by row: the body at full width, then the two wicks in the narrow column.
            // Neighbouring rows with the same glow are drawn as one rectangle
            FOR sg = 0 TO 2 DO
               IF sg = 0 THEN
                  ya = blo
                  yb = bhi
                  xa = x0
                  xb = x1
               ELSIF sg = 1 THEN
                  ya = pl
                  yb = blo
                  xa = xw0
                  xb = xw1
               ELSE
                  ya = bhi
                  yb = ph
                  xa = xw0
                  xb = xw1
               ENDIF
               IF yb > ya AND xb > xa THEN
                  ra = max(0, min(nRw - 1, floor((ya - pl) / stepY + 0.000000001)))
                  rb = max(ra, min(nRw - 1, ceil((yb - pl) / stepY - 0.000000001) - 1))
                  y0 = ya
                  FOR r = ra TO rb DO
                     qv = $cq[base + r]
                     ends = (r = rb)
                     IF NOT ends THEN
                        ends = ($cq[base + r + 1] <> qv)
                     ENDIF
                     IF ends THEN
                        IF r = rb THEN
                           y1 = yb
                        ELSE
                           y1 = pl + (r + 1) * stepY
                        ENDIF
                        IF y1 > y0 THEN
                           trV = round(100 - min(100 * gain * (0.035 + 0.515 * qv / (glowSteps - 1)), 80))
                           aV = round((100 - trV) * 2.55)
                           DRAWRECTANGLE(xa, y1, xb, y0) COLOURED(cR, cG, cB, 0) FILLCOLOR(cR, cG, cB, aV)
                        ENDIF
                        y0 = y1
                     ENDIF
                  NEXT
               ENDIF
            NEXT

            // the edges of the wicks; on the candle still forming they reach their full width, dashed until its bars get there
            IF isLive THEN
               xwE = xwF
            ELSE
               xwE = xw1
            ENDIF
            ghost = (isLive AND xwF > x1)
            IF xwE > xw0 THEN
               IF ghost THEN
                  IF blo > pl THEN
                     DRAWSEGMENT(xw0, pl, xw0, blo) COLOURED(cR, cG, cB, 140) STYLE(dottedline2, 1)
                     DRAWSEGMENT(xw0, pl, xwE, pl) COLOURED(cR, cG, cB, 140) STYLE(dottedline2, 1)
                     DRAWSEGMENT(xwE, pl, xwE, blo) COLOURED(cR, cG, cB, 140) STYLE(dottedline2, 1)
                  ENDIF
                  IF ph > bhi THEN
                     DRAWSEGMENT(xw0, bhi, xw0, ph) COLOURED(cR, cG, cB, 140) STYLE(dottedline2, 1)
                     DRAWSEGMENT(xw0, ph, xwE, ph) COLOURED(cR, cG, cB, 140) STYLE(dottedline2, 1)
                     DRAWSEGMENT(xwE, bhi, xwE, ph) COLOURED(cR, cG, cB, 140) STYLE(dottedline2, 1)
                  ENDIF
               ELSE
                  IF blo > pl THEN
                     DRAWRECTANGLE(xw0, blo, xwE, pl) COLOURED(cR, cG, cB, 115)
                  ENDIF
                  IF ph > bhi THEN
                     DRAWRECTANGLE(xw0, ph, xwE, bhi) COLOURED(cR, cG, cB, 115)
                  ENDIF
               ENDIF
            ENDIF

            // the core: the row that saw the most bars
            IF coreIn = 1 THEN
               coreY = $cCore[k]
               IF coreY >= blo AND coreY <= bhi THEN
                  xca = x0
                  xcb = x1
               ELSE
                  xca = xw0
                  xcb = xw1
               ENDIF
               IF xcb > xca THEN
                  DRAWSEGMENT(xca, coreY, xcb, coreY) COLOURED(coreR, coreG, coreB, 41) STYLE(line, 5)
                  DRAWSEGMENT(xca, coreY, xcb, coreY) COLOURED(coreR, coreG, coreB, 242) STYLE(line, 2)
               ENDIF
            ENDIF
         ENDIF
      ELSE
         // the quiet look: a thin wick down the middle and a body lit at its close, fading back to its open
         DRAWSEGMENT(xm, pl, xm, ph) COLOURED(cR, cG, cB, 107) STYLE(line, 2)
         IF x1 > x0 AND pc <> po THEN
            FOR j = 0 TO 7 DO
               ya = po + (pc - po) * j / 8
               yb = po + (pc - po) * (j + 1) / 8
               qv = round((0.025 + 0.26 * pow((j + 0.5) / 8, 1.3)) / 0.515 * (glowSteps - 1))
               trV = round(100 - min(100 * gain * (0.035 + 0.515 * qv / (glowSteps - 1)), 80))
               aV = round((100 - trV) * 2.55)
               DRAWRECTANGLE(x0, max(ya, yb), x1, min(ya, yb)) COLOURED(cR, cG, cB, 0) FILLCOLOR(cR, cG, cB, aV)
            NEXT
         ENDIF
      ENDIF

      // the body's outline, with the close as its brightest edge
      IF x1 > x0 THEN
         IF bhi > blo THEN
            DRAWRECTANGLE(x0, bhi, x1, blo) COLOURED(cR, cG, cB, 153)
         ENDIF
         DRAWSEGMENT(x0, pc, x1, pc) COLOURED(cR, cG, cB, 41) STYLE(line, 5)
         DRAWSEGMENT(x0, pc, x1, pc) COLOURED(cR, cG, cB, 242) STYLE(line, 2)
      ENDIF
      // the part of the candle that has not happened yet: an empty frame out to where it is due to close
      IF isLive AND xEnd > x1 THEN
         IF bhi > blo THEN
            DRAWRECTANGLE(x1, bhi, xEnd, blo) COLOURED(cR, cG, cB, 0) FILLCOLOR(cR, cG, cB, 13)
         ENDIF
         DRAWSEGMENT(x1, pc, xEnd, pc) COLOURED(cR, cG, cB, 140) STYLE(dottedline2, 1)
         DRAWSEGMENT(x1, po, xEnd, po) COLOURED(cR, cG, cB, 140) STYLE(dottedline2, 1)
         DRAWSEGMENT(xEnd, blo, xEnd, bhi) COLOURED(cR, cG, cB, 140) STYLE(dottedline2, 1)
      ENDIF
   NEXT

   // ---------------- panel ----------------
   IF showPanel = 1 THEN
      // time left in the bigger candle (inside a day only), from the platform clock
      minsLeft = 0
      IF bigKind = 0 THEN
         curS = floor(currenttime / 10000) * 3600 + (floor(currenttime / 100) - floor(currenttime / 10000) * 100) * 60 + (currenttime - floor(currenttime / 100) * 100)
         elapC = curS - sessStart
         IF elapC < 0 THEN
            elapC = elapC + 86400
         ENDIF
         secLeft = (floor(elapB / bigSec) + 1) * bigSec - elapC
         IF secLeft > 0 AND secLeft <= bigSec THEN
            minsLeft = floor(secLeft / 60)
         ENDIF
      ENDIF
      movePct = 0
      IF bigO > 0 THEN
         movePct = round(abs(close / bigO - 1) * 10000) / 100
      ENDIF
      IF bigH > bigL THEN
         pos = (close - bigL) / (bigH - bigL)
      ELSE
         pos = 0.5
      ENDIF
      coreTxt = round(coreNow / pipsize) * pipsize

      nRowP = 4
      IF minsLeft >= 1 THEN
         nRowP = nRowP + 1
      ENDIF
      IF coreOk THEN
         nRowP = nRowP + 1
      ENDIF
      IF prevBars > 0 THEN
         nRowP = nRowP + 1
      ENDIF
      rowH = 18
      xLab = 75
      xVal = 270
      yTop = 45 + (nRowP - 1) * rowH
      DRAWRECTANGLE(5, yTop + 11, 395, 1) ANCHOR(BOTTOMLEFT, XSHIFT, YSHIFT) COLOURED(38, 43, 56, 0) FILLCOLOR(38, 43, 56, 217)

      // row: title and the bigger timeframe
      yR = yTop
      DRAWTEXT("TIMEFRAME MASTER", xLab, yR, SansSerif, Bold, 10) ANCHOR(BOTTOMLEFT, XSHIFT, YSHIFT) COLOURED(190, 195, 205, 255)
      IF bigSec = 15 THEN
         DRAWTEXT("15s candles", xVal, yR, SansSerif, Standard, 10) ANCHOR(BOTTOMLEFT, XSHIFT, YSHIFT) COLOURED(190, 195, 205, 153)
      ELSIF bigSec = 60 THEN
         DRAWTEXT("1m candles", xVal, yR, SansSerif, Standard, 10) ANCHOR(BOTTOMLEFT, XSHIFT, YSHIFT) COLOURED(190, 195, 205, 153)
      ELSIF bigSec = 300 THEN
         DRAWTEXT("5m candles", xVal, yR, SansSerif, Standard, 10) ANCHOR(BOTTOMLEFT, XSHIFT, YSHIFT) COLOURED(190, 195, 205, 153)
      ELSIF bigSec = 900 THEN
         DRAWTEXT("15m candles", xVal, yR, SansSerif, Standard, 10) ANCHOR(BOTTOMLEFT, XSHIFT, YSHIFT) COLOURED(190, 195, 205, 153)
      ELSIF bigSec = 1800 THEN
         DRAWTEXT("30m candles", xVal, yR, SansSerif, Standard, 10) ANCHOR(BOTTOMLEFT, XSHIFT, YSHIFT) COLOURED(190, 195, 205, 153)
      ELSIF bigSec = 3600 THEN
         DRAWTEXT("1h candles", xVal, yR, SansSerif, Standard, 10) ANCHOR(BOTTOMLEFT, XSHIFT, YSHIFT) COLOURED(190, 195, 205, 153)
      ELSIF bigSec = 7200 THEN
         DRAWTEXT("2h candles", xVal, yR, SansSerif, Standard, 10) ANCHOR(BOTTOMLEFT, XSHIFT, YSHIFT) COLOURED(190, 195, 205, 153)
      ELSIF bigSec = 14400 THEN
         DRAWTEXT("4h candles", xVal, yR, SansSerif, Standard, 10) ANCHOR(BOTTOMLEFT, XSHIFT, YSHIFT) COLOURED(190, 195, 205, 153)
      ELSIF bigKind = 1 THEN
         DRAWTEXT("daily candles", xVal, yR, SansSerif, Standard, 10) ANCHOR(BOTTOMLEFT, XSHIFT, YSHIFT) COLOURED(190, 195, 205, 153)
      ELSIF bigKind = 2 THEN
         DRAWTEXT("weekly candles", xVal, yR, SansSerif, Standard, 10) ANCHOR(BOTTOMLEFT, XSHIFT, YSHIFT) COLOURED(190, 195, 205, 153)
      ELSIF bigKind = 3 THEN
         DRAWTEXT("monthly candles", xVal, yR, SansSerif, Standard, 10) ANCHOR(BOTTOMLEFT, XSHIFT, YSHIFT) COLOURED(190, 195, 205, 153)
      ELSIF bigKind = 4 THEN
         DRAWTEXT("quarterly candles", xVal, yR, SansSerif, Standard, 10) ANCHOR(BOTTOMLEFT, XSHIFT, YSHIFT) COLOURED(190, 195, 205, 153)
      ELSE
         DRAWTEXT("yearly candles", xVal, yR, SansSerif, Standard, 10) ANCHOR(BOTTOMLEFT, XSHIFT, YSHIFT) COLOURED(190, 195, 205, 153)
      ENDIF

      // row: the chart's own timeframe
      yR = yR - rowH
      tfMinTxt = round(tfSec / 60)
      tfHrTxt = round(tfSec / 3600)
      tfDayTxt = round(tfSec / 86400)
      tfWkTxt = round(tfSec / 604800)
      IF tfSec < 60 THEN
         DRAWTEXT("behind a #tfSec#s chart", xVal, yR, SansSerif, Standard, 10) ANCHOR(BOTTOMLEFT, XSHIFT, YSHIFT) COLOURED(190, 195, 205, 153)
      ELSIF tfSec < 86400 AND tfSec >= 3600 AND (tfSec MOD 3600) = 0 THEN
         DRAWTEXT("behind a #tfHrTxt#h chart", xVal, yR, SansSerif, Standard, 10) ANCHOR(BOTTOMLEFT, XSHIFT, YSHIFT) COLOURED(190, 195, 205, 153)
      ELSIF tfSec < 86400 THEN
         DRAWTEXT("behind a #tfMinTxt#m chart", xVal, yR, SansSerif, Standard, 10) ANCHOR(BOTTOMLEFT, XSHIFT, YSHIFT) COLOURED(190, 195, 205, 153)
      ELSIF tfSec = 86400 THEN
         DRAWTEXT("behind a daily chart", xVal, yR, SansSerif, Standard, 10) ANCHOR(BOTTOMLEFT, XSHIFT, YSHIFT) COLOURED(190, 195, 205, 153)
      ELSIF tfSec < 604800 THEN
         DRAWTEXT("behind a #tfDayTxt# day chart", xVal, yR, SansSerif, Standard, 10) ANCHOR(BOTTOMLEFT, XSHIFT, YSHIFT) COLOURED(190, 195, 205, 153)
      ELSIF tfSec = 604800 THEN
         DRAWTEXT("behind a weekly chart", xVal, yR, SansSerif, Standard, 10) ANCHOR(BOTTOMLEFT, XSHIFT, YSHIFT) COLOURED(190, 195, 205, 153)
      ELSIF tfSec < 2419200 THEN
         DRAWTEXT("behind a #tfWkTxt# week chart", xVal, yR, SansSerif, Standard, 10) ANCHOR(BOTTOMLEFT, XSHIFT, YSHIFT) COLOURED(190, 195, 205, 153)
      ELSE
         DRAWTEXT("behind a monthly chart", xVal, yR, SansSerif, Standard, 10) ANCHOR(BOTTOMLEFT, XSHIFT, YSHIFT) COLOURED(190, 195, 205, 153)
      ENDIF

      // row: this bigger candle
      yR = yR - rowH
      DRAWTEXT("This candle", xLab, yR, SansSerif, Standard, 10) ANCHOR(BOTTOMLEFT, XSHIFT, YSHIFT) COLOURED(190, 195, 205, 153)
      IF close >= bigO THEN
         DRAWTEXT("Up #movePct#%", xVal, yR, SansSerif, Bold, 10) ANCHOR(BOTTOMLEFT, XSHIFT, YSHIFT) COLOURED(upR, upG, upB, 255)
      ELSE
         DRAWTEXT("Down #movePct#%", xVal, yR, SansSerif, Bold, 10) ANCHOR(BOTTOMLEFT, XSHIFT, YSHIFT) COLOURED(dnR, dnG, dnB, 255)
      ENDIF

      // row: time left, when the market is open
      IF minsLeft >= 1 THEN
         yR = yR - rowH
         hhL = floor(minsLeft / 60)
         mmL = minsLeft - hhL * 60
         DRAWTEXT("Time left", xLab, yR, SansSerif, Standard, 10) ANCHOR(BOTTOMLEFT, XSHIFT, YSHIFT) COLOURED(190, 195, 205, 153)
         IF minsLeft >= 60 AND mmL < 10 THEN
            DRAWTEXT("#hhL#h 0#mmL#m left", xVal, yR, SansSerif, Standard, 10) ANCHOR(BOTTOMLEFT, XSHIFT, YSHIFT) COLOURED(190, 195, 205, 255)
         ELSIF minsLeft >= 60 THEN
            DRAWTEXT("#hhL#h #mmL#m left", xVal, yR, SansSerif, Standard, 10) ANCHOR(BOTTOMLEFT, XSHIFT, YSHIFT) COLOURED(190, 195, 205, 255)
         ELSIF minsLeft = 1 THEN
            DRAWTEXT("1 minute left", xVal, yR, SansSerif, Standard, 10) ANCHOR(BOTTOMLEFT, XSHIFT, YSHIFT) COLOURED(190, 195, 205, 255)
         ELSE
            DRAWTEXT("#minsLeft# minutes left", xVal, yR, SansSerif, Standard, 10) ANCHOR(BOTTOMLEFT, XSHIFT, YSHIFT) COLOURED(190, 195, 205, 255)
         ENDIF
      ENDIF

      // row: where price is inside the bigger candle
      yR = yR - rowH
      DRAWTEXT("Price is", xLab, yR, SansSerif, Standard, 10) ANCHOR(BOTTOMLEFT, XSHIFT, YSHIFT) COLOURED(190, 195, 205, 153)
      IF close >= bigO THEN
         IF pos >= 2 / 3 THEN
            DRAWTEXT("Above its open, in the top third of its range", xVal, yR, SansSerif, Standard, 10) ANCHOR(BOTTOMLEFT, XSHIFT, YSHIFT) COLOURED(190, 195, 205, 255)
         ELSIF pos <= 1 / 3 THEN
            DRAWTEXT("Above its open, in the bottom third of its range", xVal, yR, SansSerif, Standard, 10) ANCHOR(BOTTOMLEFT, XSHIFT, YSHIFT) COLOURED(190, 195, 205, 255)
         ELSE
            DRAWTEXT("Above its open, in the middle of its range", xVal, yR, SansSerif, Standard, 10) ANCHOR(BOTTOMLEFT, XSHIFT, YSHIFT) COLOURED(190, 195, 205, 255)
         ENDIF
      ELSE
         IF pos >= 2 / 3 THEN
            DRAWTEXT("Below its open, in the top third of its range", xVal, yR, SansSerif, Standard, 10) ANCHOR(BOTTOMLEFT, XSHIFT, YSHIFT) COLOURED(190, 195, 205, 255)
         ELSIF pos <= 1 / 3 THEN
            DRAWTEXT("Below its open, in the bottom third of its range", xVal, yR, SansSerif, Standard, 10) ANCHOR(BOTTOMLEFT, XSHIFT, YSHIFT) COLOURED(190, 195, 205, 255)
         ELSE
            DRAWTEXT("Below its open, in the middle of its range", xVal, yR, SansSerif, Standard, 10) ANCHOR(BOTTOMLEFT, XSHIFT, YSHIFT) COLOURED(190, 195, 205, 255)
         ENDIF
      ENDIF

      // row: its core
      IF coreOk THEN
         yR = yR - rowH
         DRAWTEXT("Its core", xLab, yR, SansSerif, Standard, 10) ANCHOR(BOTTOMLEFT, XSHIFT, YSHIFT) COLOURED(190, 195, 205, 153)
         DRAWTEXT("#coreTxt#, where it has spent the most time", xVal, yR, SansSerif, Standard, 10) ANCHOR(BOTTOMLEFT, XSHIFT, YSHIFT) COLOURED(190, 195, 205, 255)
      ENDIF

      // row: the last finished bigger candle
      IF prevBars > 0 THEN
         yR = yR - rowH
         prevPct = 0
         IF prevO > 0 THEN
            prevPct = round(abs(prevC / prevO - 1) * 10000) / 100
         ENDIF
         IF prevH > prevL THEN
            ppos = (prevC - prevL) / (prevH - prevL)
         ELSE
            ppos = 0.5
         ENDIF
         DRAWTEXT("Last candle", xLab, yR, SansSerif, Standard, 10) ANCHOR(BOTTOMLEFT, XSHIFT, YSHIFT) COLOURED(190, 195, 205, 153)
         IF prevC >= prevO THEN
            IF ppos >= 0.75 THEN
               DRAWTEXT("Up #prevPct#%, closed near its high", xVal, yR, SansSerif, Standard, 10) ANCHOR(BOTTOMLEFT, XSHIFT, YSHIFT) COLOURED(190, 195, 205, 255)
            ELSIF ppos <= 0.25 THEN
               DRAWTEXT("Up #prevPct#%, closed near its low", xVal, yR, SansSerif, Standard, 10) ANCHOR(BOTTOMLEFT, XSHIFT, YSHIFT) COLOURED(190, 195, 205, 255)
            ELSE
               DRAWTEXT("Up #prevPct#%, closed mid range", xVal, yR, SansSerif, Standard, 10) ANCHOR(BOTTOMLEFT, XSHIFT, YSHIFT) COLOURED(190, 195, 205, 255)
            ENDIF
         ELSE
            IF ppos >= 0.75 THEN
               DRAWTEXT("Down #prevPct#%, closed near its high", xVal, yR, SansSerif, Standard, 10) ANCHOR(BOTTOMLEFT, XSHIFT, YSHIFT) COLOURED(190, 195, 205, 255)
            ELSIF ppos <= 0.25 THEN
               DRAWTEXT("Down #prevPct#%, closed near its low", xVal, yR, SansSerif, Standard, 10) ANCHOR(BOTTOMLEFT, XSHIFT, YSHIFT) COLOURED(190, 195, 205, 255)
            ELSE
               DRAWTEXT("Down #prevPct#%, closed mid range", xVal, yR, SansSerif, Standard, 10) ANCHOR(BOTTOMLEFT, XSHIFT, YSHIFT) COLOURED(190, 195, 205, 255)
            ENDIF
         ENDIF
      ENDIF
   ENDIF
ENDIF

RETURN

Original author: SimpleAlgo (SimpleAlgoAI).

Download
Filename: PRC_Timeframe-Master.itf
Downloads: 20
Iván González
Iván González Legend
Code artist, my biography is a blank page waiting to be scripted. Imagine a bio so awesome it hasn't been coded yet.
Author’s Profile

Comments

ProRealCode ProRealCode
Loading...