Iván González

Auto Triangles: Ascending, Descending and Symmetrical

Category: Indicators By: Iván González Created: November 26, 2026, 11:35 AM
November 26, 2026, 11:35 AM
Indicators
0 Comments
Auto Triangles: Ascending, Descending and Symmetrical

Introduction

 

A triangle is two trendlines closing in on each other: the highs coming down, the lows coming up, or one of them flat. Most traders draw them by hand, redraw them every few days, and then draw the measured-move target by hand too.

Auto Triangles does that work for you. It finds triangles from swing pivots, names the type, follows the active one bar by bar, marks the close that breaks it and draws the classic target: the height of the triangle at its widest point, projected from the breakout. When price reaches the target, the label says so; when the breakout fails, the indicator says that too.

Theory Behind the Indicator

 

Pivots. A swing high is a high with pivLen lower highs on each side (a swing low the other way round). A pivot is only known pivLen bars after it happens, so a triangle appears that many bars after its last pivot. Once drawn, it is never redrawn backwards in time.

Search. On every new pivot, every pairing of the last four swing highs with the last four swing lows is tested. Using only the latest two of each would miss most triangles: one stray swing in the middle and the pair no longer fits. When several pairings pass, the longest one wins. A pairing must meet all of these rules:

  • highs and lows take turns, and both lines start at about the same time;
  • the pattern is between minSpan and maxSpan bars long;
  • its height at the widest point is at least minHgtAtr ATRs;
  • the lines converge, with the apex still ahead but not so far away that the lines are nearly parallel, and the pattern is already at least 15% narrower than at its start;
  • every close since the first pivot sits between the two lines. Wicks may poke through; closes may not.

Type. It is read from how far each line moves over the life of the pattern, compared with the pattern’s own height. A line that moves less than flatPct percent of the height is flat. Flat top and rising lows is ascending, flat bottom and falling highs is descending, falling highs and rising lows is symmetrical. Two lines moving the same way are a wedge, not a triangle, and are skipped.

Break and target. A close above the upper line or below the lower line is the breakout. The target is the height at the widest point, added to the broken line. The break has failed once price closes beyond the far side of the triangle, the level where a stop would usually sit. A triangle that reaches its apex without a close outside stays on the chart in grey, because hiding the ones that went nowhere would leave only the ones that worked.

Everything is computed on closed candles, so nothing repaints.

Key Features at a Glance

 

  • Automatic detection of ascending, descending and symmetrical triangles from swing pivots.
  • The forming triangle in gold, with shading and dotted projections to the apex.
  • Breakouts marked in green (up) or red (down), patterns that ran out of room in grey.
  • Measured-move target drawn from the breakout, marked “reached” or “cancelled”.
  • “Break failed” label when price closes back beyond the far side of the triangle.
  • A panel with the forming triangle (both lines, their distance from price and the bars left to the apex) or, when none is forming, the last triangle and the last target.

How to Read the Indicator

 

  • Gold triangle: still forming. The dotted lines show where the two lines meet. The closer the apex, the less room price has left inside.
  • Green or red triangle: broken up or down on the bar marked “Break up” or “Break down”. The dashed line 20 bars long is the target.
  • “Target … reached”: the target line becomes solid and ends on the bar that touched it.
  • “Break failed” in orange: price closed beyond the far side of the triangle after the break; the target is cancelled.
  • Grey triangle: it reached its apex without a close outside.

Practical Applications

 

  • Breakout trading: wait for the close outside the triangle and use the far side of the pattern as the invalidation level, exactly the level the indicator uses to call a failed break.
  • Targets: the measured move gives a first objective; the “reached” and “failed” marks on past triangles show how the pattern has behaved on the instrument.
  • Filtering the pattern type: set showTypes to look only at ascending, descending or symmetrical triangles.

Indicator Configuration

 

  • pivLen (default 5): bars on each side of a swing high or low. Larger values find bigger, slower triangles.
  • minSpan (default 15) and maxSpan (default 150): shortest and longest triangle in bars.
  • flatPct (default 20): a line that moves less than this percentage of the triangle’s height counts as flat.
  • minHgtAtr (default 1.5): smallest height in ATRs; skips triangles too small to matter on the chart.
  • showTypes (default 0): 0 all, 1 ascending, 2 descending, 3 symmetrical.
  • keepPast (default 6): finished triangles kept on the chart besides the newest one.
  • showFill, showTgt, showPanel (default 1): shading, target and panel on or off.
  • lineW (default 2): line thickness, 1 to 4.
  • labelSize and panelSize (default 10): font sizes.
  • panelX (default -10) and panelY (default -20): panel position in pixels from the top right corner.
  • Colours: forming (gold), broke up (green), broke down (red), ran out (grey), failed break (orange) and panel text, as RGB values.

The Code

 

//---------------------------------------------------------------
// PRC_Auto Triangles
// version = 0
// 26.11.2026
// Iván González @ www.prorealcode.com
// Author: ITA Trading Tools (itamardrori_)
// Sharing ProRealTime knowledge
//--------------------------------------------------------------------//
DEFPARAM DRAWONLASTBARONLY = true

// ===================== INPUTS
// --- Detection
pivLen = 5           // bars on each side of a swing high or low (2 to 30)
minSpan = 15         // shortest triangle in bars
maxSpan = 150        // longest triangle in bars
flatPct = 20         // a line that moves less than this % of the height is flat
minHgtAtr = 1.5      // smallest height in ATRs
// --- Display
showTypes = 0        // 0 = all, 1 = ascending, 2 = descending, 3 = symmetrical
keepPast = 6         // finished triangles to keep
showFill = 1         // shade the triangle
showTgt = 1          // draw the target
showPanel = 1        // show the panel
lineW = 2            // line thickness (1 to 4)
labelSize = 10       // label font size
panelSize = 10       // panel font size
panelX = -10         // panel right edge, pixels from the right border
panelY = -20         // panel first row, pixels from the top border
// --- Colours (R, G, B)
liveR = 229          // triangle still forming
liveG = 197
liveB = 107
upR = 8              // broke up
upG = 153
upB = 129
dnR = 242            // broke down
dnG = 54
dnB = 69
deadR = 120          // ran out without a break
deadG = 123
deadB = 134
failR = 255          // failed break
failG = 152
failB = 0
txtR = 67            // panel text
txtG = 70
txtB = 81

// ===================== ENGINE
// Every candle processes the previous one, which is closed: pivots, triangles,
// breaks and targets only change on closed candles, so nothing repaints.
ONCE nH = 0
ONCE nL = 0
ONCE nT = 0
ONCE act = 0
ONCE lastEnd = -1
ONCE hasTgt = 0
ONCE lastKind = 0
ONCE lastBar = 0
ONCE tgtTri = -1

atrV = averagetruerange[14](close)

IF barindex > 2 * pivLen + 2 THEN
   bi = barindex - 1
   aNow = atrV[1]
   cNow = close[1]
   hNow = high[1]
   lNow = low[1]

   // --- pivots of the closed candle (pivot candle = bi - pivLen)
   newPivot = 0
   IF high[pivLen + 1] > highest[pivLen](high)[1] AND high[pivLen + 1] >= highest[pivLen](high)[pivLen + 2] THEN
      $hXa[nH] = bi - pivLen
      $hYa[nH] = high[pivLen + 1]
      nH = nH + 1
      newPivot = 1
   ENDIF
   IF low[pivLen + 1] < lowest[pivLen](low)[1] AND low[pivLen + 1] <= lowest[pivLen](low)[pivLen + 2] THEN
      $lXa[nL] = bi - pivLen
      $lYa[nL] = low[pivLen + 1]
      nL = nL + 1
      newPivot = 1
   ENDIF

   // --- detection: on every new pivot, every pairing of the last four swing
   // highs with the last four swing lows (out of the last six kept). When
   // several pairings pass, the longest one wins.
   IF newPivot = 1 AND nH >= 2 AND nL >= 2 THEN
      nhC = min(nH, 6)
      nlC = min(nL, 6)
      hBase = nH - nhC
      lBase = nL - nlC
      hFrom = max(0, nhC - 4)
      lFrom = max(0, nlC - 4)
      found = 0
      FOR iHa = hFrom TO nhC - 2 DO
         FOR iHb = iHa + 1 TO nhC - 1 DO
            FOR iLc = lFrom TO nlC - 2 DO
               FOR iLd = iLc + 1 TO nlC - 1 DO
                  cux1 = $hXa[hBase + iHa]
                  cuy1 = $hYa[hBase + iHa]
                  cux2 = $hXa[hBase + iHb]
                  cuy2 = $hYa[hBase + iHb]
                  clx1 = $lXa[lBase + iLc]
                  cly1 = $lYa[lBase + iLc]
                  clx2 = $lXa[lBase + iLd]
                  cly2 = $lYa[lBase + iLd]
                  cx0 = min(cux1, clx1)
                  ok = 0
                  // highs and lows take turns; both lines start at about the same time
                  IF cux1 < clx2 AND clx1 < cux2 AND cx0 > lastEnd THEN
                     IF bi - cx0 >= minSpan AND bi - cx0 <= maxSpan THEN
                        IF found = 0 OR cx0 < bx0 THEN
                           IF abs(cux1 - clx1) <= 0.3 * (bi - cx0) THEN
                              ok = 1
                           ENDIF
                        ENDIF
                     ENDIF
                  ENDIF
                  IF ok = 1 THEN
                     xs = max(cux1, clx1)
                     su = (cuy2 - cuy1) / (cux2 - cux1)
                     sl = (cly2 - cly1) / (clx2 - clx1)
                     cH0 = (cuy1 + su * (xs - cux1)) - (cly1 + sl * (xs - clx1))
                     dw = su - sl
                     ok = 0
                     IF cH0 >= minHgtAtr * aNow AND dw < 0 THEN
                        cApex = xs + floor(cH0 / (0 - dw))
                        wNow = (cuy1 + su * (bi - cux1)) - (cly1 + sl * (bi - clx1))
                        // apex still ahead, and not so far that the lines are nearly parallel
                        IF cApex > bi + 1 AND cApex - bi <= (bi - cx0) * 1.5 AND cApex - bi <= 450 AND wNow <= cH0 * 0.85 THEN
                           ok = 1
                        ENDIF
                     ENDIF
                  ENDIF
                  IF ok = 1 THEN
                     // the type, from how far each line moves over the life of the pattern
                     life = cApex - xs
                     dU = su * life
                     dL = sl * life
                     tol = cH0 * flatPct / 100
                     cKind = 0
                     IF abs(dU) <= tol AND dL > tol THEN
                        cKind = 1
                     ELSIF abs(dL) <= tol AND dU < 0 - tol THEN
                        cKind = 2
                     ELSIF dU < 0 - tol AND dL > tol THEN
                        cKind = 3
                     ENDIF
                     ok = 0
                     IF cKind > 0 AND (showTypes = 0 OR showTypes = cKind) THEN
                        ok = 1
                     ENDIF
                  ENDIF
                  IF ok = 1 THEN
                     // containment: every close since the first pivot sits between the lines
                     FOR k = 0 TO bi - cx0 DO
                        xk = bi - k
                        cK = close[k + 1]
                        IF cK > cuy1 + su * (xk - cux1) OR cK < cly1 + sl * (xk - clx1) THEN
                           ok = 0
                           BREAK
                        ENDIF
                     NEXT
                  ENDIF
                  IF ok = 1 THEN
                     found = 1
                     bux1 = cux1
                     buy1 = cuy1
                     bux2 = cux2
                     buy2 = cuy2
                     blx1 = clx1
                     bly1 = cly1
                     blx2 = clx2
                     bly2 = cly2
                     bx0 = cx0
                     bApex = cApex
                     bH0 = cH0
                     bKind = cKind
                  ENDIF
               NEXT
            NEXT
         NEXT
      NEXT

      // a refinement of the active triangle replaces it; a shorter one inside it does not
      IF found = 1 AND (act = 0 OR bx0 >= x0) THEN
         act = 1
         ux1 = bux1
         uy1 = buy1
         ux2 = bux2
         uy2 = buy2
         lx1 = blx1
         ly1 = bly1
         lx2 = blx2
         ly2 = bly2
         x0 = bx0
         apexX = bApex
         hgt0 = bH0
         triKind = bKind
         bornAtr = aNow
      ENDIF
   ENDIF

   // --- following the active triangle
   IF act = 1 THEN
      su = (uy2 - uy1) / (ux2 - ux1)
      sl = (ly2 - ly1) / (lx2 - lx1)
      uNow = uy1 + su * (bi - ux1)
      lwNow = ly1 + sl * (bi - lx1)
      ended = 0
      IF cNow > uNow OR cNow < lwNow THEN
         IF cNow > uNow THEN
            dirB = 1
            $tMkY[nT] = hNow + aNow * 0.6
            tgt = uNow + hgt0
            failLvl = lwNow
         ELSE
            dirB = -1
            $tMkY[nT] = lNow - aNow * 0.6
            tgt = lwNow - hgt0
            failLvl = uNow
         ENDIF
         // the measured move: the height at the widest point, from the broken line
         $tRes[nT] = dirB
         $tTgt[nT] = tgt
         $tTgtSt[nT] = 0
         hasTgt = 1
         tgtDir = dirB
         tgtHit = 0
         tgtFail = 0
         tgtTri = nT
         ended = 1
      ELSIF bi >= apexX - 1 THEN
         // ran into its own apex without a close outside: kept on the chart, greyed
         $tRes[nT] = 0
         ended = 1
      ENDIF
      IF ended = 1 THEN
         $tX0[nT] = x0
         $tUy0[nT] = uy1 + su * (x0 - ux1)
         $tLy0[nT] = ly1 + sl * (x0 - lx1)
         $tXe[nT] = bi
         $tUye[nT] = uNow
         $tLye[nT] = lwNow
         $tKind[nT] = triKind
         $tLabY[nT] = uy1 + su * (x0 - ux1) + bornAtr * 0.6
         lastKind = triKind
         lastBar = bi
         nT = nT + 1
         act = 0
         lastEnd = bi
      ENDIF
   ENDIF

   // --- the target of the most recent break
   IF hasTgt = 1 AND tgtHit = 0 AND tgtFail = 0 THEN
      IF (tgtDir = 1 AND cNow < failLvl) OR (tgtDir = -1 AND cNow > failLvl) THEN
         // failed once price closes beyond the far side of the triangle
         tgtFail = 1
         $tTgtSt[tgtTri] = -1
         $tEvX[tgtTri] = bi
         IF tgtDir = 1 THEN
            $tEvY[tgtTri] = lNow - aNow * 1.2
         ELSE
            $tEvY[tgtTri] = hNow + aNow * 1.2
         ENDIF
      ELSIF (tgtDir = 1 AND hNow >= tgt) OR (tgtDir = -1 AND lNow <= tgt) THEN
         tgtHit = 1
         $tTgtSt[tgtTri] = 1
         $tEvX[tgtTri] = bi
      ENDIF
   ENDIF
ENDIF

// ===================== DRAWING
IF islastbarupdate THEN
   // --- finished triangles, oldest first
   IF nT > 0 THEN
      firstT = max(0, nT - keepPast - 1)
      FOR it = firstT TO nT - 1 DO
         res = $tRes[it]
         IF res = 1 THEN
            fR = upR
            fG = upG
            fB = upB
         ELSIF res = -1 THEN
            fR = dnR
            fG = dnG
            fB = dnB
         ELSE
            fR = deadR
            fG = deadG
            fB = deadB
         ENDIF
         ax = $tX0[it]
         ex = $tXe[it]
         au = $tUy0[it]
         al = $tLy0[it]
         eu = $tUye[it]
         el = $tLye[it]
         IF showFill = 1 THEN
            DRAWTRIANGLE(ax, au, ex, eu, ex, el) COLOURED(fR, fG, fB, 0) FILLCOLOR(fR, fG, fB, 26)
            DRAWTRIANGLE(ax, au, ex, el, ax, al) COLOURED(fR, fG, fB, 0) FILLCOLOR(fR, fG, fB, 26)
         ENDIF
         IF lineW <= 1 THEN
            DRAWSEGMENT(ax, au, ex, eu) COLOURED(fR, fG, fB, 255) STYLE(line, 1)
            DRAWSEGMENT(ax, al, ex, el) COLOURED(fR, fG, fB, 255) STYLE(line, 1)
         ELSIF lineW = 2 THEN
            DRAWSEGMENT(ax, au, ex, eu) COLOURED(fR, fG, fB, 255) STYLE(line, 2)
            DRAWSEGMENT(ax, al, ex, el) COLOURED(fR, fG, fB, 255) STYLE(line, 2)
         ELSIF lineW = 3 THEN
            DRAWSEGMENT(ax, au, ex, eu) COLOURED(fR, fG, fB, 255) STYLE(line, 3)
            DRAWSEGMENT(ax, al, ex, el) COLOURED(fR, fG, fB, 255) STYLE(line, 3)
         ELSE
            DRAWSEGMENT(ax, au, ex, eu) COLOURED(fR, fG, fB, 255) STYLE(line, 4)
            DRAWSEGMENT(ax, al, ex, el) COLOURED(fR, fG, fB, 255) STYLE(line, 4)
         ENDIF
         // the triangle's name, above its first upper point
         ly = $tLabY[it]
         tk = $tKind[it]
         IF tk = 1 THEN
            DRAWTEXT("Ascending triangle", ax, ly, SansSerif, Bold, labelSize) COLOURED(fR, fG, fB, 255)
         ELSIF tk = 2 THEN
            DRAWTEXT("Descending triangle", ax, ly, SansSerif, Bold, labelSize) COLOURED(fR, fG, fB, 255)
         ELSE
            DRAWTEXT("Symmetrical triangle", ax, ly, SansSerif, Bold, labelSize) COLOURED(fR, fG, fB, 255)
         ENDIF
         IF res <> 0 THEN
            my = $tMkY[it]
            IF res = 1 THEN
               DRAWTEXT("▲ Break up", ex, my, SansSerif, Bold, labelSize) COLOURED(fR, fG, fB, 255)
            ELSE
               DRAWTEXT("▼ Break down", ex, my, SansSerif, Bold, labelSize) COLOURED(fR, fG, fB, 255)
            ENDIF
            st = $tTgtSt[it]
            ty = $tTgt[it]
            IF showTgt = 1 THEN
               IF st = 1 THEN
                  DRAWSEGMENT(ex, ty, $tEvX[it], ty) COLOURED(fR, fG, fB, 204) STYLE(line, 1)
               ELSIF st = -1 THEN
                  DRAWSEGMENT(ex, ty, ex + 20, ty) COLOURED(failR, failG, failB, 153) STYLE(dottedline2, 1)
               ELSE
                  DRAWSEGMENT(ex, ty, ex + 20, ty) COLOURED(fR, fG, fB, 204) STYLE(dottedline2, 1)
               ENDIF
            ENDIF
            IF st = -1 THEN
               DRAWTEXT("✗ Break failed", $tEvX[it], $tEvY[it], SansSerif, Bold, labelSize) COLOURED(failR, failG, failB, 255)
            ENDIF
         ENDIF
      NEXT
   ENDIF

   // --- label of the most recent target
   IF showTgt = 1 AND hasTgt = 1 AND tgtTri >= 0 THEN
      tgtT = round(tgt / ticksize) * ticksize
      tex = $tXe[tgtTri]
      IF tgtDir = 1 THEN
         gR = upR
         gG = upG
         gB = upB
      ELSE
         gR = dnR
         gG = dnG
         gB = dnB
      ENDIF
      IF tgtHit = 1 THEN
         DRAWTEXT("✓ Target #tgtT# reached", $tEvX[tgtTri] + 8, tgt, SansSerif, Bold, labelSize) COLOURED(gR, gG, gB, 255)
      ELSIF tgtFail = 1 THEN
         DRAWTEXT("Target #tgtT# cancelled", tex + 28, tgt, SansSerif, Bold, labelSize) COLOURED(failR, failG, failB, 255)
      ELSE
         DRAWTEXT("Target #tgtT#", tex + 26, tgt, SansSerif, Bold, labelSize) COLOURED(gR, gG, gB, 255)
      ENDIF
   ENDIF

   // --- the active triangle
   IF act = 1 THEN
      su = (uy2 - uy1) / (ux2 - ux1)
      sl = (ly2 - ly1) / (lx2 - lx1)
      lb = barindex - 1
      au = uy1 + su * (x0 - ux1)
      al = ly1 + sl * (x0 - lx1)
      eu = uy1 + su * (lb - ux1)
      el = ly1 + sl * (lb - lx1)
      pu = uy1 + su * (apexX - ux1)
      pl = ly1 + sl * (apexX - lx1)
      IF showFill = 1 THEN
         DRAWTRIANGLE(x0, au, lb, eu, lb, el) COLOURED(liveR, liveG, liveB, 0) FILLCOLOR(liveR, liveG, liveB, 26)
         DRAWTRIANGLE(x0, au, lb, el, x0, al) COLOURED(liveR, liveG, liveB, 0) FILLCOLOR(liveR, liveG, liveB, 26)
      ENDIF
      IF lineW <= 1 THEN
         DRAWSEGMENT(x0, au, lb, eu) COLOURED(liveR, liveG, liveB, 255) STYLE(line, 1)
         DRAWSEGMENT(x0, al, lb, el) COLOURED(liveR, liveG, liveB, 255) STYLE(line, 1)
      ELSIF lineW = 2 THEN
         DRAWSEGMENT(x0, au, lb, eu) COLOURED(liveR, liveG, liveB, 255) STYLE(line, 2)
         DRAWSEGMENT(x0, al, lb, el) COLOURED(liveR, liveG, liveB, 255) STYLE(line, 2)
      ELSIF lineW = 3 THEN
         DRAWSEGMENT(x0, au, lb, eu) COLOURED(liveR, liveG, liveB, 255) STYLE(line, 3)
         DRAWSEGMENT(x0, al, lb, el) COLOURED(liveR, liveG, liveB, 255) STYLE(line, 3)
      ELSE
         DRAWSEGMENT(x0, au, lb, eu) COLOURED(liveR, liveG, liveB, 255) STYLE(line, 4)
         DRAWSEGMENT(x0, al, lb, el) COLOURED(liveR, liveG, liveB, 255) STYLE(line, 4)
      ENDIF
      // projections to the apex
      DRAWSEGMENT(lb, eu, apexX, pu) COLOURED(liveR, liveG, liveB, 153) STYLE(dottedline, 1)
      DRAWSEGMENT(lb, el, apexX, pl) COLOURED(liveR, liveG, liveB, 153) STYLE(dottedline, 1)
      ly = au + bornAtr * 0.6
      IF triKind = 1 THEN
         DRAWTEXT("Ascending triangle", x0, ly, SansSerif, Bold, labelSize) COLOURED(liveR, liveG, liveB, 255)
      ELSIF triKind = 2 THEN
         DRAWTEXT("Descending triangle", x0, ly, SansSerif, Bold, labelSize) COLOURED(liveR, liveG, liveB, 255)
      ELSE
         DRAWTEXT("Symmetrical triangle", x0, ly, SansSerif, Bold, labelSize) COLOURED(liveR, liveG, liveB, 255)
      ENDIF
   ENDIF

   // --- panel (top right)
   IF showPanel = 1 THEN
      xKey = panelX - 250
      xV = panelX - 135
      xD = panelX - 40
      y0 = panelY
      y1 = panelY - 18
      y2 = panelY - 36
      y3 = panelY - 54
      DRAWTEXT("AUTO TRIANGLES", xKey, y0, SansSerif, Bold, panelSize) ANCHOR(TOPRIGHT, XSHIFT, YSHIFT) COLOURED(liveR, liveG, liveB, 255)
      IF act = 1 THEN
         su = (uy2 - uy1) / (ux2 - ux1)
         sl = (ly2 - ly1) / (lx2 - lx1)
         puNow = uy1 + su * (barindex - ux1)
         plNow = ly1 + sl * (barindex - lx1)
         IF triKind = 1 THEN
            DRAWTEXT("Ascending, forming", xV, y0, SansSerif, Standard, panelSize) ANCHOR(TOPRIGHT, XSHIFT, YSHIFT) COLOURED(liveR, liveG, liveB, 255)
         ELSIF triKind = 2 THEN
            DRAWTEXT("Descending, forming", xV, y0, SansSerif, Standard, panelSize) ANCHOR(TOPRIGHT, XSHIFT, YSHIFT) COLOURED(liveR, liveG, liveB, 255)
         ELSE
            DRAWTEXT("Symmetrical, forming", xV, y0, SansSerif, Standard, panelSize) ANCHOR(TOPRIGHT, XSHIFT, YSHIFT) COLOURED(liveR, liveG, liveB, 255)
         ENDIF
         // upper line
         uT = round(puNow / ticksize) * ticksize
         dU = round((puNow - close) / close * 1000) / 10
         DRAWTEXT("Upper line", xKey, y1, SansSerif, Standard, panelSize) ANCHOR(TOPRIGHT, XSHIFT, YSHIFT) COLOURED(txtR, txtG, txtB, 255)
         DRAWTEXT("#uT#", xV, y1, SansSerif, Standard, panelSize) ANCHOR(TOPRIGHT, XSHIFT, YSHIFT) COLOURED(upR, upG, upB, 255)
         IF dU >= 0 THEN
            DRAWTEXT("+#dU#%", xD, y1, SansSerif, Standard, panelSize) ANCHOR(TOPRIGHT, XSHIFT, YSHIFT) COLOURED(upR, upG, upB, 255)
         ELSE
            DRAWTEXT("#dU#%", xD, y1, SansSerif, Standard, panelSize) ANCHOR(TOPRIGHT, XSHIFT, YSHIFT) COLOURED(upR, upG, upB, 255)
         ENDIF
         // lower line
         lT = round(plNow / ticksize) * ticksize
         dL = round((plNow - close) / close * 1000) / 10
         DRAWTEXT("Lower line", xKey, y2, SansSerif, Standard, panelSize) ANCHOR(TOPRIGHT, XSHIFT, YSHIFT) COLOURED(txtR, txtG, txtB, 255)
         DRAWTEXT("#lT#", xV, y2, SansSerif, Standard, panelSize) ANCHOR(TOPRIGHT, XSHIFT, YSHIFT) COLOURED(dnR, dnG, dnB, 255)
         IF dL >= 0 THEN
            DRAWTEXT("+#dL#%", xD, y2, SansSerif, Standard, panelSize) ANCHOR(TOPRIGHT, XSHIFT, YSHIFT) COLOURED(dnR, dnG, dnB, 255)
         ELSE
            DRAWTEXT("#dL#%", xD, y2, SansSerif, Standard, panelSize) ANCHOR(TOPRIGHT, XSHIFT, YSHIFT) COLOURED(dnR, dnG, dnB, 255)
         ENDIF
         // apex
         apexIn = apexX - barindex
         DRAWTEXT("Apex in", xKey, y3, SansSerif, Standard, panelSize) ANCHOR(TOPRIGHT, XSHIFT, YSHIFT) COLOURED(txtR, txtG, txtB, 255)
         DRAWTEXT("#apexIn# bars", xV, y3, SansSerif, Standard, panelSize) ANCHOR(TOPRIGHT, XSHIFT, YSHIFT) COLOURED(txtR, txtG, txtB, 255)
      ELSE
         DRAWTEXT("None forming", xV, y0, SansSerif, Standard, panelSize) ANCHOR(TOPRIGHT, XSHIFT, YSHIFT) COLOURED(txtR, txtG, txtB, 255)
         IF lastKind > 0 THEN
            nAgo = barindex - lastBar
            DRAWTEXT("Last triangle", xKey, y1, SansSerif, Standard, panelSize) ANCHOR(TOPRIGHT, XSHIFT, YSHIFT) COLOURED(txtR, txtG, txtB, 255)
            IF lastKind = 1 THEN
               DRAWTEXT("Ascending, #nAgo# bars ago", xV, y1, SansSerif, Standard, panelSize) ANCHOR(TOPRIGHT, XSHIFT, YSHIFT) COLOURED(txtR, txtG, txtB, 255)
            ELSIF lastKind = 2 THEN
               DRAWTEXT("Descending, #nAgo# bars ago", xV, y1, SansSerif, Standard, panelSize) ANCHOR(TOPRIGHT, XSHIFT, YSHIFT) COLOURED(txtR, txtG, txtB, 255)
            ELSE
               DRAWTEXT("Symmetrical, #nAgo# bars ago", xV, y1, SansSerif, Standard, panelSize) ANCHOR(TOPRIGHT, XSHIFT, YSHIFT) COLOURED(txtR, txtG, txtB, 255)
            ENDIF
         ENDIF
         IF hasTgt = 1 THEN
            IF tgtDir = 1 THEN
               gR = upR
               gG = upG
               gB = upB
            ELSE
               gR = dnR
               gG = dnG
               gB = dnB
            ENDIF
            tgtT = round(tgt / ticksize) * ticksize
            dT = round((tgt - close) / close * 1000) / 10
            DRAWTEXT("Last target", xKey, y2, SansSerif, Standard, panelSize) ANCHOR(TOPRIGHT, XSHIFT, YSHIFT) COLOURED(txtR, txtG, txtB, 255)
            DRAWTEXT("#tgtT#", xV, y2, SansSerif, Standard, panelSize) ANCHOR(TOPRIGHT, XSHIFT, YSHIFT) COLOURED(gR, gG, gB, 255)
            IF tgtHit = 1 THEN
               DRAWTEXT("reached", xD, y2, SansSerif, Standard, panelSize) ANCHOR(TOPRIGHT, XSHIFT, YSHIFT) COLOURED(gR, gG, gB, 255)
            ELSIF tgtFail = 1 THEN
               DRAWTEXT("break failed", xD, y2, SansSerif, Standard, panelSize) ANCHOR(TOPRIGHT, XSHIFT, YSHIFT) COLOURED(failR, failG, failB, 255)
            ELSIF dT >= 0 THEN
               DRAWTEXT("+#dT#%", xD, y2, SansSerif, Standard, panelSize) ANCHOR(TOPRIGHT, XSHIFT, YSHIFT) COLOURED(gR, gG, gB, 255)
            ELSE
               DRAWTEXT("#dT#%", xD, y2, SansSerif, Standard, panelSize) ANCHOR(TOPRIGHT, XSHIFT, YSHIFT) COLOURED(gR, gG, gB, 255)
            ENDIF
         ENDIF
      ENDIF
   ENDIF
ENDIF

RETURN

Original author: ITA Trading Tools (itamardrori_), published open source.

Download
Filename: PRC_Auto-Triangles.itf
Downloads: 8
Iván González
Iván González Legend
This author is like an anonymous function, present but not directly identifiable. More details on this code architect as soon as they exit 'incognito' mode.
Author’s Profile

Comments

ProRealCode ProRealCode
Loading...