# Stocks Strategy

> Build a TradingView strategy that buys shares on a buy alert and sells them on a sell alert: setup, sizing, exits, how each broker sells, and testing.

*Source: https://tradelabs.org/docs/tradingview/stocks*

A stocks strategy trades shares of the ticker on your chart. It is the simplest TradingView strategy: a buy alert buys, a sell alert sells.

**Brokers:** Interactive Brokers, Tradier, Robinhood and Charles Schwab.

## Build it

1. Create your alert in TradingView and prepare it in the app. [How TradingView Trading Works](/docs/tradingview/) shows how.

2. On **Strategies**, click **New strategy**.

3. In **Signal source**, set **Source** to **TradingView**.

4. In **Basics**, set **Name** to your alert's name, without any `indicator long` or `indicator short` suffix.

5. Set **Instrument** to **Stocks** and choose your broker on the **Brokers** tab.

6. Set **Direction** to **Long** or **Both**.

7. Set **Ticker** to the symbol on your chart, like `AAPL`, or `ALL` to trade whatever the alert sends.

8. Set the size, a stop loss and a take profit (below).

![A TradingView stocks strategy in the editor](/docs-assets/app-tv-stocks-editor.png)
*A stocks strategy with TradingView as its source.*

## Order settings

| Setting | Choose | Why |
| --- | --- | --- |
| Entry | **Market** to fill now, **Limit** to wait for your price | Limit is only offered on brokers that take it. |
| Exit | **Market** | A limit exit that does not fill leaves you in the trade. |
| Time in force | **Day** | An unfilled order is cancelled at the close, not left for tomorrow. |
| Allow extended hours | On, if you trade pre-market or after-hours | IBKR only. Spreads are wider outside regular hours. |

## How much to buy

Under **Sizing**, set **How to pick the trade size** to **Fixed size**, then set **Default quantity** in one of three units.

| Unit | Example | What is bought |
| --- | --- | --- |
| Shares | `10` | 10 shares |
| Dollars | `$500` | As many shares as $500 buys |
| Percent | `5%` | 5% of the account, on IBKR and Tradier |

A sell alert sizes from what is held, not from this setting.

## Getting out

A sell alert is one way out. **Stop loss** and **Take profit** under **Risk management** are the other: they close the position if price gets there first, even with no alert.

> **Heads up**
>
> **How much a sell alert sells depends on the broker.** IBKR sells only the shares this strategy bought. Tradier and Schwab sell the whole position at the broker, including shares you bought yourself. On Robinhood, a share-count size sells up to that many shares, and a dollar size sells everything held. Keep a TradingView stocks strategy in an account you do not trade by hand.

## Short selling

Alerts do not open short positions on IBKR, Tradier or Robinhood. A sell alert with no shares held does nothing. Use **Long** or **Both**. **Short** is not a way to short a stock from TradingView on these brokers.

## Test it

1. Set a small size, like `1` share.

2. Fire the buy alert from TradingView. **Activity** shows the alert, the order and the fill.

3. Fire the sell alert. The shares are sold and the position closes in **Positions**.
