Orders & Indicators
All the ways you can phrase buy/sell orders and the indicators available in your strategies.
Buying
If you don't specify available cash, your portfolio starts with $10,000. You can express a buy in several ways:
| Phrasing | What it does |
|---|
Buy 10 shares of AAPL | Buys exactly 10 shares |
Buy $500 of AAPL | Buys as many shares as $500 allows at current price |
Buy 100% of portfolio in SPY | Invests entire portfolio value into SPY |
Buy 50% of available cash in MSFT | Uses half of remaining cash to buy MSFT |
Buy AAPL | Default: buys as many shares as cash allows |
If you specify a percentage and currently hold 0 shares, it defaults to buying with available cash.
Selling
Sell orders work similarly:
| Phrasing | What it does |
|---|
Sell 10 shares of AAPL | Sells exactly 10 shares |
Sell $500 of AAPL | Sells enough shares to equal ~$500 at current price |
Sell all AAPL | Closes the entire position |
Sell 50% of my AAPL | Sells half the shares you hold |
Sell all | Closes all open positions |
Available Indicators
These indicators can be used as conditions in your strategy. Just reference them by name — no code needed.
Trend
| Indicator | Description | Example usage |
|---|
Simple Moving Average (SMA) | Average closing price over N days | Price above 200-day SMA |
Exponential Moving Average (EMA) | Weighted average favoring recent prices | EMA(50) crosses above EMA(200) |
SMA Crossover | When a fast SMA crosses above/below a slow SMA | 50-day SMA crosses above 200-day SMA |
Momentum
| Indicator | Description | Example usage |
|---|
RSI (Relative Strength Index) | Measures overbought/oversold (0-100) | RSI(14) drops below 30 |
MACD | Trend momentum with signal line crossovers | MACD crosses above signal line |
MACD Histogram | Difference between MACD and signal | MACD histogram turns positive |
Stochastic %K / %D | Momentum oscillator (0-100) | Stochastic %K < 20 |
Volatility
| Indicator | Description | Example usage |
|---|
Bollinger Bands | Price envelope around SMA ± standard deviations | Price touches lower Bollinger Band |
Bollinger Proximity | How close price is to a band (as %) | Within 5% of lower band |
ATR (Average True Range) | Measures daily price volatility | ATR(14) > $5 |
Volume
| Indicator | Description | Example usage |
|---|
Volume vs Average | Compare today's volume to rolling average | Volume is 1.5x the 50-day average |
Volume Surge | Detect unusual volume spikes | Volume is 2x above average on breakout |
Price Action
| Indicator | Description | Example usage |
|---|
Price Change | Percentage move from previous bar | Price drops more than 3% in one day |
52-week High/Low | Distance from yearly extremes | Price within 5% of 52-week high |
Price vs SMA | Whether price is above or below a moving average | Price below 50-day SMA |
Fundamentals
| Indicator | Description | Example usage |
|---|
Gross Margin | Gross profit as % of revenue | Gross margin > 40% |
Operating Margin | Operating income as % of revenue | Operating margin > 15% |
Net Margin | Net income as % of revenue | Net margin improving YoY |
ROE | Return on equity | ROE > 15% |
ROA | Return on assets | ROA > 10% |
ROIC | Return on invested capital | ROIC > 15% |
P/E Ratio | Price to earnings | P/E < 20 |
P/S Ratio | Price to sales | P/S < 1.5 |
P/B Ratio | Price to book value | P/B < 1.5 |
EV/EBITDA | Enterprise value to EBITDA | EV/EBITDA < 10 |
Debt to Equity | Total debt / shareholder equity | Debt/Equity < 0.5 |
Current Ratio | Current assets / current liabilities | Current ratio > 2 |
Free Cash Flow | Cash from operations minus capex | FCF is positive |
Revenue Growth | Year-over-year revenue change | Revenue growth > 10% |
Earnings Growth | Year-over-year net income change | Earnings growth > 15% |
Dividend Yield | Annual dividend / price | Dividend yield > 3% |