Search...Ctrl K

Get all weekly swings

weekly_swings = df[df['W_Price'].notna()][['time', 'W_Cycle', 'W_Phase', 'W_Price']]

Coming Soon — MTTP is currently in development. This documentation is published early so you can explore what's ahead.

MTTP's CSV export provides hierarchical swing data across all timeframes. Unlike SSI PRO's single-timeframe export, MTTP exports the complete multi-timeframe structure with cycle numbering.


Enabling Export

  1. Open MTTP settings
  2. Find CSV Export section
  3. Enable Enable CSV Export Mode
  4. Optionally enable CSV Data Only if you don't need visual labels

Once enabled, additional columns appear in TradingView's data window and are included when you export chart data.


Exported Columns

For each timeframe, MTTP exports five data points:

ColumnDescriptionExample
{TF}_CycleCurrent cycle number within parent timeframe3
{TF}_PhaseDirection: 0=Bottom, 1=Top1
{TF}_PricePrice at the swing extreme4525.75
{TF}_Formation_TimeUnix timestamp (milliseconds) when extreme occurred1731801600000
{TF}_Bar_IndexBar index where extreme occurred2847

Timeframe prefixes:

  • Y = Yearly
  • Q = Quarterly
  • M = Monthly
  • W = Weekly
  • D = Daily
  • H4 = 4-Hour
  • H1 = 1-Hour
  • M15 = 15-Minute

Complete Column List

Y_Cycle, Y_Phase, Y_Price, Y_Formation_Time, Y_Bar_Index Q_Cycle, Q_Phase, Q_Price, Q_Formation_Time, Q_Bar_Index M_Cycle, M_Phase, M_Price, M_Formation_Time, M_Bar_Index W_Cycle, W_Phase, W_Price, W_Formation_Time, W_Bar_Index D_Cycle, D_Phase, D_Price, D_Formation_Time, D_Bar_Index H4_Cycle, H4_Phase, H4_Price, H4_Formation_Time, H4_Bar_Index H1_Cycle, H1_Phase, H1_Price, H1_Formation_Time, H1_Bar_Index M15_Cycle, M15_Phase, M15_Price, M15_Formation_Time, M15_Bar_Index Full_Hierarchy

Understanding Cycle Numbers

Cycle numbers count swings within their parent timeframe:

Example progression:

Year 1 begins Quarter 1: Q_Cycle = 1 Quarter 2: Q_Cycle = 2 Quarter 3: Q_Cycle = 3 Quarter 4: Q_Cycle = 4 Year 2 begins → Q_Cycle resets to 1 Quarter 1: Q_Cycle = 1 ...

The same logic applies down the hierarchy:

  • Monthly cycles reset each quarter
  • Weekly cycles reset each month
  • Daily cycles reset each week
  • And so on for intraday timeframes

Hierarchical Tags

Internally, MTTP builds hierarchical tags like:

Y2.Q4.M3.W8.D5.H4-2.H1-3.M15-7

This reads as:

  • Year cycle 2
  • Quarter 4 within that year
  • Month 3 within that quarter
  • Week 8 within that month
  • Day 5 within that week
  • 4-Hour swing 2 within that day
  • 1-Hour swing 3 within that 4-hour period
  • 15-Minute swing 7 within that hour

The exported columns break this apart into individual components for easier filtering and analysis.


The Full_Hierarchy Column

A composite number encoding all cycle positions:

Full_Hierarchy = Y * 100000000 + Q * 10000000 + M * 1000000 + W * 100000 + D * 10000 + H4 * 1000 + H1 * 100 + M15

Example:

  • Y=2, Q=4, M=3, W=8, D=5, H4=2, H1=3, M15=7
  • Full_Hierarchy = 243850237

This single number uniquely identifies the hierarchical position, useful for sorting and comparing structural positions across different bars.


Phase Interpretation

The Phase column indicates whether the last confirmed swing was a top or bottom:

PhaseMeaningCurrent Direction
0Last swing was a Bottom (low)Moving UP from that low
1Last swing was a Top (high)Moving DOWN from that high

Combined with the cycle number, you know both where you are in the structure and which direction is currently active.


How to Export

  1. Enable CSV Export Mode in settings
  2. Click the camera/snapshot icon in TradingView's toolbar
  3. Select Export chart data
  4. Choose CSV format
  5. Open in Excel, Google Sheets, or your analysis tool

Working with the Data

Filtering to Swing Rows

Most rows will have NaN values for swing columns (swings only occur at specific bars). Filter to rows where at least one {TF}_Price column has data:

Excel:

=NOT(ISNA(Y_Price)) OR NOT(ISNA(Q_Price)) OR NOT(ISNA(M_Price)) ...

Python (pandas):

python
swing_rows = df[df[['Y_Price', 'Q_Price', 'M_Price', 'W_Price', 'D_Price']].notna().any(axis=1)]

Converting Timestamps

Formation timestamps are Unix milliseconds. To convert:

Python:

python
import pandas as pd df['Y_Date'] = pd.to_datetime(df['Y_Formation_Time'], unit='ms')

JavaScript:

javascript
const date = new Date(row.Y_Formation_Time);

Excel:

=(A2/86400000)+DATE(1970,1,1)

Building Cycle Sequences

To analyze how cycles progress:

python
# Get all weekly swings weekly_swings = df[df['W_Price'].notna()][['time', 'W_Cycle', 'W_Phase', 'W_Price']] # Calculate swing-to-swing relationships weekly_swings['prev_price'] = weekly_swings['W_Price'].shift(1) weekly_swings['range'] = abs(weekly_swings['W_Price'] - weekly_swings['prev_price'])

CSV Data Only Mode

When CSV Data Only (No Labels) is enabled:

  • Swing detection runs normally
  • Cycle data is collected and exported
  • No visual labels are created

Benefits:

  • Bypasses the 500 label limit entirely
  • No dynamic window scanning overhead
  • Faster chart performance
  • Clean chart with data-only collection

Use case: You want MTTP's hierarchical data for external analysis but don't need labels cluttering your chart.


Date Filter

MTTP applies a 3-year recency filter to exported data. Swings older than 3 years from the current time are excluded from the CSV state variables.

This prevents ancient historical swings from persisting indefinitely in the export columns while ensuring recent and relevant data is captured.


Combining with SSI PRO Export

For comprehensive swing analysis, you can run both indicators and export both:

  • SSI PRO CSV: Detailed single-timeframe swing data with all 16 metrics
  • MTTP CSV: Multi-timeframe hierarchical position data

Merge by timestamp or bar_index to create a unified dataset showing both detailed swing metrics and structural context.


Database Integration

The exported data works well for database storage:

Suggested Schema

sql
CREATE TABLE mttp_swings ( id SERIAL PRIMARY KEY, symbol VARCHAR(20), bar_time TIMESTAMP, bar_index INTEGER, -- Yearly y_cycle INTEGER, y_phase INTEGER, y_price DECIMAL(18,8), y_formation_time BIGINT, -- Quarterly q_cycle INTEGER, q_phase INTEGER, q_price DECIMAL(18,8), q_formation_time BIGINT, -- Monthly m_cycle INTEGER, m_phase INTEGER, m_price DECIMAL(18,8), m_formation_time BIGINT, -- Weekly w_cycle INTEGER, w_phase INTEGER, w_price DECIMAL(18,8), w_formation_time BIGINT, -- Daily d_cycle INTEGER, d_phase INTEGER, d_price DECIMAL(18,8), d_formation_time BIGINT, -- Full hierarchy full_hierarchy BIGINT, UNIQUE(symbol, bar_index) );

Query Examples

Find all Weekly bottoms:

sql
SELECT * FROM mttp_swings WHERE w_phase = 0 AND w_price IS NOT NULL;

Find convergence (Weekly + Monthly bottom at same bar):

sql
SELECT * FROM mttp_swings WHERE w_phase = 0 AND m_phase = 0 AND w_price IS NOT NULL AND m_price IS NOT NULL;

Limitations

  • 2-Day and 3-Day swings are not currently included in CSV export (they use a different detection system)
  • Historical data beyond 3 years is filtered out
  • Chart must load sufficient history for higher timeframe swings to appear

Next Steps