OPEN-SOURCE SCRIPT
Ribbon Stack [Quanty]

Everyone uses an EMA ribbon. Almost nobody checks what happens after it lines up.
This script draws the ribbon and then measures it. When all eight EMAs fall into order, it records the bar, waits ten bars, and counts how often price kept moving that way. It puts that count next to two yardsticks: the same signals tested in the opposite direction, and a random bar on the same chart. If a full stack is no better than a coin toss on your symbol and timeframe, the table says so.
WHAT MAKES IT DIFFERENT
The measurement. The ribbon itself is familiar; what is added is a stats table that tests the ribbon's own moment against chance, on the chart you are viewing, with the sample size always shown.
The colour reads the whole ribbon, not one crossover. Each of the seven neighbouring pairs is checked, so a ribbon that is only partly ordered looks partly ordered instead of flipping between two colours.
The width is measured. The distance between the fastest and the slowest line is shown in ATR, and bars where the ribbon is unusually tight are shaded.
WHAT IT SHOWS
Eight EMAs between a fastest and a slowest length (8 and 89 by default), coloured by the stack: one colour when the lines are in rising order, another when they are in falling order, and a neutral tone when they are mixed. The colour moves gradually, so a ribbon that is only partly ordered looks partly ordered. Optional: a fill between the fastest and the slowest line, a light shade on bars where the ribbon is compressed, a small mark on the bar where the ribbon becomes fully stacked, and a small readout in the bottom-right corner ("Stack +5/7 | width 1.8 ATR").
HOW IT IS CALCULATED
Lengths: the six lengths in between are spaced geometrically, so each one is the same multiple of the one before it (about 1.4x with the defaults: 8, 11, 16, 22, 32, 45, 63, 89). Evenly spaced ribbons (20, 25, 30...) crowd their slow end and leave their fast end sparse; geometric spacing keeps the steps even.
Stack: each of the seven neighbouring pairs scores +1 when the faster line is above the slower one and -1 when it is below. The sum runs from -7 to +7. Full stack means all seven pairs agree.
Width: the distance between the highest and the lowest of the eight lines, divided by the ATR (14 bars by default). In ATR units a width reads the same on a 15-minute chart and a daily one.
Compression: a bar is shaded when the width is in the lowest 10% of the last 200 bars. A compressed ribbon means the averages have converged; it says nothing about what comes next.
SETTINGS
Source, fastest and slowest length, ATR length, compression lookback and threshold. Appearance: the three colours, the fill, the compression shade, the full-stack marks and the readout. Three alerts: full stack in rising order, full stack in falling order, and the ribbon entering compression.
NOTES AND LIMITATIONS
Moving averages are built from past prices, so the ribbon always lags. A full stack confirms what price has already done; it is not a forecast. Marks and alerts are read on closed bars, so they do not repaint. The slowest length must be at least seven bars longer than the fastest.
HOW TO READ THE STATS TABLE
The table in the corner measures this indicator's own past signals on the chart you are viewing: how many signals fired (the number after the slash), and in how many of them price moved at least 1 ATR (14 bars) in the signal's direction within the next 10 bars. It is a measurement of history on this symbol and timeframe, not a prediction and not a promise. Change the symbol or the timeframe and the numbers change with it. Past results do not guarantee future results.
The next row tests the same signals in the opposite direction: if both directions score about the same, the signal marked a volatile moment, not a direction. The row after that runs the same test on every one of the last 500 bars in a random direction, so you can see what a coin toss would have scored here. Two more rows split the count by volume: signals whose candle volume was at least 2 times the average of the previous 50 bars, and the rest. When one side has only a handful of signals, read it as a handful, not as a rate. Pending signals are too recent to be measured and are not counted. The threshold can be set in ATR or in percent, and the number of bars ahead is a setting. The table can be shown in full or collapsed to one line.
Here a signal is the closed bar on which the ribbon becomes fully stacked: all eight EMAs in rising order (upward) or in falling order (downward).
Not investment advice.
This script draws the ribbon and then measures it. When all eight EMAs fall into order, it records the bar, waits ten bars, and counts how often price kept moving that way. It puts that count next to two yardsticks: the same signals tested in the opposite direction, and a random bar on the same chart. If a full stack is no better than a coin toss on your symbol and timeframe, the table says so.
WHAT MAKES IT DIFFERENT
The measurement. The ribbon itself is familiar; what is added is a stats table that tests the ribbon's own moment against chance, on the chart you are viewing, with the sample size always shown.
The colour reads the whole ribbon, not one crossover. Each of the seven neighbouring pairs is checked, so a ribbon that is only partly ordered looks partly ordered instead of flipping between two colours.
The width is measured. The distance between the fastest and the slowest line is shown in ATR, and bars where the ribbon is unusually tight are shaded.
WHAT IT SHOWS
Eight EMAs between a fastest and a slowest length (8 and 89 by default), coloured by the stack: one colour when the lines are in rising order, another when they are in falling order, and a neutral tone when they are mixed. The colour moves gradually, so a ribbon that is only partly ordered looks partly ordered. Optional: a fill between the fastest and the slowest line, a light shade on bars where the ribbon is compressed, a small mark on the bar where the ribbon becomes fully stacked, and a small readout in the bottom-right corner ("Stack +5/7 | width 1.8 ATR").
HOW IT IS CALCULATED
Lengths: the six lengths in between are spaced geometrically, so each one is the same multiple of the one before it (about 1.4x with the defaults: 8, 11, 16, 22, 32, 45, 63, 89). Evenly spaced ribbons (20, 25, 30...) crowd their slow end and leave their fast end sparse; geometric spacing keeps the steps even.
Stack: each of the seven neighbouring pairs scores +1 when the faster line is above the slower one and -1 when it is below. The sum runs from -7 to +7. Full stack means all seven pairs agree.
Width: the distance between the highest and the lowest of the eight lines, divided by the ATR (14 bars by default). In ATR units a width reads the same on a 15-minute chart and a daily one.
Compression: a bar is shaded when the width is in the lowest 10% of the last 200 bars. A compressed ribbon means the averages have converged; it says nothing about what comes next.
SETTINGS
Source, fastest and slowest length, ATR length, compression lookback and threshold. Appearance: the three colours, the fill, the compression shade, the full-stack marks and the readout. Three alerts: full stack in rising order, full stack in falling order, and the ribbon entering compression.
NOTES AND LIMITATIONS
Moving averages are built from past prices, so the ribbon always lags. A full stack confirms what price has already done; it is not a forecast. Marks and alerts are read on closed bars, so they do not repaint. The slowest length must be at least seven bars longer than the fastest.
HOW TO READ THE STATS TABLE
The table in the corner measures this indicator's own past signals on the chart you are viewing: how many signals fired (the number after the slash), and in how many of them price moved at least 1 ATR (14 bars) in the signal's direction within the next 10 bars. It is a measurement of history on this symbol and timeframe, not a prediction and not a promise. Change the symbol or the timeframe and the numbers change with it. Past results do not guarantee future results.
The next row tests the same signals in the opposite direction: if both directions score about the same, the signal marked a volatile moment, not a direction. The row after that runs the same test on every one of the last 500 bars in a random direction, so you can see what a coin toss would have scored here. Two more rows split the count by volume: signals whose candle volume was at least 2 times the average of the previous 50 bars, and the rest. When one side has only a handful of signals, read it as a handful, not as a rate. Pending signals are too recent to be measured and are not counted. The threshold can be set in ATR or in percent, and the number of bars ahead is a setting. The table can be shown in full or collapsed to one line.
Here a signal is the closed bar on which the ribbon becomes fully stacked: all eight EMAs in rising order (upward) or in falling order (downward).
Not investment advice.
สคริปต์แบบโอเพนซอร์ส
ด้วยเจตนารมณ์หลักของ TradingView ผู้สร้างสคริปต์นี้ได้ทำให้เป็นโอเพนซอร์ส เพื่อให้เทรดเดอร์สามารถตรวจสอบและยืนยันฟังก์ชันการทำงานของมันได้ ขอชื่นชมผู้เขียน! แม้ว่าคุณจะใช้งานได้ฟรี แต่โปรดจำไว้ว่าการเผยแพร่โค้ดซ้ำจะต้องเป็นไปตาม กฎระเบียบการใช้งาน ของเรา
คำจำกัดสิทธิ์ความรับผิดชอบ
ข้อมูลและบทความไม่ได้มีวัตถุประสงค์เพื่อก่อให้เกิดกิจกรรมทางการเงิน, การลงทุน, การซื้อขาย, ข้อเสนอแนะ หรือคำแนะนำประเภทอื่น ๆ ที่ให้หรือรับรองโดย TradingView อ่านเพิ่มเติมใน ข้อกำหนดการใช้งาน
สคริปต์แบบโอเพนซอร์ส
ด้วยเจตนารมณ์หลักของ TradingView ผู้สร้างสคริปต์นี้ได้ทำให้เป็นโอเพนซอร์ส เพื่อให้เทรดเดอร์สามารถตรวจสอบและยืนยันฟังก์ชันการทำงานของมันได้ ขอชื่นชมผู้เขียน! แม้ว่าคุณจะใช้งานได้ฟรี แต่โปรดจำไว้ว่าการเผยแพร่โค้ดซ้ำจะต้องเป็นไปตาม กฎระเบียบการใช้งาน ของเรา
คำจำกัดสิทธิ์ความรับผิดชอบ
ข้อมูลและบทความไม่ได้มีวัตถุประสงค์เพื่อก่อให้เกิดกิจกรรมทางการเงิน, การลงทุน, การซื้อขาย, ข้อเสนอแนะ หรือคำแนะนำประเภทอื่น ๆ ที่ให้หรือรับรองโดย TradingView อ่านเพิ่มเติมใน ข้อกำหนดการใช้งาน