---
title: strategy.market_position vs market_position_size Guide
slug: strategy-market-position-vs-size
date: 2026-09-08
modified: 2026-09-09
author: Bhavishya Goyal
excerpt: ""
meta_description: "market_position returns a string, market_position_size returns a number. Swap them in a PickMyTrade JSON alert and your webhook silently breaks. Here\'s the fix."
focus_keyword: market_position vs market_position_size
canonical_url: "https://blog.pickmytrade.io/strategy-market-position-vs-size/"
og_title: strategy.market_position vs market_position_size Guide
og_description: "market_position returns a string, market_position_size returns a number. Swap them in a PickMyTrade JSON alert and your webhook silently breaks. Here\'s the fix."
og_image: "https://blog.pickmytrade.io/wp-content/uploads/2026/09/strategy-market-position-vs-size-1024x576.avif"
schema_type: FAQPage
categories:
  - TradingView
tags: []
reading_time: 8
word_count: 1810
robots: "index, follow"
lang: en-US
---

# strategy.market_position vs market_position_size Guide

If your TradingView alert fires but PickMyTrade rejects the payload or sends the wrong contract count, the cause is often one mixed-up placeholder. `{{strategy.market_position}}` and `{{strategy.market_position_size}}` look almost identical in the alert editor, but they return completely different data types. A third relative, `{{strategy.position_size}}`, adds a signed-number trap on top. Pick the wrong one for a JSON field, and the alert either fails to parse or sends a quantity that doesn’t match what you intended.

Table of Contents

1. [What Does {{strategy.market_position}} Actually Return?](https://blog.pickmytrade.io/#what-does-strategy-market_position-actually-return)
2. [What Does {{strategy.market_position_size}} Actually Return?](https://blog.pickmytrade.io/#what-does-strategy-market_position_size-actually-return)
3. [market_position vs market_position_size vs position_size: What’s the Difference?](https://blog.pickmytrade.io/#market_position-vs-market_position_size-vs-position_size-whats-the-difference)
4. [Which Placeholder Should You Use in a PickMyTrade JSON Alert?](https://blog.pickmytrade.io/#which-placeholder-should-you-use-in-a-pickmytrade-json-alert)
5. [What Breaks When You Use the Wrong Placeholder?](https://blog.pickmytrade.io/#what-breaks-when-you-use-the-wrong-placeholder)
6. [How Do You Build a Correct JSON Payload?](https://blog.pickmytrade.io/#how-do-you-build-a-correct-json-payload)
7. [Frequently Asked Questions](https://blog.pickmytrade.io/#frequently-asked-questions)
8. [Can I put {{strategy.market_position}} directly into the quantity field?](https://blog.pickmytrade.io/#can-i-put-strategy-market_position-directly-into-the-quantity-field)
9. [Does {{strategy.market_position_size}} ever return a negative number?](https://blog.pickmytrade.io/#does-strategy-market_position_size-ever-return-a-negative-number)
10. [What’s the real difference between strategy.position_size and strategy.market_position_size?](https://blog.pickmytrade.io/#whats-the-real-difference-between-strategy-position_size-and-strategy-market_position_size)
11. [Should I use strategy.order.contracts or strategy.market_position_size for quantity?](https://blog.pickmytrade.io/#should-i-use-strategy-order-contracts-or-strategy-market_position_size-for-quantity)
12. [Do these placeholders work in indicator alerts, or only strategy alerts?](https://blog.pickmytrade.io/#do-these-placeholders-work-in-indicator-alerts-or-only-strategy-alerts)

This post covers only these three placeholders: what each returns, and the exact failure mode from dropping it into the wrong field of a PickMyTrade webhook payload. For the full list of TradingView placeholders PickMyTrade supports, see the [TradingView Alert Placeholders reference](https://docs.pickmytrade.trade/docs/tradingview-plot-placeholder/).

&gt; **Key Takeaways**  
&gt; • `{{strategy.market_position}}` returns a string: “long”, “short”, or “flat”. It is not a number.  
&gt; • `{{strategy.market_position_size}}` returns the current position size as an absolute, non-negative number.  
&gt; • `{{strategy.position_size}}` returns the same value but signed: positive when long, negative when short, zero when flat.  
&gt; • Put a string placeholder in a numeric field (like `quantity`) and the JSON either fails to parse or PickMyTrade rejects the field.  
&gt; • Put the signed `position_size` in a `quantity` field and a short trade can send a negative contract count.

## What Does {{strategy.market_position}} Actually Return? {#what-does-strategy-market_position-actually-return}

`{{strategy.market_position}}` is a text placeholder. TradingView’s own documentation defines it plainly: it “returns the current position of the strategy in string form: ‘long’, ‘flat,’ or ‘short’.” That’s the entire value set: three words, nothing else. It never returns a number, a percentage, or a contract count.

That’s useful for conditional logic in an alert message, or for a `data`/`action`-style field where PickMyTrade expects text like “buy” or “sell”. It’s the wrong choice anywhere the platform expects a number, including PickMyTrade’s `quantity` field. Drop it into `"quantity": {{strategy.market_position}}`, and TradingView substitutes the literal word `long` into that spot in the JSON string. Since `long` isn’t a quoted string and isn’t a number, the payload is no longer valid JSON, and PickMyTrade’s parser throws it out before any trade logic runs.

&gt; **Citation capsule:** TradingView’s Strategy Alerts documentation states `{{strategy.market_position}}` “returns the current position of the strategy in string form: ‘long’, ‘flat,’ or ‘short.'” It is always text, never numeric, and cannot substitute for a quantity or size value in a JSON payload. Source: [TradingView Strategy Alerts](https://www.tradingview.com/support/solutions/43000481368-strategy-alerts/), TradingView Support.

## What Does {{strategy.market_position_size}} Actually Return? {#what-does-strategy-market_position_size-actually-return}

`{{strategy.market_position_size}}` is a number. TradingView describes it as returning “the size of the current position as an absolute value, i.e. a non-negative number.” Absolute means the sign is stripped: a 3-contract short position and a 3-contract long position both return `3`. When the strategy is flat, it returns `0`.

That absolute-value behavior matches what PickMyTrade’s `quantity` field wants: a plain, unsigned number of contracts or shares. Quantity has no separate “direction” input, because direction is carried by the `data`/action field instead, typically fed by `{{strategy.order.action}}`, which returns “buy” or “sell”. Splitting direction and size this way is standard for webhook execution.

&gt; **Citation capsule:** TradingView documents `{{strategy.market_position_size}}` as returning “the size of the current position as an absolute value, i.e. a non-negative number,” always zero or positive regardless of direction. Source: [TradingView Strategy Alerts](https://www.tradingview.com/support/solutions/43000481368-strategy-alerts/), TradingView Support.

## market_position vs market_position_size vs position_size: What’s the Difference? {#market_position-vs-market_position_size-vs-position_size-whats-the-difference}

A third placeholder, `{{strategy.position_size}}`, gets confused with `market_position_size` constantly because the names overlap by one word. TradingView’s alert documentation notes it “returns the value of the same keyword in Pine, i.e., the size of the current position.” Pine’s built-in `strategy.position_size` variable is signed: positive while long, negative while short, zero when flat. So a 3-contract short position returns `-3` from `{{strategy.position_size}}`, but `3` from `{{strategy.market_position_size}}`. Same trade, opposite-looking numbers, one word of difference in the placeholder name.

| Placeholder | Data type | What it returns | Example (3-contract short) |
| --- | --- | --- | --- |
| {{strategy.market_position}} | String | Current position as text: “long”, “short”, or “flat” | “short” |
| {{strategy.market_position_size}} | Number (unsigned) | Absolute size of current position, never negative | 3 |
| {{strategy.position_size}} | Number (signed) | Position size with sign: positive long, negative short, zero flat | -3 |
| {{strategy.order.contracts}} | Number (unsigned) | Size of the specific order that just triggered, not the whole position | 3 |
| {{strategy.order.action}} | String | Direction of the triggering order: “buy” or “sell” | “sell” |

&gt; **Citation capsule:** TradingView confirms `{{strategy.position_size}}` mirrors Pine’s `strategy.position_size` variable, which is signed: positive for long, negative for short. `{{strategy.market_position_size}}` strips that sign and returns an absolute value instead. The two are not interchangeable in a numeric field. Source: [How to Use a Variable Value in Alert](https://www.tradingview.com/support/solutions/43000531021-how-to-use-a-variable-value-in-alert/), TradingView Support.

## Which Placeholder Should You Use in a PickMyTrade JSON Alert? {#which-placeholder-should-you-use-in-a-pickmytrade-json-alert}

For most PickMyTrade webhook setups, you won’t use `market_position` or `market_position_size` in the standard `quantity` field at all. PickMyTrade’s own JSON template feeds `quantity` from `{{strategy.order.contracts}}`, the size of the order that just fired, not the running position total. That’s the right default for entries and scale-ins, since it tells PickMyTrade exactly how many contracts this signal is for.

`{{strategy.market_position_size}}` earns its place in a narrower case: closing or flattening based on whatever the strategy currently holds, rather than a fixed per-order size. If your alert sends “close everything open,” the absolute current position size is more reliable than assuming the last order size still matches the live position, especially after partial fills or pyramiding. `{{strategy.market_position}}` belongs on the direction side of the payload, or in conditional alert text, never in a quantity field.

&gt; The pattern that shows up most isn’t a fully broken alert. It’s a payload that “sort of” works, still sends trades, but silently sizes them wrong for weeks before anyone notices the fill history doesn’t match intent.

&gt; **Citation capsule:** PickMyTrade’s own Strategy JSON template uses `{{strategy.order.contracts}}` for the `quantity` field and `{{strategy.order.action}}` for the direction field, keeping size and direction as separate string/number inputs. Source: [TradingView JSON Alert Configuration](https://docs.pickmytrade.trade/docs/tradingview-json-alert-configuration/), PickMyTrade Docs.

## What Breaks When You Use the Wrong Placeholder? {#what-breaks-when-you-use-the-wrong-placeholder}

Two distinct failure modes show up, and they look different in the logs.

**String in a numeric field.** Put `{{strategy.market_position}}` into `"quantity": {{strategy.market_position}}` and TradingView renders it as `"quantity": long`, an unquoted bareword, not valid JSON. Most webhook receivers, PickMyTrade included, fail to parse that payload at all. Quote it instead as `"quantity": "{{strategy.market_position}}"`, and the JSON parses, but `quantity` now holds the text “long” instead of a number, which typically gets rejected or coerced to `0`.

**Signed number where unsigned was expected.** This one is quieter and more dangerous. Swap `{{strategy.order.contracts}}` for `{{strategy.position_size}}` in a `quantity` field, and every alert fired while the strategy is short sends a negative number. Some downstream systems reject negative quantities; others handle them unpredictably. Either way, the executed trade doesn’t match what the strategy intended, and it’s easy to miss because the alert still fires successfully. It just fires wrong.

&gt; **Citation capsule:**  JSON has no bareword type. An unquoted string like `long` is a syntax error, not a warning. Combined with TradingView’s placeholder substitution happening as plain text insertion, a string placeholder in a numeric JSON field produces a payload that fails validation before any broker logic runs, per the [JSON specification](https://www.json.org/json-en.html) and TradingView’s placeholder documentation.

## How Do You Build a Correct JSON Payload? {#how-do-you-build-a-correct-json-payload}

Here’s a minimal strategy alert message using each placeholder in the field it actually fits:

```
{
  "symbol": "NQ",
  "date": "{{timenow}}",
  "data": "{{strategy.order.action}}",
  "quantity": "{{strategy.order.contracts}}",
  "price": "{{close}}",
  "token": "your_token_here",
  "account_id": "your_account_id"
}
```

`data` takes the string from `{{strategy.order.action}}` (“buy” or “sell”). `quantity` takes the unsigned number from `{{strategy.order.contracts}}`. Neither `{{strategy.market_position}}` nor `{{strategy.market_position_size}}` appears here, because order-level placeholders are the right fit for order-by-order execution. Reserve `{{strategy.market_position_size}}` for alerts built to flatten or resize against the live position, and keep `{{strategy.market_position}}` out of numeric fields entirely. Before saving any alert, paste the rendered message into a JSON validator with sample values swapped in for the placeholders. That step catches an unquoted string or a stray negative sign before it reaches a live account.

&gt; **Citation capsule:** PickMyTrade’s JSON alert configuration guide shows the baseline strategy template pairing `{{strategy.order.action}}` with `data` and `{{strategy.order.contracts}}` with `quantity`, the pattern PickMyTrade documents for standard entry and scale-in alerts. Source: [TradingView JSON Alert Configuration](https://docs.pickmytrade.trade/docs/tradingview-json-alert-configuration/), PickMyTrade Docs.

## Frequently Asked Questions {#frequently-asked-questions}

### Can I put {{strategy.market_position}} directly into the quantity field? {#can-i-put-strategy-market_position-directly-into-the-quantity-field}

No. `quantity` expects a number, and `market_position` always returns a string. The payload either fails JSON parsing or the field gets rejected or coerced to zero.

### Does {{strategy.market_position_size}} ever return a negative number? {#does-strategy-market_position_size-ever-return-a-negative-number}

No. TradingView documents it as an absolute value, always zero or positive, even when the position is short.

### What’s the real difference between strategy.position_size and strategy.market_position_size? {#whats-the-real-difference-between-strategy-position_size-and-strategy-market_position_size}

Both report the size of the current position, but `position_size` is signed (negative when short), and `market_position_size` strips the sign. Using the signed version in an unsigned field is the more common, harder-to-spot bug.

### Should I use strategy.order.contracts or strategy.market_position_size for quantity? {#should-i-use-strategy-order-contracts-or-strategy-market_position_size-for-quantity}

For normal entries and scale-ins, use `{{strategy.order.contracts}}`, since it reflects that specific order’s size. Use `{{strategy.market_position_size}}` only for alerts meant to close or resize against the whole current position.

### Do these placeholders work in indicator alerts, or only strategy alerts? {#do-these-placeholders-work-in-indicator-alerts-or-only-strategy-alerts}

`strategy.*` placeholders only populate on strategy alerts created from “Order fills” events. They return unusable values on plain indicator alerts, which is why indicator templates typically hardcode `quantity` instead.

**Automate Your TradingView Strategies**  
Connect your alerts with [PickMyTrade](https://pickmytrade.io "PickMyTrade") — automated trade execution, no coding required. [Start free →](https://pickmytrade.io/pricing)

For AI tools &amp; developers:[View Markdown →](https://blog.pickmytrade.io/strategy-market-position-vs-size.md)<!--pmtA1-clean-->