How to Analyze BTC/USD on TradingViewTradingView provides a variety of built-in tools and indicators that can help us analyze crypto markets more effectively. Once connected with Alpaca, these tools become part of a seamless workflow for charting and order execution.
Please note we are using BTC/USD as an example and it should not be considered investment advice.
How to connect Alpaca to TradingView account
To begin, link your Alpaca trading account with your TradingView account. You can follow the tutorial below by connecting your Alpaca account to your TradingView account. If you don’t have an Alpaca account but have a TradingView account, you can sign up for an Alpaca account.
Using Trendlines for Bitcoin Analysis
A trendline helps visualize the general direction of price movement. It’s commonly used to identify support and resistance zones in both uptrends and downtrends. The chart below displays BTC/USD price action on a daily timeframe. Two parallel trendlines define a descending price channel, capturing a series of lower highs and lower lows over an extended period. Descending channels like this are commonly used to monitor trend continuation or assess potential breakout scenarios.
Please note that this screenshot is for hypothetical and illustrative purposes only. Past results do not guarantee future returns, and actual results may vary from the analysis.
Bitcoin Analysis with Fibonacci Retracement
Fibonacci retracement is a technical tool used to identify potential support or resistance levels during pullbacks in a trending market. It’s drawn between a recent high and low, marking key levels like 38.2%, 50%, and 61.8% where price may temporarily reverse.
Please note that this screenshot is for hypothetical and illustrative purposes only. Past results do not guarantee future returns, and actual results may vary from the analysis.
Trend-based Fibonacci Extension for BTC/USD
Trend-based Fibonacci Expansion is a tool that projects how far a bullish or bearish trend may extend using Fibonacci ratios. By anchoring to key price points—such as the trend’s start, its initial move, and the corrective leg—it helps estimate future target levels. Traders may use long-term moving averages, like the 35, 50, or 200-period SMA, to validate the broader trend before applying this tool. Common Fibonacci extension levels include 1.0 as a conservative target and 1.618 as a widely used sweet spot for trend continuation.
Please note that this screenshot is for hypothetical and illustrative purposes only. Past results do not guarantee future returns, and actual results may vary from the analysis.
Conclusion
Trading BTC/USD is a popular starting point in cryptocurrency trading due to its liquidity, USD pricing, and readily available analysis tools. Traders may possibly employ various strategies, including day trading, swing trading, and long-term investment, depending on their risk tolerance and time commitment. Platforms like TradingView, integrated with Alpaca, offer robust charting and execution capabilities for both manual and algorithmic trading. Alpaca's Trading API further enables developers to automate strategies, such as bull call spreads.
However, it's crucial to remember that all trading involves risk, and cryptocurrency markets are particularly volatile. Effective risk management, a clear trading plan, and staying informed are essential.
We hope you've found this tutorial on how to trade “BTC/USD” in real-time with Alpaca’s Trading API, dashboard, or TradingView integration insightful and useful for getting started on your own strategy. As we put these concepts into practice, feel free to share your feedback and experiences on our forum, Slack community, or subreddit! And don’t forget to check out the rest of our crypto-trading tutorials.
For those looking to integrate crypto trading with Alpaca’s Trading API, you can find some additional resources on our Profile page.
=====================================================================
Disclosure
Alpaca and TradingView are not affiliated and neither are responsible for the liabilities of the other.
Please note that this article is for general informational purposes only and is believed to be accurate as of the posting date but may be subject to change. The examples above are for illustrative purposes only.
Please note that this article is for general informational purposes only and is believed to be accurate as of the posting date, but may be subject to change. The examples above are for illustrative purposes only. All examples are for illustrative purposes only.
Alpaca does not prepare, edit, or endorse Third Party Content. Alpaca does not guarantee the accuracy, timeliness, completeness or usefulness of Third Party Content, and is not responsible or liable for any content, advertising, products, or other materials on or available from third party sites.
All investments involve risk, and the past performance of a security, or financial product does not guarantee future results or returns. There is no guarantee that any investment strategy will achieve its objectives. Please note that diversification does not ensure a profit, or protect against loss. There is always the potential of losing money when you invest in securities, or other financial products. Investors should consider their investment objectives and risks carefully before investing.
Cryptocurrency is highly speculative in nature, involves a high degree of risks, such as volatile market price swings, market manipulation, flash crashes, and cybersecurity risks. Cryptocurrency regulations are continuously evolving, and it is your responsibility to understand and abide by them. Cryptocurrency trading can lead to large, immediate and permanent loss of financial value. You should have appropriate knowledge and experience before engaging in cryptocurrency trading. For additional information, please click here: files.alpaca.markets .
The Paper Trading API is offered by AlpacaDB, Inc. and does not require real money or permit a user to transact in real securities in the market. Providing use of the Paper Trading API is not an offer or solicitation to buy or sell securities, securities derivative or futures products of any kind, or any type of trading or investment advice, recommendation or strategy, given or in any manner endorsed by AlpacaDB, Inc. or any AlpacaDB, Inc. affiliate and the information made available through the Paper Trading API is not an offer or solicitation of any kind in any jurisdiction where AlpacaDB, Inc. or any AlpacaDB, Inc. affiliate (collectively, “Alpaca”) is not authorized to do business.
Securities brokerage services are provided by Alpaca Securities LLC ("Alpaca Securities"), member FINRA/SIPC, a wholly-owned subsidiary of AlpacaDB, Inc. Technology and services are offered by AlpacaDB, Inc.
Cryptocurrency services are made available by Alpaca Crypto LLC ("Alpaca Crypto"), a FinCEN registered money services business (NMLS # 2160858), and a wholly-owned subsidiary of AlpacaDB, Inc. Alpaca Crypto is not a member of SIPC or FINRA/ . Cryptocurrencies are not stocks and your cryptocurrency investments are not protected by either FDIC or SIPC. Please see the Alpaca Disclosure Library for more information.
This is not an offer, solicitation of an offer, or advice to buy or sell securities or cryptocurrencies or open a brokerage account or cryptocurrency account in any jurisdiction where Alpaca Securities or Alpaca Crypto, respectively, are not registered or licensed, as applicable.
Alpaca is not affiliated with this third-party website, which is not actively monitored by us. We do not review or update content here regularly and are not responsible for user comments or third-party content. For full disclosures, visit: alpaca.markets
Alpaca publications
How to Identify a Head and Shoulders Pattern on TradingViewTo effectively trade the head and shoulders pattern, there are a few factors to consider. If you don’t have an Alpaca account but have a TradingView account, you can sign up for an Alpaca account.
Multiple Time Frame Analysis
Analyze the chart on different time frames—such as 4-hour, daily, and weekly—to get a complete view of the broader trend. If the weekly chart indicates a downtrend while the 4-hour chart shows an uptrend, it may be premature or risky to interpret price action as a head and shoulders pattern. Aligning trends across time frames generally increases the reliability of your findings.
In the image below, using Broadcom, Inc (AVGO) stock chart, the weekly chart shows a well-established uptrend, indicating bullish market sentiment. On the daily chart, an inverse head and shoulders pattern forms along the upward trend line. The 4-hour chart reveals another inverse head and shoulders setup on a smaller scale. Confirming this bullish structure across multiple time frames may increase a traders’ confidence in a continued uptrend, rather than relying on a single chart interval.
NOTE: "AVGO" is used for demonstration purposes and should not be considered investment advice.
Break of Swing High and Swing Low
Pay attention to recent swing points to confirm the pattern. In a standard head and shoulders formation, a decisive break below the neckline (often aligning with a previous swing low) typically validates the pattern. Conversely, in an inverse head and shoulders, a break above the neckline confirms a bullish reversal. Observing retests of the neckline can further strengthen your confirmation and help refine entry or exit points.
Use of Additional Technical Indicators
Supplement your visual analysis with a few simple indicators to strengthen your signal confirmation and filter out false moves:
Moving Averages (MA) : Use simple or exponential moving averages (such as a 20-day EMA and a 50-day SMA) to gauge overall trend direction. A crossover where the short-term MA moves above the long-term MA supports an uptrend, and vice versa.
Bollinger Bands : Look at Bollinger Bands to assess volatility and identify overbought or oversold conditions. If the price approaches or breaks out of these bands, it can signal a potential reversal or continuation, adding context to your swing points.
Moving Average Convergence Divergence (MACD) : Monitor the MACD to spot momentum shifts. If the MACD lines diverge from the price action, it might indicate that a breakout is less reliable.
Attached is an image showing the head and shoulders pattern on AVGO stock with the MACD (12,26) displayed below. The MACD enhances the analysis by confirming momentum: a bullish crossover and expanding histogram support the pattern's validity, while divergence, such as flat or declining momentum despite rising prices, warns of a possible false breakout.
TradingView Implementation: Coding the Head and Shoulders Pattern with Pine Script
TradingView is a widely used platform that offers advanced charting tools and a scripting language called Pine Script. The head and shoulders pattern, being a powerful reversal indicator, can be detected automatically using a custom indicator with a Pine Script.
Let's explore how to implement this using the example:
Setting Up the Detection System
The example Pine Script indicator below automatically highlights both traditional head and shoulders (bearish) and inverse head and shoulders (bullish) patterns on any chart. As shown in the screenshot, the indicator successfully detected inverse head and shoulders patterns on both 4-hour and daily timeframes, coinciding with an uptrend on the weekly chart.
Understanding the Pine Script Code
The script begins by declaring version 6 compatibility and creating an overlay indicator. The leftbars and rightbars parameters allow traders to adjust the sensitivity of the pattern detection—smaller values detect shorter-term patterns while larger values find longer-term formations.
//@version=6
indicator("Head & Shoulders", overlay=true)
// Input parameters
leftbars = input.int(4, title="Left Bars")
rightbars = input.int(4, title="Right Bars")
The core of the detection relies on identifying pivot points—local highs and lows that form the shoulders and head of the pattern.
// Find pivot points
ph = ta.pivothigh(rightbars, leftbars)
pl = ta.pivotlow(rightbars, leftbars)
For the inverse head and shoulders (bullish pattern), the script checks if:
The right shoulder low is higher than the head low (condi1)
The head low is lower than the left shoulder low (condi2)
When both conditions are met, a purple background highlights the pattern.
// Bullish (Inverse) Head and Shoulders pattern detection
condi1 = ta.valuewhen(na(pl) == false, pl, 0) > ta.valuewhen(na(pl ) == false, pl , 0) ? 1 : 0
condi2 = ta.valuewhen(na(pl ) == false, pl , 0) < ta.valuewhen(na(pl ) == false, pl , 2) ? 1 : 0
colorbull = condi1 == 1 and condi2 == 1
Similarly, for the traditional head and shoulders (bearish pattern), the script verifies if:
The right shoulder high is lower than the head high (condi3)
The head high is higher than the left shoulder high (condi4)
When detected, a gold background highlights this bearish pattern.
// Bearish Head and Shoulders pattern detection
condi3 = ta.valuewhen(na(ph) == false, ph, 0) < ta.valuewhen(na(ph ) == false, ph , 0) ? 1 : 0
condi4 = ta.valuewhen(na(ph ) == false, ph , 0) > ta.valuewhen(na(ph ) == false, ph , 2) ? 1 : 0
colorbear = condi3 == 1 and condi4 == 1
Visual Indicators and Alerts
The indicator uses distinct visual cues:
Purple background (#7331FF) with an upward arrow (↗) for bullish patterns
Gold background (#EBC003) with a downward arrow (↘) for bearish patterns
These visual markers make it easy to spot patterns across multiple timeframes, as demonstrated in the screenshot where inverse head and shoulders patterns appear on both 4-hour and daily charts.
// Background colors for pattern visualization
bgcolor(colorbull ? color.new(#7331FF, 50) : na, title="Bullish H&S", offset=-leftbars)
bgcolor(colorbear ? color.new(#EBC003, 50) : na, title="Bearish H&S", offset=-leftbars)
// Alert signals
plotchar(colorbull, title="Bullish H&S", char="↗", location=location.belowbar, color=color.new(#7331FF, 0))
plotchar(colorbear, title="Bearish H&S", char="↘", location=location.abovebar, color=color.new(#EBC003, 0))
Setting Up Trading Alerts
The script includes three alert conditions that can notify traders when:
A bullish (inverse) head and shoulders forms
A bearish head and shoulders forms
Either pattern appears
This allows traders to receive timely notifications without constant chart monitoring.
As seen in the screenshot above, this indicator successfully highlighted multiple inverse head and shoulders patterns that aligned with a broader uptrend, demonstrating its effectiveness as a trend confirmation tool when used across multiple timeframes.
// Alert conditions
alertcondition(colorbull, title="Bullish H&S Detected", message="Bullish Head and Shoulders Pattern Detected")
alertcondition(colorbear, title="Bearish H&S Detected", message="Bearish Head and Shoulders Pattern Detected")
alertcondition(colorbear or colorbull, title="H&S Signal", message="Head and Shoulders Pattern Detected")
The head and shoulders pattern is a fundamental tool in technical analysis, offering insights into potential trend reversals. By understanding its structure, variations, and the context in which it appears, traders can make more informed decisions.
While the pattern often provides valuable signals, it's essential to consider its limitations and corroborate findings with additional technical indicators and thorough analysis. Combining theoretical knowledge with practical application on platforms like TradingView and Alpaca can enhance one's trading strategy and execution.
=====================================================================
Disclosure
Alpaca and TradingView are not affiliated and neither are responsible for the liabilities of the other.
All investments involve risk, and the past performance of a security, or financial product does not guarantee future results or returns. There is no guarantee that any investment strategy will achieve its objectives. Please note that diversification does not ensure a profit, or protect against loss. There is always the potential of losing money when you invest in securities, or other financial products. Investors should consider their investment objectives and risks carefully before investing.
Securities brokerage services are provided by Alpaca Securities LLC ("Alpaca Securities"), member FINRA / SIPC , a wholly-owned subsidiary of AlpacaDB, Inc. Technology and services are offered by AlpacaDB, Inc.
Cryptocurrency services are made available by Alpaca Crypto LLC ("Alpaca Crypto"), a FinCEN registered money services business (NMLS # 2160858), and a wholly-owned subsidiary of AlpacaDB, Inc. Alpaca Crypto is not a member of SIPC or FINRA. Cryptocurrencies are not stocks and your cryptocurrency investments are not protected by either FDIC or SIPC. Please see the Disclosure Library for more information.
Cryptocurrency is highly speculative in nature, involves a high degree of risks, such as volatile market price swings, market manipulation, flash crashes, and cybersecurity risks. Cryptocurrency regulations are continuously evolving, and it is your responsibility to understand and abide by them. Cryptocurrency trading can lead to large, immediate and permanent loss of financial value. You should have appropriate knowledge and experience before engaging in cryptocurrency trading. For additional information, please click here .
This is not an offer, solicitation of an offer, or advice to buy or sell securities or cryptocurrencies or open a brokerage account or cryptocurrency account in any jurisdiction where Alpaca Securities or Alpaca Crypto, respectively, are not registered or licensed, as applicable.
Please note that this article is for general informational purposes only and is believed to be accurate as of the posting date, but may be subject to change. The examples above are for illustrative purposes only. All examples are for illustrative purposes only.
Past hypothetical backtest results do not guarantee future returns, and actual results may vary from the analysis.
The Paper Trading API is offered by AlpacaDB, Inc. and does not require real money or permit a user to transact in real securities in the market. Providing use of the Paper Trading API is not an offer or solicitation to buy or sell securities, securities derivative or futures products of any kind, or any type of trading or investment advice, recommendation or strategy, given or in any manner endorsed by AlpacaDB, Inc. or any AlpacaDB, Inc. affiliate and the information made available through the Paper Trading API is not an offer or solicitation of any kind in any jurisdiction where AlpacaDB, Inc. or any AlpacaDB, Inc. affiliate (collectively, “Alpaca”) is not authorized to do business.
Alpaca is not affiliated with this third-party website, which is not actively monitored by us. We do not review or update content here regularly and are not responsible for user comments or third-party content. For full disclosures, visit: alpaca.markets/disclosures

