Market command
What it does
Section titled “What it does”market executes immediately using market execution.
It is the simplest command type and the best command to start with.
Use TradingView Order Syntax first if you need the full command structure before working through individual command types.
Minimal example
Section titled “Minimal example”ALPHA(BTCUSDT){type=market,side=buy,amount=0.001}Typical fields
Section titled “Typical fields”type=marketside=buyorside=sellamount=...position=...reduceOnly=truetp=...sl=...tag=...
Open a long
Section titled “Open a long”ALPHA(BTCUSDT){type=market,side=buy,amount=0.001}Open a short
Section titled “Open a short”ALPHA(BTCUSDT){type=market,side=sell,amount=0.001}Target a final position
Section titled “Target a final position”ALPHA(BTCUSDT){type=market,position=0.003}This is different from amount=0.003.
It means the app resolves the current position first, then sends only the difference needed to reach 0.003.
Flatten the position
Section titled “Flatten the position”ALPHA(BTCUSDT){type=market,position=0}This is the cleanest flatten pattern.
Reduce current position
Section titled “Reduce current position”ALPHA(BTCUSDT){type=market,side=sell,amount=50%p,reduceOnly=true}Close current position using current position size
Section titled “Close current position using current position size”ALPHA(BTCUSDT){type=market,side=sell,amount=100%p,reduceOnly=true}Market with TP and SL
Section titled “Market with TP and SL”ALPHA(BTCUSDT){type=market,side=buy,amount=0.001,tp=1%,sl=0.5%}You can also use entry-relative forms:
ALPHA(BTCUSDT){type=market,side=buy,amount=0.001,tp=e1%,sl=e-0.5%}When to use amount vs position
Section titled “When to use amount vs position”Use amount when you want an order quantity.
Use position when you want a final target position size.
Common mistakes
Section titled “Common mistakes”Using reduceOnly=true on an entry command
Section titled “Using reduceOnly=true on an entry command”That can prevent the order from opening a new position.
Using side and position without understanding the difference
Section titled “Using side and position without understanding the difference”position determines the final target state.
Using a quantity that resolves below exchange minimums
Section titled “Using a quantity that resolves below exchange minimums”The exchange can reject the final order even if your syntax is valid.