OPEN-SOURCE SCRIPT
Perrin Polygons Shape Engine | ProjectSyndicate

Perrin Polygons — Shape Engine
Ten tabs of real dot-lattice mathematics, constructed live on your chart. Not a picture of figurate numbers — the actual construction, built dot by dot, every bar.
What it is
Most "Fibonacci" tools draw three lines and call it geometry. This one builds the geometry.
Perrin Polygons renders figurate numbers — the ancient dot-lattices that gave us triangular, square, pentagonal and hexagonal numbers — as living constructions on a chart canvas. Every dot is placed by the formula that defines it. Nothing is an image, nothing is hardcoded, nothing is traced.
The polygonal number
(s-2)·n² − (s-4)·n
P(s,n) = ──────────────────────────
2
is built here the way it is drawn, not the way it is written: as n nested gnomons. Gnomon k is the path W₁→W₂→…→W₍ₛ₋₁₎ of a regular s-gon of side k anchored at the origin, and it carries exactly (s-2)k + 1 dots. Stack k = 0 … n-1 and the total is P(s,n) — exactly, for every s and every n.
That construction is the engine. Everything else is what you can see once you have it.
The idea: why Perrin and polygons belong together
The Perrin sequence
P(n) = P(n-2) + P(n-3), P(0)=3, P(1)=0, P(2)=2
→ 3 · 0 · 2 · 3 · 2 · 5 · 5 · 7 · 10 · 12 · 17 · 22 · 29 · 39 · 51 · 68 …
is the plastic ratio's answer to Fibonacci — it grows by ρ = 1.3247179572, the real root of x³ = x + 1, where Fibonacci grows by φ = 1.618.
It looks like an unrelated curiosity. It isn't. It touches polygons twice, and both are shapes:
1 · The Perrin sequence is a list of polygons.
Read the terms as side counts: 3, 5, 7, 10, 12, 17, 22, 29 → triangle, pentagon, heptagon, decagon, dodecagon, 17-gon, 22-gon, 29-gon. The sequence doesn't describe polygons. It enumerates them.
2 · The Perrin numbers count polygons.
P(n) is exactly the number of maximal independent sets of the n-vertex cycle graph — and a cycle graph is a polygon. Choose vertices so no two are adjacent and no vertex is left uncovered; the number of ways is the nth Perrin number.
Tabs 02 and 05 draw those two facts. They are the reason this indicator exists.
The ten tabs
#TabWhat it draws01ATLASThe whole polygonal family. s = 3…8 across, n = 1…4 down. Every dot the same size, so the shapes grow with n — the sequence made visible.02PERRIN POLYGONSThe Perrin sequence as side counts: eight lattices from triangle to 29-gon.03GNOMONSOne shape, then the same shape taken apart ring by ring — (s-2)k+1 dots at a time.04CENTEREDCentered polygonal numbers: concentric rings of s·k dots around a single centre.05CYCLE GRAPHC(n) plus every one of its maximal independent sets, each drawn as a highlighted polygon. The count is brute-forced live and checked against P(n) on screen.06ROSETTEs = 12→3 nested, each radius divided by a power of ρ.07SPIRALSPlastic spiral (ρ per 120°) beside the golden spiral (φ per 90°) — why the plastic whirl is ~3× tighter.08RADAR ▸ liveThe market as a polygon: one vertex per Perrin-length RSI.09MARKET LATTICE ▸ liveThe last P(s,n) bars poured into a lattice — oldest at the centre, newest on the outer ring, coloured by direction.10IDENTITYA proof you can see: P(s+1,n) − P(s,n) = T(n-1). Three lattices, one shared pitch, counts checked live.
The formula panel
The dead chart space to the left of the shapes carries 30 formula cards — three per tab, switching with the tab.
Pine has no LaTeX. But its labels are monospace, so the panel renders genuine fraction bars instead of collapsing everything into (...)/2:
√( 8(s-2)·x + (s-4)² ) + (s-4)
n = ──────────────────────────────────
2(s-2)
Every card carries live values substituted in, not just symbols — the identity and its evaluation at your current settings. Set the atlas to n=4 and the gnomon card reads rings: 1 + 7 + 13 + 19 = 40.
Font size is yours (up to huge). Nothing is locked small.
Why it's unique
It computes; it doesn't illustrate. The gnomon construction, the plastic ratio, the maximal independent sets, the inverse of P(s,n) — all evaluated on your chart, from first principles.
It checks itself in public. Tab 05 brute-forces every maximal independent set of C(n) across all 2ⁿ subsets, counts them, and prints the result against the Perrin number with a ✓ or ✗. It isn't asserting the theorem at you. It's demonstrating it, and it would show you if it failed.
Every claim was verified before it was drawn. The gnomon construction was checked against P(s,n) for s = 3…12, n = 1…6 (dot counts and totals). MIS(Cₙ) = P(n) was brute-forced for n = 2…13. The inverse formula was checked to be exact for s = 3…12, n = 3…8. None of it was transcribed on trust.
The lattice actually reads. Dots are drawn in canvas units as a fraction of the lattice pitch, not in fixed pixels — so a 40-dot octagon stays legible instead of collapsing into a blob. Comparison tabs share one pitch across every shape, which is what makes a figurate sequence look like a sequence rather than a row of unrelated blobs.
Colour carries information. Five perceptual ramps (Magma, Viridis, Plasma, Ember, Ice) run inner→outer, so ring colour encodes gnomon order rather than fighting it.
Practical applications
1 · A non-Fibonacci lookback family.
Everyone uses 8/13/21/34/55. The Perrin sequence gives 5, 7, 10, 12, 17, 22, 29, 39, 51, 68, 90, 119 — a different, slower-growing ladder (ρ = 1.325 vs φ = 1.618), so the periods are more tightly spaced and sample the middle horizons that Fibonacci skips.
2 · RADAR — read many horizons as one shape.
Instead of stacking eight RSI panes, read the polygon. A swollen shape means every horizon is extended the same way — broad-based pressure. A shrunken shape is the mirror. A lopsided shape — fast vertices pushed out, slow vertices pulled in — is short-term extension against a slower base, which is the geometry of a divergence. One glance replaces eight readings.
3 · MARKET LATTICE — regime texture at a glance.
The last P(s,n) bars, oldest at the centre. Directional runs appear as coloured arcs; chop appears as speckle. The up-fraction is printed underneath. It's a compact way to see whether recent history is trending or shuffling.
4 · Reference geometry for plastic-ratio work.
Exact constants and identities for anyone building ρ-based levels: ρ³ = ρ+1, and the exact "plastic pocket" 1/ρ² + 1/ρ³ = 1 (0.569840 + 0.430160), the plastic analogue of the golden pocket.
5 · Teaching and content.
Figurate numbers, gnomon growth, the plastic ratio, and a graph-theory identity, all on one canvas with the formulas beside them. For educators, students, and anyone publishing.
Settings that matter
◧ Shape aspect (x per y) — the one dial you must set.
Pine cannot read a pane's pixel size, so nothing can automate this. Set it to:
aspect = (Canvas width / 100) × (pane height ÷ pane width)
Default 1.80 = a 440-bar canvas on a pane roughly 2.4× wider than tall. Shapes squashed flat → raise it. Stretched tall → lower it. They are only true polygons when this is right.
Everything else is optional: Lattice dot size (× pitch), five palettes, independent heading / caption / tab / formula text sizes, manual text colours, panel widths, and per-tab shape parameters.
On the tab strip: it is an index, not a button bar. Pine Script exposes no click, mouse or hover events — no TradingView indicator can have a working on-chart button. Tabs switch in Settings → Canvas → Tab.
What this is not
Stated plainly, because the space is full of tools that won't:
It generates no signals. No buy/sell arrows, no alerts, no strategy, no entries, no targets.
It reports no performance. No win rate, no profit factor, no backtest, no equity curve — because it makes no claims that would need them. Nothing here has been shown to have an edge, and nothing here pretends to.
The two live tabs are readouts, not forecasts. RADAR is RSI across Perrin lookbacks. MARKET LATTICE is bar direction. Neither predicts anything.
The plastic ratio is not magic. ρ is a real constant with real mathematics behind it. That it appears in a market tool does not mean markets obey it.
This is an instrument and a teaching engine. It shows you mathematics and it shows you your data. What you conclude is yours.
Pine Script® v6 · separate pane · no repainting · no external data.
Ten tabs of real dot-lattice mathematics, constructed live on your chart. Not a picture of figurate numbers — the actual construction, built dot by dot, every bar.
What it is
Most "Fibonacci" tools draw three lines and call it geometry. This one builds the geometry.
Perrin Polygons renders figurate numbers — the ancient dot-lattices that gave us triangular, square, pentagonal and hexagonal numbers — as living constructions on a chart canvas. Every dot is placed by the formula that defines it. Nothing is an image, nothing is hardcoded, nothing is traced.
The polygonal number
(s-2)·n² − (s-4)·n
P(s,n) = ──────────────────────────
2
is built here the way it is drawn, not the way it is written: as n nested gnomons. Gnomon k is the path W₁→W₂→…→W₍ₛ₋₁₎ of a regular s-gon of side k anchored at the origin, and it carries exactly (s-2)k + 1 dots. Stack k = 0 … n-1 and the total is P(s,n) — exactly, for every s and every n.
That construction is the engine. Everything else is what you can see once you have it.
The idea: why Perrin and polygons belong together
The Perrin sequence
P(n) = P(n-2) + P(n-3), P(0)=3, P(1)=0, P(2)=2
→ 3 · 0 · 2 · 3 · 2 · 5 · 5 · 7 · 10 · 12 · 17 · 22 · 29 · 39 · 51 · 68 …
is the plastic ratio's answer to Fibonacci — it grows by ρ = 1.3247179572, the real root of x³ = x + 1, where Fibonacci grows by φ = 1.618.
It looks like an unrelated curiosity. It isn't. It touches polygons twice, and both are shapes:
1 · The Perrin sequence is a list of polygons.
Read the terms as side counts: 3, 5, 7, 10, 12, 17, 22, 29 → triangle, pentagon, heptagon, decagon, dodecagon, 17-gon, 22-gon, 29-gon. The sequence doesn't describe polygons. It enumerates them.
2 · The Perrin numbers count polygons.
P(n) is exactly the number of maximal independent sets of the n-vertex cycle graph — and a cycle graph is a polygon. Choose vertices so no two are adjacent and no vertex is left uncovered; the number of ways is the nth Perrin number.
Tabs 02 and 05 draw those two facts. They are the reason this indicator exists.
The ten tabs
#TabWhat it draws01ATLASThe whole polygonal family. s = 3…8 across, n = 1…4 down. Every dot the same size, so the shapes grow with n — the sequence made visible.02PERRIN POLYGONSThe Perrin sequence as side counts: eight lattices from triangle to 29-gon.03GNOMONSOne shape, then the same shape taken apart ring by ring — (s-2)k+1 dots at a time.04CENTEREDCentered polygonal numbers: concentric rings of s·k dots around a single centre.05CYCLE GRAPHC(n) plus every one of its maximal independent sets, each drawn as a highlighted polygon. The count is brute-forced live and checked against P(n) on screen.06ROSETTEs = 12→3 nested, each radius divided by a power of ρ.07SPIRALSPlastic spiral (ρ per 120°) beside the golden spiral (φ per 90°) — why the plastic whirl is ~3× tighter.08RADAR ▸ liveThe market as a polygon: one vertex per Perrin-length RSI.09MARKET LATTICE ▸ liveThe last P(s,n) bars poured into a lattice — oldest at the centre, newest on the outer ring, coloured by direction.10IDENTITYA proof you can see: P(s+1,n) − P(s,n) = T(n-1). Three lattices, one shared pitch, counts checked live.
The formula panel
The dead chart space to the left of the shapes carries 30 formula cards — three per tab, switching with the tab.
Pine has no LaTeX. But its labels are monospace, so the panel renders genuine fraction bars instead of collapsing everything into (...)/2:
√( 8(s-2)·x + (s-4)² ) + (s-4)
n = ──────────────────────────────────
2(s-2)
Every card carries live values substituted in, not just symbols — the identity and its evaluation at your current settings. Set the atlas to n=4 and the gnomon card reads rings: 1 + 7 + 13 + 19 = 40.
Font size is yours (up to huge). Nothing is locked small.
Why it's unique
It computes; it doesn't illustrate. The gnomon construction, the plastic ratio, the maximal independent sets, the inverse of P(s,n) — all evaluated on your chart, from first principles.
It checks itself in public. Tab 05 brute-forces every maximal independent set of C(n) across all 2ⁿ subsets, counts them, and prints the result against the Perrin number with a ✓ or ✗. It isn't asserting the theorem at you. It's demonstrating it, and it would show you if it failed.
Every claim was verified before it was drawn. The gnomon construction was checked against P(s,n) for s = 3…12, n = 1…6 (dot counts and totals). MIS(Cₙ) = P(n) was brute-forced for n = 2…13. The inverse formula was checked to be exact for s = 3…12, n = 3…8. None of it was transcribed on trust.
The lattice actually reads. Dots are drawn in canvas units as a fraction of the lattice pitch, not in fixed pixels — so a 40-dot octagon stays legible instead of collapsing into a blob. Comparison tabs share one pitch across every shape, which is what makes a figurate sequence look like a sequence rather than a row of unrelated blobs.
Colour carries information. Five perceptual ramps (Magma, Viridis, Plasma, Ember, Ice) run inner→outer, so ring colour encodes gnomon order rather than fighting it.
Practical applications
1 · A non-Fibonacci lookback family.
Everyone uses 8/13/21/34/55. The Perrin sequence gives 5, 7, 10, 12, 17, 22, 29, 39, 51, 68, 90, 119 — a different, slower-growing ladder (ρ = 1.325 vs φ = 1.618), so the periods are more tightly spaced and sample the middle horizons that Fibonacci skips.
2 · RADAR — read many horizons as one shape.
Instead of stacking eight RSI panes, read the polygon. A swollen shape means every horizon is extended the same way — broad-based pressure. A shrunken shape is the mirror. A lopsided shape — fast vertices pushed out, slow vertices pulled in — is short-term extension against a slower base, which is the geometry of a divergence. One glance replaces eight readings.
3 · MARKET LATTICE — regime texture at a glance.
The last P(s,n) bars, oldest at the centre. Directional runs appear as coloured arcs; chop appears as speckle. The up-fraction is printed underneath. It's a compact way to see whether recent history is trending or shuffling.
4 · Reference geometry for plastic-ratio work.
Exact constants and identities for anyone building ρ-based levels: ρ³ = ρ+1, and the exact "plastic pocket" 1/ρ² + 1/ρ³ = 1 (0.569840 + 0.430160), the plastic analogue of the golden pocket.
5 · Teaching and content.
Figurate numbers, gnomon growth, the plastic ratio, and a graph-theory identity, all on one canvas with the formulas beside them. For educators, students, and anyone publishing.
Settings that matter
◧ Shape aspect (x per y) — the one dial you must set.
Pine cannot read a pane's pixel size, so nothing can automate this. Set it to:
aspect = (Canvas width / 100) × (pane height ÷ pane width)
Default 1.80 = a 440-bar canvas on a pane roughly 2.4× wider than tall. Shapes squashed flat → raise it. Stretched tall → lower it. They are only true polygons when this is right.
Everything else is optional: Lattice dot size (× pitch), five palettes, independent heading / caption / tab / formula text sizes, manual text colours, panel widths, and per-tab shape parameters.
On the tab strip: it is an index, not a button bar. Pine Script exposes no click, mouse or hover events — no TradingView indicator can have a working on-chart button. Tabs switch in Settings → Canvas → Tab.
What this is not
Stated plainly, because the space is full of tools that won't:
It generates no signals. No buy/sell arrows, no alerts, no strategy, no entries, no targets.
It reports no performance. No win rate, no profit factor, no backtest, no equity curve — because it makes no claims that would need them. Nothing here has been shown to have an edge, and nothing here pretends to.
The two live tabs are readouts, not forecasts. RADAR is RSI across Perrin lookbacks. MARKET LATTICE is bar direction. Neither predicts anything.
The plastic ratio is not magic. ρ is a real constant with real mathematics behind it. That it appears in a market tool does not mean markets obey it.
This is an instrument and a teaching engine. It shows you mathematics and it shows you your data. What you conclude is yours.
Pine Script® v6 · separate pane · no repainting · no external data.
Açık kaynak kodlu komut dosyası
Gerçek TradingView ruhuyla, bu komut dosyasının mimarı, yatırımcıların işlevselliğini inceleyip doğrulayabilmesi için onu açık kaynaklı hale getirdi. Yazarı tebrik ederiz! Ücretsiz olarak kullanabilseniz de, kodu yeniden yayınlamanın Topluluk Kurallarımıza tabi olduğunu unutmayın.
syndicate001.com
Algo systems for prop traders
Algo systems for pro gold traders
Algo Trading and Indicator Tutorials
Levels desk Gold FX NQ ES JPN225
telegram.me/aisyndicate001
Algo systems for prop traders
Algo systems for pro gold traders
Algo Trading and Indicator Tutorials
Levels desk Gold FX NQ ES JPN225
telegram.me/aisyndicate001
Feragatname
Bilgiler ve yayınlar, TradingView tarafından sağlanan veya onaylanan finansal, yatırım, alım satım veya diğer türden tavsiye veya öneriler anlamına gelmez ve teşkil etmez. Kullanım Koşulları bölümünde daha fazlasını okuyun.
Açık kaynak kodlu komut dosyası
Gerçek TradingView ruhuyla, bu komut dosyasının mimarı, yatırımcıların işlevselliğini inceleyip doğrulayabilmesi için onu açık kaynaklı hale getirdi. Yazarı tebrik ederiz! Ücretsiz olarak kullanabilseniz de, kodu yeniden yayınlamanın Topluluk Kurallarımıza tabi olduğunu unutmayın.
syndicate001.com
Algo systems for prop traders
Algo systems for pro gold traders
Algo Trading and Indicator Tutorials
Levels desk Gold FX NQ ES JPN225
telegram.me/aisyndicate001
Algo systems for prop traders
Algo systems for pro gold traders
Algo Trading and Indicator Tutorials
Levels desk Gold FX NQ ES JPN225
telegram.me/aisyndicate001
Feragatname
Bilgiler ve yayınlar, TradingView tarafından sağlanan veya onaylanan finansal, yatırım, alım satım veya diğer türden tavsiye veya öneriler anlamına gelmez ve teşkil etmez. Kullanım Koşulları bölümünde daha fazlasını okuyun.