Selective TradingView stock signals routed to Alpaca

Automating a 117% TradingView Stock Strategy on Alpaca

RSI raises the distress signal when a stock becomes oversold. The strategy does not buy immediately. It keeps that event in memory and waits for MACD to confirm that the sell-off has started losing control.

Strategy type MACD and RSI recovery
Market tested NASDAQ stock
Timeframe 15 minutes
Destination Alpaca paper account

A large historical return can make a strategy look fast and aggressive. This one is unusual because the chart uses 15-minute candles while the entry filter remains extremely selective.

The MACD Bull Crossover and RSI Oversold 5 Candles Ago Strategy was published by Trebor_Namor as a stock strategy combining a remembered RSI extreme with a later MACD momentum crossover.

This experiment applies the current strategy version to eBay Inc. on NASDAQ using 15-minute regular-session candles. TradingView calculates the strategy, while AlgoWay routes its orders to an Alpaca Demo account.

EBAY is the instrument used to document the test. The broader purpose of the page is to explain how a TradingView stock strategy can be researched and automated through Alpaca.

RSI records the damage before MACD confirms the recovery

RSI Length 14 measures the balance between recent upward and downward closing movement. The oversold threshold is set to 30, while the overbought threshold is set to 70.

An oversold RSI reading does not automatically create a long order. A stock can remain oversold while price continues falling.

Instead, the strategy remembers that the oversold event occurred and waits for MACD to cross above its signal line.

RSI is the distress flare; MACD is the recovery clearance.

The flare identifies that selling pressure became unusually strong. The strategy then waits for the MACD crossover to indicate that short-term momentum has started moving in the opposite direction.

This delayed handoff is mechanically important. The system is not buying simply because a stock looks cheap relative to its recent movement. It waits for a second indicator to confirm that the recovery process has begun.

The MACD settings deliberately separate fast and slow momentum

MACD Fast Length 9
MACD Slow Length 55
MACD Signal Length 17
RSI Length 14
RSI Oversold 30
RSI Overbought 70

The fast MACD component uses nine candles, while the slow component uses fifty-five. This creates a large separation between recent momentum and the slower baseline.

The signal line uses seventeen periods. A bullish crossover therefore requires the fast and slow momentum relationship to improve enough to cross its own smoothed reference.

The result is a two-stage recovery detector: RSI identifies the earlier extreme, while MACD decides whether the subsequent rebound is strong enough to become a strategy order.

The current configuration enables both market directions

The current strategy panel shows both Enable Long Strategy and Enable Short Strategy selected.

Long branch

The public strategy description explains the long entry as a bullish MACD crossover following a recently oversold RSI condition.

Short branch

The current script includes a bearish branch and produces short orders on the chart. The protected source prevents the current short logic from being independently audited line by line.

One combined report

The 117.20% result includes the enabled long and short branches. Turning either direction off creates a different backtest.

Short stock execution also has broker-side requirements. A valid TradingView short signal does not guarantee that Alpaca will accept the short order for every stock or account.

The optional EMA lines are not strategy filters

The input panel offers EMA periods of 9, 21, 50, 100 and 200. All five switches are disabled in this test.

The strategy author states that these EMA lines are chart-display tools and do not change the strategy logic.

A visible line is not automatically part of the decision engine.

Enabling an EMA can help a trader inspect trend context, but it does not add an EMA condition to the MACD and RSI order logic.

This distinction is useful when reproducing a backtest. Visual settings can change what the chart looks like without changing the trades.

Fifteen-minute candles do not make this a scalping system

A 15-minute timeframe is normally associated with intraday or day trading. It can react several times during a normal US stock session and is much faster than a four-hour or daily chart.

Signal frequency tells a different story here. The test completed 57 trades across 569 calendar days, averaging approximately three completed trades per month.

Not conventional scalping

A scalping system normally expects frequent entries and short holding periods. This strategy waits for an RSI extreme and a later MACD confirmation.

Selective intraday trading

Signals are calculated from 15-minute candles, but several weeks can pass with only a small number of completed trades.

Possible swing overlap

The strategy does not include a mandatory end-of-session exit. A position can remain active until its later exit condition or protective boundary is reached.

Automation is still useful even when signals are infrequent. It removes the need to watch every 15-minute candle while waiting for the two-stage setup.

The 50% protective levels require careful interpretation

Long Stop Loss 50%
Long Take Profit 50%
Short Stop Loss 50%
Short Take Profit 50%

A 50% price movement is an extremely wide boundary for an individual US stock. These values should not be treated as ordinary account risk controls merely because they appear inside the strategy settings.

With boundaries this distant, many positions may close from the strategy's MACD and RSI reversal logic before the percentage stop or target is reached.

A 50% strategy stop does not mean the account risks only a safe amount.

Account risk depends on position size, entry price, available equity and the actual distance to the stop. A distant stop can expose a large portion of the account even when only one stock is traded.

Before live use, inspect the TradingView trade list and identify which exits came from reversal logic, stop loss and take profit.

The 117% return came with a 29.90% drawdown

The historical Strategy Tester period runs from January 2, 2025 through July 24, 2026. Initial capital is 100,000 USD, order size is 10% of equity, and script execution occurs on the completed candle.

Total P&L +117,195.52 USD +117.20%
Maximum drawdown 79,871.74 USD 29.90%
Profitable trades 42 of 57 73.68%
Profit factor 1.928 Historical simulation

Forty-two of the fifty-seven recorded trades were profitable. Fifteen were unprofitable.

A profit factor of 1.928 means recorded gross profit was approximately 1.93 times recorded gross loss during the sample.

The total return more than doubled the starting capital, but maximum drawdown reached nearly thirty percent.

The equity curve paid a high price for the headline return.

A trader beginning near the wrong part of the historical sequence could have experienced a substantial decline before the strategy recovered.

The return, win rate and drawdown must therefore be evaluated together. The backtest is impressive, but it is not a low-volatility result.

Historical optimization is not live machine learning

The author reports using Python and Freqtrade to optimize strategy parameters across three years of data from eighty stocks.

That process searches historical combinations for settings that performed well. It does not mean the TradingView script continuously learns from live EBAY candles or automatically adapts when the market regime changes.

Optimization can improve a backtest and also increase overfitting risk.

A parameter combination that performed well across historical stocks can behave differently on another stock, another period or another data feed.

Forward testing in an Alpaca paper account is therefore a necessary next stage, not a ceremonial final check.

Creating the Alpaca paper execution route

Generate a dedicated Alpaca paper API key pair. Paper and live accounts use different credentials, so the selected AlgoWay API Mode must match the keys.

Open Dashboard >> Trade Webhooks and create a route with TradingView as the source and Alpaca as the destination.

Webhook field Recorded setup Purpose
Platform Alpaca Selects the Alpaca Trading API route.
API Mode Demo Routes orders to the Alpaca paper environment.
API Key Your paper API key Identifies the selected Alpaca paper account.
API Secret Your paper API secret Authenticates the order request.
Quantity Multiplier Absolute 1 Passes the TradingView strategy quantity without scaling it.
Symbol Mapping Empty unless required Translates a TradingView ticker when Alpaca expects another form.
News Filter No Does not block stock orders around configured news events.

The complete setup is documented in TradingView Alerts to Alpaca Webhook Automation with AlgoWay .

A paper order tests the route before the strategy controls it

Open Dashboard >> Webhook Logs, select Test Webhook and choose the Alpaca Demo route.

Enter a supported stock ticker and use one share or another deliberately small test quantity.

The paper test verifies execution, not profitability.

It confirms the API environment, credentials, symbol, quantity and Alpaca response. It does not calculate RSI, MACD or the five-candle memory rule.

Test buy, close and short behaviour separately. A paper environment can simulate short selling, but every live stock still needs to satisfy actual account and shortability requirements.

The TradingView alert carries the final stock position state

Return to the 15-minute stock chart and confirm the RSI and MACD inputs. Create an alert from the strategy order fills and paste this one-line JSON:

{"platform_name":"alpaca","ticker":"{{ticker}}","order_contracts":"{{strategy.order.contracts}}","order_action":"{{strategy.market_position}}","price":{{close}}}
{{ticker}}

Inserts the stock symbol from the TradingView chart.

{{strategy.order.contracts}}

Inserts the share quantity calculated for the executed TradingView strategy order.

{{strategy.market_position}}

Inserts the resulting long, short or flat strategy state.

{{close}}

Inserts the TradingView close available when the alert fires. The eventual Alpaca fill price can differ.

Open Notifications, enable Webhook URL and paste the private URL generated by the AlgoWay Alpaca webhook.

TradingView stores a server-side copy of the strategy when the alert is created. After changing the RSI thresholds, MACD periods, enabled directions or Strategy Properties, delete the old alert and create it again.

The first autonomous stock trade needs three matching records

  1. Check the completed TradingView order. Confirm the stock ticker, long or short direction and calculated quantity.
  2. Read AlgoWay Webhook Logs. Confirm the received placeholders and the complete Alpaca response.
  3. Inspect the Alpaca paper account. Confirm the symbol, accepted share quantity, position direction and fill.

Paper trading is valuable because it exposes rejected symbols, incorrect quantities, short-sale restrictions and alert mistakes without risking live capital.

It still cannot reproduce every feature of live order execution. The paper result should be treated as a technical test rather than proof that the historical equity curve will continue.

The complete stock automation path

What this Alpaca stock experiment establishes

RSI identifies that a stock recently experienced an extreme movement. MACD waits for momentum to begin recovering before the strategy commits to the next order.

Across the recorded period, the configuration completed 57 trades and produced 117,195.52 USD in simulated profit with a 73.68% win rate and profit factor of 1.928.

The same test reached a 29.90% maximum drawdown. The headline return therefore came from a substantially volatile equity path rather than a smooth low-risk progression.

AlgoWay connects the completed TradingView stock state to an Alpaca paper or live account using API credentials, a private webhook URL and dynamic strategy placeholders.

The 15-minute chart does not make the system a high-frequency scalper. Its multi-stage filter produced only about three completed trades per month, making patience and reliable unattended execution part of the strategy itself.

Original strategy: MACD Bull Crossover and RSI Oversold 5 Candles Ago Strategy . Alpaca connection manual: TradingView Alerts to Alpaca Webhook Automation .

Direct answers

Direct answers about TradingView stock automation on Alpaca

Can a TradingView stock strategy be automated on Alpaca?

Yes. TradingView can send strategy order alerts to an AlgoWay webhook. AlgoWay validates the stock ticker, strategy quantity and position state before routing the corresponding order to an Alpaca paper or live account.

Which indicators does this stock strategy use?

The strategy combines RSI and MACD. RSI records that the stock recently reached an oversold or overbought condition, while a later MACD crossover confirms that momentum has changed.

Which settings produced the recorded stock backtest?

The visible configuration used RSI Length 14, oversold level 30, overbought level 70 and MACD periods 9, 55 and 17 on a 15-minute NASDAQ stock chart.

What does five candles ago mean in this strategy?

The strategy does not require RSI to remain oversold at the moment of the MACD bullish crossover. It remembers the earlier oversold condition and waits for momentum to begin recovering before entering.

Is this a stock scalping strategy?

Not in practical signal frequency. Although it uses 15-minute candles, the backtest completed only 57 trades in approximately nineteen months. It behaves more like selective intraday trading with possible overlap into short swing trading.

Do the optional EMA settings affect the strategy?

No. The strategy author states that the optional EMA lines are visual chart aids and do not affect the entry or exit logic. All five EMA switches were disabled in this test.

What do the 50 percent stop loss and take profit values mean?

Both long and short branches show 50 percent stop-loss and take-profit values. These are very distant protective levels for an individual stock and should not be confused with ordinary risk limits suitable for every account.

Can the short branch always open an Alpaca stock short?

No. A short instruction also depends on the account permissions, available equity and whether the selected stock is currently shortable. Test the complete short workflow in Alpaca paper mode before considering live execution.

Should the final alert use a fixed number of shares?

No. A fixed small quantity is useful for the initial connection test. The final strategy alert should use {{strategy.order.contracts}} so TradingView supplies the quantity associated with the executed strategy order.

What historical results did the stock test produce?

From January 2, 2025 through July 24, 2026, the TradingView simulation produced 117,195.52 USD in total profit, a profit factor of 1.928, 42 profitable trades out of 57 and maximum drawdown of 79,871.74 USD.

Historical backtest and risk notice

Test the strategy independently before using it

This page documents a historical TradingView backtest covering through . The reported results are simulated and depend on the selected symbol, data provider, timeframe, strategy settings, position-sizing rules, trading costs and execution assumptions. Market conditions, broker feeds and strategy performance may be different by the time you read this page.

This material is provided for research and technical demonstration only. It is not investment advice, a recommendation, or an invitation to begin using the strategy. Historical performance does not guarantee future results. AlgoWay accepts no responsibility for trading decisions or losses resulting from the use of this information.

Run your own backtest on the intended symbol, provider and timeframe using realistic spread, commission and slippage. After that, verify the complete alert, webhook, symbol, quantity and execution workflow on a demo account before considering any live trading.