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:

PhrasingWhat it does
Buy 10 shares of AAPLBuys exactly 10 shares
Buy $500 of AAPLBuys as many shares as $500 allows at current price
Buy 100% of portfolio in SPYInvests entire portfolio value into SPY
Buy 50% of available cash in MSFTUses half of remaining cash to buy MSFT
Buy AAPLDefault: 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:

PhrasingWhat it does
Sell 10 shares of AAPLSells exactly 10 shares
Sell $500 of AAPLSells enough shares to equal ~$500 at current price
Sell all AAPLCloses the entire position
Sell 50% of my AAPLSells half the shares you hold
Sell allCloses all open positions

Available Indicators

These indicators can be used as conditions in your strategy. Just reference them by name — no code needed.

Trend

IndicatorDescriptionExample usage
Simple Moving Average (SMA)Average closing price over N daysPrice above 200-day SMA
Exponential Moving Average (EMA)Weighted average favoring recent pricesEMA(50) crosses above EMA(200)
SMA CrossoverWhen a fast SMA crosses above/below a slow SMA50-day SMA crosses above 200-day SMA

Momentum

IndicatorDescriptionExample usage
RSI (Relative Strength Index)Measures overbought/oversold (0-100)RSI(14) drops below 30
MACDTrend momentum with signal line crossoversMACD crosses above signal line
MACD HistogramDifference between MACD and signalMACD histogram turns positive
Stochastic %K / %DMomentum oscillator (0-100)Stochastic %K < 20

Volatility

IndicatorDescriptionExample usage
Bollinger BandsPrice envelope around SMA ± standard deviationsPrice touches lower Bollinger Band
Bollinger ProximityHow close price is to a band (as %)Within 5% of lower band
ATR (Average True Range)Measures daily price volatilityATR(14) > $5

Volume

IndicatorDescriptionExample usage
Volume vs AverageCompare today's volume to rolling averageVolume is 1.5x the 50-day average
Volume SurgeDetect unusual volume spikesVolume is 2x above average on breakout

Price Action

IndicatorDescriptionExample usage
Price ChangePercentage move from previous barPrice drops more than 3% in one day
52-week High/LowDistance from yearly extremesPrice within 5% of 52-week high
Price vs SMAWhether price is above or below a moving averagePrice below 50-day SMA

Fundamentals

IndicatorDescriptionExample usage
Gross MarginGross profit as % of revenueGross margin > 40%
Operating MarginOperating income as % of revenueOperating margin > 15%
Net MarginNet income as % of revenueNet margin improving YoY
ROEReturn on equityROE > 15%
ROAReturn on assetsROA > 10%
ROICReturn on invested capitalROIC > 15%
P/E RatioPrice to earningsP/E < 20
P/S RatioPrice to salesP/S < 1.5
P/B RatioPrice to book valueP/B < 1.5
EV/EBITDAEnterprise value to EBITDAEV/EBITDA < 10
Debt to EquityTotal debt / shareholder equityDebt/Equity < 0.5
Current RatioCurrent assets / current liabilitiesCurrent ratio > 2
Free Cash FlowCash from operations minus capexFCF is positive
Revenue GrowthYear-over-year revenue changeRevenue growth > 10%
Earnings GrowthYear-over-year net income changeEarnings growth > 15%
Dividend YieldAnnual dividend / priceDividend yield > 3%
← Writing StrategiesNext: Backtestable Properties →