OPEN-SOURCE SCRIPT
Carry Cost Monitor

The bill you did not expect
You run a Swiss franc account. You trade Micro E-mini S&P 500 futures because the US equity market is where the liquidity is. One quarter later your broker sends a statement and there it is: CHF 1,600 in debit interest. Nobody warned you. The contract you traded settles in US dollars. Your account holds Swiss francs. Interactive Brokers lent you the dollars, charged you the USD overnight rate plus 1.5% markup on every dollar for every day you held the position. Meanwhile your Swiss franc cash earned close to nothing because the SNB policy rate sits well below the Fed Funds rate. The gap between those two rates, accumulated silently over months, is the carry cost that drained your account.
This is not a rare edge case. Any trader whose account currency differs from the instrument currency faces the same mechanic. A European trading US equities, a Japanese investor buying Australian bonds, a Canadian holding FTSE futures. The cost is real, it compounds daily, and most platforms do not surface it until the quarterly statement arrives.
The Carry Cost Monitor exists to make this cost visible before it accumulates. It shows the yield differential between your account currency and the instrument currency in real time, estimates the financing cost or income over any horizon you choose, and lets you compare all major currencies side by side so you can make informed decisions about where and what you trade.
The indicator applied to a US dollar denominated chart with a CHF base account. The dashboard in the top right shows the carry spread, percentile rank, estimated annual cost, and break-even return. Below, the comparison table lists all available currencies sorted by carry cost.
What carry costs actually are
When you hold an instrument denominated in a foreign currency, your broker creates a loan in that currency to settle the trade. You owe interest on the borrowed amount and may earn interest on your deposited base currency. The net cost is the difference between those two rates plus whatever the broker charges on top.
The indicator formalizes this as:
Carry Spread (%) = Y_instrument - Y_account
where Y is the sovereign yield for the selected maturity. A positive spread means you borrow a currency that yields more than yours. You pay. A negative spread means the borrowed currency yields less than your base. You earn.
The gross carry rate adds the broker fee:
Gross Carry (%) = Carry Spread + Broker Markup
Interactive Brokers structures this markup in tiers (Interactive Brokers, 2024):
Balance 0 to 100,000: benchmark + 1.50%
Balance 100,000 to 1M: benchmark + 0.50%
Balance above 1M: benchmark + 0.30%
The estimated cost over a chosen horizon follows standard money market convention, adjusted for each currency's day count basis (Stigum and Crescenzi, 2007):
Cost = Nominal * (Gross Carry / 100) * (Days / Day Count Basis)
Day Count Basis is 360 for USD, EUR, CHF, JPY, and SEK (ACT/360), and 365 for GBP, CAD, AUD, and NZD (ACT/365). These match the interbank settlement rules in the ISDA day count fraction definitions (ISDA, 2006).
Finally, the break-even tells you how much your instrument must move to cover the carry drag:
Break-Even (%) = |Gross Carry| * (Days / 365)
This is the minimum performance needed to not lose money purely from financing.
Where the data comes from
The indicator pulls sovereign bond yields for 9 currencies across two maturities (2-year and 10-year), totaling 18 external data requests. The symbols follow TradingView's TVC convention:
USD: US02Y / US10Y EUR: DE02Y / DE10Y (Germany as eurozone proxy)
CHF: CH02Y / CH10Y GBP: GB02Y / GB10Y
JPY: JP02Y / JP10Y CAD: CA02Y / CA10Y
AUD: AU02Y / AU10Y NZD: NZ02Y / NZ10Y
SEK: SE02Y / SE10Y
The 2-year yield is the default because it sits closest to actual overnight funding rates. The correlation between 2-year sovereign yields and their respective benchmarks (SOFR for USD, SARON for CHF, ESTR for EUR) typically exceeds 0.85 over rolling 1-year windows, with average deviations of 20 to 50 basis points (Ilmanen, 2011). That deviation is smaller than the broker markup itself, making sovereign yields a practical proxy.
Why not use the overnight rates directly? Most are only available at monthly frequency through FRED on TradingView, with shorter history. Sovereign yields update daily with 10+ years of data. The trade-off is slight imprecision for much better coverage and responsiveness.
The instrument currency is detected automatically through the built-in syminfo.currency variable. When it matches your account currency, the indicator reports zero cost because no foreign exchange borrowing occurs. Currencies whose yield data returns nothing on TradingView are hidden from the chart and dashboard automatically.

The settings panel showing the Carry Model inputs. Account Currency is set to CHF, Yield Maturity to 2Y, Position Size to 100,000, and the broker tier to 0-100k. These four settings control the entire cost calculation.
Reading the carry lines
The main panel draws up to 8 spread lines, one per foreign currency relative to your account currency.
The zero line is the boundary. Everything above it costs you money. Everything below it earns you money. The further a line sits from zero, the larger the financing effect.
For the active instrument pair, a 1-sigma band (252-day rolling mean plus/minus one standard deviation) wraps around the spread. When the current value breaks outside this band, the carry environment is statistically unusual compared to its own recent history. That might mean a central bank shifted rates, or term spreads moved.
Each currency has its own color, chosen to stay distinguishable even under the most common forms of colorblindness:
USD: blue EUR: amber CHF: red GBP: purple
JPY: emerald CAD: orange AUD: cyan NZD: lime
SEK: fuchsia

The historical view with all currency lines visible. Each colored line represents one currency's carry spread against the selected base. Crossing the zero line marks a shift from paying carry to earning it.
The dashboard
The dashboard sits in the corner of the chart (position adjustable) and answers two questions without requiring you to read the lines themselves.
The top section shows the active pair in detail: the raw carry spread in percent, its percentile rank over 2 years (504 trading days), the estimated absolute cost or income for your chosen time horizon and position size, and the break-even return. This is the quick answer to "what is this position costing me right now?"
The bottom section is a comparison table listing every currency with valid data. Each row shows the currency name, its carry spread, its current yield, and the projected cost over your horizon. The instrument currency is marked with a triangle. Rows are color-coded: green for pairs that produce income, red for pairs that cost you money. This answers the follow-up question: "would my carry situation improve if I traded a similar instrument denominated in a different currency?"

The dashboard detail showing the active pair section. CHF to USD carry spread is positive, placing it in the 72nd percentile of its 2-year range. The estimated annual cost for a 100,000 position at the 0-100k broker tier is displayed alongside the break-even return.
The comparison table below the active pair section. All currencies are listed with their individual spreads and estimated costs. JPY shows the largest negative spread (income), while USD shows the highest positive spread (cost) from a CHF base perspective.
Setting it up
The Carry Model group contains the five settings that determine everything:
Account Currency: your brokerage base currency. This is the single most important input. Get this wrong and every number on the screen is meaningless.
Yield Maturity: 2Y sits closer to actual funding costs. 10Y captures term premium effects and is useful for longer-horizon strategic planning.
Position Size: the notional value of your position in the instrument currency. Drives the absolute cost estimate.
Cost Horizon: 1 month, 3 months, 6 months, or 1 year. Controls how far out the projection reaches.
Broker Balance Tier: matches the IB tiered structure. Set to "None" to strip out the broker markup entirely and see the pure yield differential.
The Display group controls background shading (green when earning, red when paying) and whether all currency lines appear or only the detected one.
Eight color themes are available (EdgeTools, Gold, Behavioral, Quant, Ocean, Fire, Matrix, Arctic) with dark and light mode support. Line width and glow effects are adjustable.
Three alert conditions can fire:
Carry spread enters the 90th percentile (historically expensive environment)
Carry spread enters the 10th percentile (historically cheap environment)
Carry spread crosses zero (direction flipped)
Practical examples
Example 1: CHF account trading MES (Micro E-mini S&P 500)
Account currency: CHF. Instrument currency: USD. Assume CH02Y = 0.60%, US02Y = 3.85%.
Carry spread = 3.85 - 0.60 = +3.25%.
Broker markup (0-100k tier) = 1.50%.
Gross carry = 3.25 + 1.50 = 4.75%.
Annual cost on 100,000 USD nominal = 100,000 * 0.0475 * (365/360) = 4,819 USD.
Break-even = 4.75% per year. The S&P 500 must return more than 4.75% annually just to cover carry.
Example 2: USD account buying CSPX (iShares S&P 500 UCITS, EUR-listed)
Account currency: USD. Instrument currency: EUR. Assume US02Y = 3.85%, DE02Y = 2.05%.
Carry spread = 2.05 - 3.85 = -1.80%.
Broker markup = 1.50%.
Gross carry = -1.80 + 1.50 = -0.30%.
Annual income on 100,000 EUR nominal = 100,000 * 0.003 * (365/360) = 304 EUR.
You earn a small amount because USD yields exceed EUR yields by more than the broker markup.
Example 3: EUR account trading Nikkei 225 futures (JPY-denominated)
Account currency: EUR. Instrument currency: JPY. Assume DE02Y = 2.05%, JP02Y = 0.15%.
Carry spread = 0.15 - 2.05 = -1.90%.
Broker markup = 1.50%.
Gross carry = -1.90 + 1.50 = -0.40%.
You earn a small net income because borrowing JPY is cheaper than what your EUR balance yields.
These examples show that the carry direction depends entirely on which currency has the higher rate and how large the broker fee is. Pairs close to zero can flip between cost and income whenever a central bank moves.
Limitations
Sovereign yields are not overnight rates. The 2-year bond yield is a proxy, not the exact benchmark brokers use. Interactive Brokers references SOFR for USD, SARON for CHF, ESTR for EUR, SONIA for GBP. The gap between sovereign 2Y yields and these overnight rates typically sits at 20 to 50 basis points (Ilmanen, 2011, p. 364), occasionally more during yield curve inversions.
The broker cost model is simplified. Real IB interest calculations depend on multi-currency balances across the account, unrealized PnL, margin usage, and the interaction between positive and negative currency positions. The indicator applies a single-tier markup, which captures the dominant cost component but may overstate the net cost for larger accounts earning credit interest on their base currency.
Currency detection relies on syminfo.currency. For most futures, ETFs, and equities on major exchanges, this returns the correct settlement currency. Some synthetic instruments, CFDs, or crypto pairs may return unexpected values. Always verify the detected currency in the dashboard header.
Currencies that consistently lacked yield data on TradingView (such as NOK) have been excluded. Missing data for remaining currencies is handled gracefully and does not produce errors.
The indicator works best on the daily timeframe. Intraday charts display yield data that updates once per day, creating flat segments within the session. This does not affect the accuracy of cost estimates.
References
Ilmanen, A. (2011) Expected returns: an investor's guide to harvesting market rewards. Chichester: John Wiley and Sons.
Interactive Brokers (2024) Interest rates on credit and debit balances. (Web Accessed: May 2026).
ISDA (2006) 2006 ISDA definitions. New York: International Swaps and Derivatives Association.
Koijen, R.S.J., Moskowitz, T.J., Pedersen, L.H. and Vrugt, E.B. (2018) 'Carry', Journal of Financial Economics, 127(2), pp. 197-225.
Stigum, M. and Crescenzi, A. (2007) Stigum's money market. 4th edn. New York: McGraw-Hill.
You run a Swiss franc account. You trade Micro E-mini S&P 500 futures because the US equity market is where the liquidity is. One quarter later your broker sends a statement and there it is: CHF 1,600 in debit interest. Nobody warned you. The contract you traded settles in US dollars. Your account holds Swiss francs. Interactive Brokers lent you the dollars, charged you the USD overnight rate plus 1.5% markup on every dollar for every day you held the position. Meanwhile your Swiss franc cash earned close to nothing because the SNB policy rate sits well below the Fed Funds rate. The gap between those two rates, accumulated silently over months, is the carry cost that drained your account.
This is not a rare edge case. Any trader whose account currency differs from the instrument currency faces the same mechanic. A European trading US equities, a Japanese investor buying Australian bonds, a Canadian holding FTSE futures. The cost is real, it compounds daily, and most platforms do not surface it until the quarterly statement arrives.
The Carry Cost Monitor exists to make this cost visible before it accumulates. It shows the yield differential between your account currency and the instrument currency in real time, estimates the financing cost or income over any horizon you choose, and lets you compare all major currencies side by side so you can make informed decisions about where and what you trade.
The indicator applied to a US dollar denominated chart with a CHF base account. The dashboard in the top right shows the carry spread, percentile rank, estimated annual cost, and break-even return. Below, the comparison table lists all available currencies sorted by carry cost.
What carry costs actually are
When you hold an instrument denominated in a foreign currency, your broker creates a loan in that currency to settle the trade. You owe interest on the borrowed amount and may earn interest on your deposited base currency. The net cost is the difference between those two rates plus whatever the broker charges on top.
The indicator formalizes this as:
Carry Spread (%) = Y_instrument - Y_account
where Y is the sovereign yield for the selected maturity. A positive spread means you borrow a currency that yields more than yours. You pay. A negative spread means the borrowed currency yields less than your base. You earn.
The gross carry rate adds the broker fee:
Gross Carry (%) = Carry Spread + Broker Markup
Interactive Brokers structures this markup in tiers (Interactive Brokers, 2024):
Balance 0 to 100,000: benchmark + 1.50%
Balance 100,000 to 1M: benchmark + 0.50%
Balance above 1M: benchmark + 0.30%
The estimated cost over a chosen horizon follows standard money market convention, adjusted for each currency's day count basis (Stigum and Crescenzi, 2007):
Cost = Nominal * (Gross Carry / 100) * (Days / Day Count Basis)
Day Count Basis is 360 for USD, EUR, CHF, JPY, and SEK (ACT/360), and 365 for GBP, CAD, AUD, and NZD (ACT/365). These match the interbank settlement rules in the ISDA day count fraction definitions (ISDA, 2006).
Finally, the break-even tells you how much your instrument must move to cover the carry drag:
Break-Even (%) = |Gross Carry| * (Days / 365)
This is the minimum performance needed to not lose money purely from financing.
Where the data comes from
The indicator pulls sovereign bond yields for 9 currencies across two maturities (2-year and 10-year), totaling 18 external data requests. The symbols follow TradingView's TVC convention:
USD: US02Y / US10Y EUR: DE02Y / DE10Y (Germany as eurozone proxy)
CHF: CH02Y / CH10Y GBP: GB02Y / GB10Y
JPY: JP02Y / JP10Y CAD: CA02Y / CA10Y
AUD: AU02Y / AU10Y NZD: NZ02Y / NZ10Y
SEK: SE02Y / SE10Y
The 2-year yield is the default because it sits closest to actual overnight funding rates. The correlation between 2-year sovereign yields and their respective benchmarks (SOFR for USD, SARON for CHF, ESTR for EUR) typically exceeds 0.85 over rolling 1-year windows, with average deviations of 20 to 50 basis points (Ilmanen, 2011). That deviation is smaller than the broker markup itself, making sovereign yields a practical proxy.
Why not use the overnight rates directly? Most are only available at monthly frequency through FRED on TradingView, with shorter history. Sovereign yields update daily with 10+ years of data. The trade-off is slight imprecision for much better coverage and responsiveness.
The instrument currency is detected automatically through the built-in syminfo.currency variable. When it matches your account currency, the indicator reports zero cost because no foreign exchange borrowing occurs. Currencies whose yield data returns nothing on TradingView are hidden from the chart and dashboard automatically.
The settings panel showing the Carry Model inputs. Account Currency is set to CHF, Yield Maturity to 2Y, Position Size to 100,000, and the broker tier to 0-100k. These four settings control the entire cost calculation.
Reading the carry lines
The main panel draws up to 8 spread lines, one per foreign currency relative to your account currency.
The zero line is the boundary. Everything above it costs you money. Everything below it earns you money. The further a line sits from zero, the larger the financing effect.
For the active instrument pair, a 1-sigma band (252-day rolling mean plus/minus one standard deviation) wraps around the spread. When the current value breaks outside this band, the carry environment is statistically unusual compared to its own recent history. That might mean a central bank shifted rates, or term spreads moved.
Each currency has its own color, chosen to stay distinguishable even under the most common forms of colorblindness:
USD: blue EUR: amber CHF: red GBP: purple
JPY: emerald CAD: orange AUD: cyan NZD: lime
SEK: fuchsia
The historical view with all currency lines visible. Each colored line represents one currency's carry spread against the selected base. Crossing the zero line marks a shift from paying carry to earning it.
The dashboard
The dashboard sits in the corner of the chart (position adjustable) and answers two questions without requiring you to read the lines themselves.
The top section shows the active pair in detail: the raw carry spread in percent, its percentile rank over 2 years (504 trading days), the estimated absolute cost or income for your chosen time horizon and position size, and the break-even return. This is the quick answer to "what is this position costing me right now?"
The bottom section is a comparison table listing every currency with valid data. Each row shows the currency name, its carry spread, its current yield, and the projected cost over your horizon. The instrument currency is marked with a triangle. Rows are color-coded: green for pairs that produce income, red for pairs that cost you money. This answers the follow-up question: "would my carry situation improve if I traded a similar instrument denominated in a different currency?"
The dashboard detail showing the active pair section. CHF to USD carry spread is positive, placing it in the 72nd percentile of its 2-year range. The estimated annual cost for a 100,000 position at the 0-100k broker tier is displayed alongside the break-even return.
The comparison table below the active pair section. All currencies are listed with their individual spreads and estimated costs. JPY shows the largest negative spread (income), while USD shows the highest positive spread (cost) from a CHF base perspective.
Setting it up
The Carry Model group contains the five settings that determine everything:
Account Currency: your brokerage base currency. This is the single most important input. Get this wrong and every number on the screen is meaningless.
Yield Maturity: 2Y sits closer to actual funding costs. 10Y captures term premium effects and is useful for longer-horizon strategic planning.
Position Size: the notional value of your position in the instrument currency. Drives the absolute cost estimate.
Cost Horizon: 1 month, 3 months, 6 months, or 1 year. Controls how far out the projection reaches.
Broker Balance Tier: matches the IB tiered structure. Set to "None" to strip out the broker markup entirely and see the pure yield differential.
The Display group controls background shading (green when earning, red when paying) and whether all currency lines appear or only the detected one.
Eight color themes are available (EdgeTools, Gold, Behavioral, Quant, Ocean, Fire, Matrix, Arctic) with dark and light mode support. Line width and glow effects are adjustable.
Three alert conditions can fire:
Carry spread enters the 90th percentile (historically expensive environment)
Carry spread enters the 10th percentile (historically cheap environment)
Carry spread crosses zero (direction flipped)
Practical examples
Example 1: CHF account trading MES (Micro E-mini S&P 500)
Account currency: CHF. Instrument currency: USD. Assume CH02Y = 0.60%, US02Y = 3.85%.
Carry spread = 3.85 - 0.60 = +3.25%.
Broker markup (0-100k tier) = 1.50%.
Gross carry = 3.25 + 1.50 = 4.75%.
Annual cost on 100,000 USD nominal = 100,000 * 0.0475 * (365/360) = 4,819 USD.
Break-even = 4.75% per year. The S&P 500 must return more than 4.75% annually just to cover carry.
Example 2: USD account buying CSPX (iShares S&P 500 UCITS, EUR-listed)
Account currency: USD. Instrument currency: EUR. Assume US02Y = 3.85%, DE02Y = 2.05%.
Carry spread = 2.05 - 3.85 = -1.80%.
Broker markup = 1.50%.
Gross carry = -1.80 + 1.50 = -0.30%.
Annual income on 100,000 EUR nominal = 100,000 * 0.003 * (365/360) = 304 EUR.
You earn a small amount because USD yields exceed EUR yields by more than the broker markup.
Example 3: EUR account trading Nikkei 225 futures (JPY-denominated)
Account currency: EUR. Instrument currency: JPY. Assume DE02Y = 2.05%, JP02Y = 0.15%.
Carry spread = 0.15 - 2.05 = -1.90%.
Broker markup = 1.50%.
Gross carry = -1.90 + 1.50 = -0.40%.
You earn a small net income because borrowing JPY is cheaper than what your EUR balance yields.
These examples show that the carry direction depends entirely on which currency has the higher rate and how large the broker fee is. Pairs close to zero can flip between cost and income whenever a central bank moves.
Limitations
Sovereign yields are not overnight rates. The 2-year bond yield is a proxy, not the exact benchmark brokers use. Interactive Brokers references SOFR for USD, SARON for CHF, ESTR for EUR, SONIA for GBP. The gap between sovereign 2Y yields and these overnight rates typically sits at 20 to 50 basis points (Ilmanen, 2011, p. 364), occasionally more during yield curve inversions.
The broker cost model is simplified. Real IB interest calculations depend on multi-currency balances across the account, unrealized PnL, margin usage, and the interaction between positive and negative currency positions. The indicator applies a single-tier markup, which captures the dominant cost component but may overstate the net cost for larger accounts earning credit interest on their base currency.
Currency detection relies on syminfo.currency. For most futures, ETFs, and equities on major exchanges, this returns the correct settlement currency. Some synthetic instruments, CFDs, or crypto pairs may return unexpected values. Always verify the detected currency in the dashboard header.
Currencies that consistently lacked yield data on TradingView (such as NOK) have been excluded. Missing data for remaining currencies is handled gracefully and does not produce errors.
The indicator works best on the daily timeframe. Intraday charts display yield data that updates once per day, creating flat segments within the session. This does not affect the accuracy of cost estimates.
References
Ilmanen, A. (2011) Expected returns: an investor's guide to harvesting market rewards. Chichester: John Wiley and Sons.
Interactive Brokers (2024) Interest rates on credit and debit balances. (Web Accessed: May 2026).
ISDA (2006) 2006 ISDA definitions. New York: International Swaps and Derivatives Association.
Koijen, R.S.J., Moskowitz, T.J., Pedersen, L.H. and Vrugt, E.B. (2018) 'Carry', Journal of Financial Economics, 127(2), pp. 197-225.
Stigum, M. and Crescenzi, A. (2007) Stigum's money market. 4th edn. New York: McGraw-Hill.
Script de código aberto
Em verdadeiro espírito do TradingView, o criador deste script o tornou de código aberto, para que os traders possam revisar e verificar sua funcionalidade. Parabéns ao autor! Embora você possa usá-lo gratuitamente, lembre-se de que a republicação do código está sujeita às nossas Regras da Casa.
Where others speculate, we systematize.
edgetools.org
edgetools.org
Aviso legal
As informações e publicações não se destinam a ser, e não constituem, conselhos ou recomendações financeiras, de investimento, comerciais ou de outro tipo fornecidos ou endossados pela TradingView. Leia mais nos Termos de Uso.
Script de código aberto
Em verdadeiro espírito do TradingView, o criador deste script o tornou de código aberto, para que os traders possam revisar e verificar sua funcionalidade. Parabéns ao autor! Embora você possa usá-lo gratuitamente, lembre-se de que a republicação do código está sujeita às nossas Regras da Casa.
Where others speculate, we systematize.
edgetools.org
edgetools.org
Aviso legal
As informações e publicações não se destinam a ser, e não constituem, conselhos ou recomendações financeiras, de investimento, comerciais ou de outro tipo fornecidos ou endossados pela TradingView. Leia mais nos Termos de Uso.