{{strategy.market_position}} and {{strategy.market_position_size}} sit side by side among TradingView’s 11 strategy placeholders, and they look like two answers to the same question. They aren’t.
Table of Contents
- What does {{strategy.market_position}} return, and when?
- What does {{strategy.market_position_size}} return?
- Two lookalikes: position_size and order.contracts
- One strategy, five fills: what each placeholder sends
- Why are market_position and market_position_size a pair?
- Which pair does your strategy type need?
- Continuous strategies: the position pair
- Flat-to-flat strategies: the position pair, if anything else exits
- Partial exits and pyramiding: the order pair
- What if a scaling strategy can also be closed from outside?
- Mixing the pairs: two one-field mistakes
- Mix 1: market_position_size in an order-pair alert
- Mix 2: market_position with the default flags
- The exit trap: market_position_size reads 0 on every full exit
- Set up each pair in PickMyTrade
- Test the pair on a demo before it trades real money
- Frequently asked questions
- Before you save the alert
The first sends a word: long, short or flat. The second sends a number, the absolute size of the position. Both describe the strategy after the order has filled, which is why one of them reads 0 on every full exit.
So the title’s question has a short answer. Your alert doesn’t pick one of them. It picks a pair. PickMyTrade’s data field can carry an order (buy or sell) or a target position (long, short or flat), and each of those vocabularies comes with its own size placeholder.
Below, one strategy runs through five fills: enter, add, scale out, reverse and exit. You’ll see what each placeholder sends at every step, what PickMyTrade does with both pairs, and how the two most common one-field edits break an account. For every other strategy placeholder, see the full list of TradingView strategy placeholders.
Key Takeaways
{{strategy.market_position}}sendslong,shortorflat.{{strategy.market_position_size}}sends the size after the fill, so every full exit reads0.- They form one pair: the word goes in
data, the number inquantity.- In our five-fill walkthrough, one common mix-up leaves the account wrong after 4 of 5 fills.
- Scale-in and scale-out strategies need the order pair instead.
The order pair is {{strategy.order.action}} in data plus {{strategy.order.contracts}} in quantity, and it tells PickMyTrade which trade to place. The position pair is {{strategy.market_position}} in data plus {{strategy.market_position_size}} in quantity, and it tells PickMyTrade where the position should end up.
Haven’t built a strategy alert before? TradingView’s own tutorial shows where alerts get created, including alerts on indicators and strategies.
What does {{strategy.market_position}} return, and when?
{{strategy.market_position}} returns one of 3 words: long, short or flat. TradingView sets it at the moment an order fills, so the word describes the position after that order. A full exit therefore sends flat, and a flip from long sends short.
{{strategy.market_position}} is a text placeholder that only resolves in alerts created from a strategy’s order fills. It never carries the side of the order. That’s what sets it apart from {{strategy.order.action}}, which reports every order as buy or sell.
Why does that matter? A sell can mean three things. It can close a long, open a short, or do both at once when the strategy reverses. The position word skips the guessing, because it names the result.
You can see the timing in any alert log. An alert whose message is {{strategy.order.action}} {{strategy.position_size}} logs buy 1 when a 1-contract long entry fills from flat. A value from before the fill would have logged buy 0.
Need the state from before the fill? That’s {{strategy.prev_market_position}}, which sends the same three words for the position the order started from. Read the two together and most fills label themselves: flat to long is an entry, long to flat is an exit, and long to short is a reversal. long to long could be an add or a scale-out, and only the sizes tell those two apart.
In PickMyTrade, the word goes in the data field. The strategy automation guide explains the switch in two lines: {{strategy.order.action}} tells it what trade to place, while {{strategy.market_position}} tells it what the final position should be. In practice, long works as a buy, short as a sell and flat as a close.
What does {{strategy.market_position_size}} return?
{{strategy.market_position_size}} returns the position’s size after the fill as an absolute number, so it’s never negative. A 3-contract short reads 3. Any fill that leaves the strategy flat reads 0, which matters the moment you put it in a close alert.
{{strategy.market_position_size}} is the numeric half of the position pair. It shares the word’s timing, and the two always agree: flat arrives with 0, while long or short arrives with a positive size. What it can’t tell you is how many contracts the last order moved.
So which placeholder does know the order’s size? Two others describe a size, and both are easy to mix up with this one.
Two lookalikes: position_size and order.contracts
{{strategy.position_size}} carries the same number with a sign attached. Long 3 reads 3 and short 3 reads -3. That sign helps in a log and hurts in a quantity field, since no broker takes an order for minus three contracts.
{{strategy.order.contracts}} is the size of the order that just filled. On a first entry from flat it equals {{strategy.market_position_size}}, and that coincidence is why a swapped placeholder passes a quick test. The two split apart on the first add, scale-out, reversal or exit.
Here’s how the six position and order placeholders read on a short entry from flat, and on the exit that closes it:
| Placeholder | What it returns | Short entry (flat to short 3) | Exit (short 3 to flat) | PickMyTrade field |
|---|---|---|---|---|
{{strategy.market_position}} | Position word after the fill | short | flat | data, position pair |
{{strategy.market_position_size}} | Absolute size after the fill | 3 | 0 | quantity, position pair |
{{strategy.position_size}} | Signed size after the fill | -3 | 0 | Neither field |
{{strategy.prev_market_position_size}} | Absolute size before the fill | 0 | 3 | Logs only |
{{strategy.order.contracts}} | Size of the order that filled | 3 | 3 | quantity, order pair |
{{strategy.order.action}} | Side of the order that filled | sell | buy | data, order pair |
Read down the exit column and the pattern is plain. Only {{strategy.order.contracts}} and {{strategy.prev_market_position_size}} still carry the size that just closed, and {{strategy.order.contracts}} is the one PickMyTrade’s default template puts in quantity.
One strategy, five fills: what each placeholder sends
Across the five fills below, {{strategy.market_position_size}} and {{strategy.order.contracts}} agree only twice. The strategy trades 1 contract per entry with pyramiding = 2, so it can add once. It enters long, adds, scales out, reverses to short and exits, and every value in the table is what TradingView sends at that fill. Headers drop the strategy. prefix to fit.
| Fill | Pine call | order.action | order.contracts | market_position | market_position_size | prev_market_position_size |
|---|---|---|---|---|---|---|
| 1. Enter | strategy.entry("Long1", strategy.long) | buy | 1 | long | 1 | 0 |
| 2. Add | strategy.entry("Long2", strategy.long) | buy | 1 | long | 2 | 1 |
| 3. Scale out | strategy.close("Long2") | sell | 1 | long | 1 | 2 |
| 4. Reverse | strategy.entry("Short", strategy.short) | sell | 2 | short | 1 | 1 |
| 5. Exit | strategy.close("Short") | buy | 1 | flat | 0 | 1 |
Which fill deserves the closest look? Fill 4.
When strategy.entry() fires against an open position in the other direction, TradingView adds the open size to the new order, so a single sell 2 closes the long and opens the short. The order says 2, the position says 1, and both are right, because they answer different questions.
What about fill 3? It’s the sneaky one. The strategy just sold a contract, yet the position word still reads long. Nothing in the position pair says a sale happened. It only names the target: long 1.
Order placeholders describe the change, and position placeholders describe the result. A pair only works when both of its halves describe the same thing: two changes, or two results.
Why are market_position and market_position_size a pair?
In PickMyTrade, data takes 2 vocabularies, and each needs its own size. With buy or sell, the alert is an order, so quantity has to be the order’s size. With long, short or flat, the alert is a target, so quantity has to be the target’s size. That leaves 2 valid pairs, not 4 combinations.
The order pair is what PickMyTrade’s Generate Alert tool writes for a strategy. Its JSON alert reference sets data to {{strategy.order.action}} and quantity to {{strategy.order.contracts}}, with pyramid on and reverse_order_close off. Each alert becomes one order that nets against the account, much like a trader clicking buy or sell.
The position pair works more like cruise control. You set the speed and the car works out the throttle. PickMyTrade’s Rithmic JSON guide uses it as the strategy template, with pyramid off and reverse_order_close on. Under the documented flag rules, every alert closes what’s open and reopens at the target, unless the target is flat.
Why do the flags have to change with the pair?
With reverse_order_close on, PickMyTrade closes an opposite position before placing the new trade, so a sell that was meant as an exit comes out as a reversal instead. That’s why PickMyTrade’s FAQ steers strategy alerts away from the flag. The position pair is the exception. Its exits arrive as flat, and flat only closes.
We analyzed every PickMyTrade doc page that mentions these placeholders, and only one of the five, the Rithmic guide, puts {{strategy.market_position_size}} in quantity. The limit-order guide keeps the position word but requires a fixed quantity. The multiple TP/SL workaround needs one too, because its exit legs have to add up to it.
Which pair does your strategy type need?
Strategies come in 3 types in PickMyTrade’s strategy guide: continuous, flat and partial exit. The type decides the pair. Continuous and flat strategies gain the most from the position pair, because it repairs a drifted account on the next alert. Partial-exit strategies belong on the order pair, because the position pair rebuilds the whole position on every step.
Continuous strategies: the position pair
A continuous strategy is always in the market and flips on every signal. On the order pair, each flip arrives as one netted order at twice the size, such as sell 2 to go from long 1 to short 1. That works for as long as the account matches the chart.
But what if a broker-side stop loss closed the long an hour earlier? The same sell 2 hits a flat account and opens short 2, double what the strategy meant. A prop firm’s daily-loss liquidation or end-of-day flatten causes the same drift, because TradingView never hears about it.
The position pair sends short 1 instead. PickMyTrade closes whatever is open, which here is nothing, then sells 1. The account lands on short 1 either way, and a normal flip still costs the same 2 contracts as the netted order.
Flat-to-flat strategies: the position pair, if anything else exits
A flat strategy enters, exits completely and waits. Both pairs trade the same contracts here, 1 in and 1 out. The difference only shows after an outside exit, when an auto trail or a take-profit closes the trade before the strategy does.
The strategy’s own exit still fires later. On the order pair it sends sell 1 to a flat account and opens a short nobody asked for. On the position pair it sends flat, and there’s nothing left to close.
What if only the strategy ever exits? Then either pair works, and the default order pair is the simpler one.
Partial exits and pyramiding: the order pair
Scaling is where the position pair gets expensive. With pyramid off and reverse_order_close on, PickMyTrade closes the open position before every new signal, same side included. A scale-out from long 2 to long 1 therefore closes 2 contracts and buys 1 back. The end state is right, but it costs 3 contracts instead of 1, and the account sits flat between the two orders.
From our analysis of the flag rules, a strategy that scales in to 3 and back out trades 6 contracts on the order pair and 18 on the position pair. PickMyTrade’s strategy guide also lists broker-side TP and SL as unsupported for partial-exit strategies. So the outside exits that justify the position pair mostly can’t happen on a scaling strategy anyway.
What if a scaling strategy can also be closed from outside?
Then each pair has a cost. The position pair re-syncs the account but rebuilds the position on every step. The order pair stays cheap, yet after a prop firm’s auto-flatten or a manual close it’s out of sync, and the next scale-out sells into a flat account.
For most scaling strategies, keep the order pair and turn the final exit into a close. Set data to {{strategy.order.alert_message}} and give every order call an alert_message of buy, sell or close. Our TradingView placeholder guide walks through the pattern.
Under PickMyTrade’s close alert rules, a close never opens a position, so a late final exit on a flat account does no harm. Partial exits get no such guard, because the comment-based partial close works with indicator alerts only. After an outside exit, pause the alert until the strategy is flat again, then switch it back on.
Mixing the pairs: two one-field mistakes
Mixing the halves breaks an account quietly. We walked the five fills through the two most likely one-field edits of the default template. One left the account wrong after 4 of 5 fills and still long once the strategy was flat. The other turned a scale-out into a buy.
Mix 1: market_position_size in an order-pair alert
Keep {{strategy.order.action}} in data, swap quantity to {{strategy.market_position_size}}, and every alert sends the position total as if it were the order. Fill 2 buys 2 instead of 1, so the account holds 3. Fill 3 sells 1 and leaves 2.
Fill 4 sells 1 rather than 2, which keeps the account long while the strategy is short. Fill 5 sends a buy for 0 contracts. A zero-size order can’t reduce anything, so the account sits long 1 while the chart shows flat.
Mix 2: market_position with the default flags
Now make the opposite edit. The strategy guide calls the position word an optional change, and it’s tempting to swap data and stop there. With the default pyramid: true and reverse_order_close: false still in place, long behaves like a buy and short like a sell.
Fill 3 pays for it. The strategy sold a contract, the alert said long with an order size of 1, and the account bought another, ending at long 3 against the strategy’s 1. Fill 4 then sells 2 and leaves the account long 1 when it should be short.
Would a quick test catch either mistake? We found the same blind spot in both mixes: fill 1 looks perfect, because from flat the order size and the position size are equal. A single test entry can’t expose them, which is why the demo test further down runs all five fills.
The exit trap: market_position_size reads 0 on every full exit
On a full exit, {{strategy.market_position_size}} reads 0 every time. It’s tempting to use it in close alerts, so the alert closes whatever the strategy holds. By the time the placeholder resolves, the strategy holds nothing. The number you actually want is the size before the fill.
So where does the closed size live? Two placeholders carry it. {{strategy.prev_market_position_size}} is the size before the fill, which on a full exit is the whole position. {{strategy.order.contracts}} is the size of the exit order, and it matches unless the exit also reversed.

Does that zero hurt inside PickMyTrade? Mostly, no. Its close alert closes open positions and cancels open orders whatever the quantity says. The Rithmic position template even sends that 0 on every exit, because flat ignores the size. The zero bites when the number feeds something that trusts it, such as a sizing formula, a trade log or a second webhook receiver.
Quick check: Put
{{strategy.prev_market_position}} {{strategy.prev_market_position_size}} -> {{strategy.market_position}} {{strategy.market_position_size}}in a test alert’s message. A full exit from a 2-contract long logslong 2 -> flat 0.
Set up each pair in PickMyTrade
Switching pairs means editing 4 fields. Generate a strategy alert as usual, then change data, quantity, pyramid and reverse_order_close together. Leave every other field as generated. Changing only one or two of them is exactly how the mixed setups above happen.
| Field | Order pair (default) | Position pair |
|---|---|---|
data | {{strategy.order.action}} | {{strategy.market_position}} |
quantity | {{strategy.order.contracts}} | {{strategy.market_position_size}} |
pyramid | true | false |
reverse_order_close | false | true |
The position pair’s four lines look like this:
"data": "{{strategy.market_position}}",
"quantity": "{{strategy.market_position_size}}",
"pyramid": false,
"reverse_order_close": true,Leave same_direction_ignore set to false on the position pair. When it’s true, PickMyTrade ignores alerts on the side you already hold, and on this pair those alerts are your adds and scale-outs. The TradingView webhook alert field reference covers the rest of the payload field by field.
Test the pair on a demo before it trades real money
How long does a proper test take? About six minutes on a 1-minute chart. This Pine script places the same five orders as the walkthrough, one per bar, starting on the first live bar after you create the alert:
//@version=6
strategy("Five-fill alert test", overlay = true, pyramiding = 2, default_qty_type = strategy.fixed, default_qty_value = 1)
var int step = 0
if barstate.isrealtime
step += 1
switch step
1 => strategy.entry("Long1", strategy.long)
2 => strategy.entry("Long2", strategy.long)
3 => strategy.close("Long2")
4 => strategy.entry("Short", strategy.short)
5 => strategy.close("Short")Then run it against a demo account, the same way our Tradovate demo trading test plan checks every alert before real money. Create an alert on the script with the “Order fills only” condition, the PickMyTrade webhook URL and your edited JSON, then check three things:
| Check | What a pass looks like |
|---|---|
| All 5 fills | The demo position matches the strategy’s after every fill |
| A hand close after fill 2 | On fill 3 the position pair comes back to long 1, while the order pair sells into a flat account |
| Order history | The position pair shows extra contracts on the add and the scale-out |
Generating the alert itself takes a few clicks, and this PickMyTrade walkthrough shows each one.
PickMyTrade runs both pairs on Tradovate and Rithmic accounts for $50 a month, with a 7-day free trial and no credit card. Compare the plans, read who runs PickMyTrade, or contact the PickMyTrade team if you’d like a second look at your JSON.
Frequently asked questions
One of 3 words: long, short or flat. It describes the strategy’s position after the order that triggered the alert filled, so an exit sends flat and a reversal sends the new side. Its twin, {{strategy.prev_market_position}}, sends the word from before the fill.
No. It’s the absolute size after the fill, so a 3-contract short reads 3 and any exit that leaves the strategy flat reads 0. When you need the sign, {{strategy.position_size}} reads -3 for that same short, though a signed number doesn’t belong in a quantity field.
Match it to data. With {{strategy.order.action}} in data, use {{strategy.order.contracts}}, the size of the order that filled. With {{strategy.market_position}}, use {{strategy.market_position_size}}, the size to end at. In our five-fill walkthrough, one mixed setup left the account wrong after 4 of 5 fills.
It’s a timing issue. The market_position_size placeholder reports the position after the fill, and a full exit leaves 0. Use {{strategy.prev_market_position_size}} or {{strategy.order.contracts}} when you need the size that closed. PickMyTrade’s close and flat actions close the position regardless, so the 0 mainly matters in logs and formulas.
Yes, and PickMyTrade’s limit-order guide builds on the position word. It sets data to {{strategy.market_position}}, fixes the quantity and turns reverse_order_close on, so a flat alert closes and a short alert reverses. It’s one of 5 PickMyTrade doc pages that use the placeholder.
Before you save the alert
Run 3 checks before the alert goes live. First, pick the pair. An always-in or flat-to-flat strategy belongs on the position pair whenever something besides the strategy can close a trade. A scaling strategy stays on the order pair, with a close on its final exit if it faces the same risk.
Second, change all 4 fields together, because {{strategy.market_position}} and {{strategy.market_position_size}} only work as a pair. Third, prove the result on 5 demo fills before a funded account sees it. After that, route one TradingView alert to several prop-firm accounts.
Written by the PickMyTrade Team, the automated futures and execution specialists behind PickMyTrade’s webhook routing. Editorial note: placeholder behavior and PickMyTrade settings were checked against TradingView and PickMyTrade documentation on September 18, 2026, and the pair outcomes follow PickMyTrade’s documented pyramid and reverse rules. Confirm them on a demo account before trading live. This article is for information only, not trading or financial advice.
Also Checkout: Automate TradingView Indicators with Tradovate Using PickMyTrade
