Skip to content

automated trading

Choosing Position Size, Stop Loss and Take Profit for a PineConnector Alert

Choosing Position Size, Stop Loss and Take Profit for a PineConnector Alert

Short answer: PineConnector sizes a position with exactly one volume parameter per alert: a fixed lot size (vol_lots=), a cash amount you're willing to lose (vol_dollar=), a percentage of balance or equity as a loss budget (vol_pct_bal_loss=, vol_pct_eq_loss=), or a percentage of balance allocated as margin (vol_pct_bal_margin=). It sets a stop or target with one parameter per level, chosen by what your script actually has: a pip distance (sl_pips=, tp_pips=), an exact price (sl_price=, tp_price=), or a percentage distance (sl_pct=, tp_pct=). Mixing those up, sending a chart price through a pip parameter, or picking a loss-based sizing method without a stop, is a common reason an order's size or target doesn't match what you expected. This guide covers how to choose, and how to check.


Before You Start

This assumes you already have an alert() call or TradingView alert sending messages to PineConnector's webhook. If you haven't set that up yet, start with Pine Script alert() Function: Automate Strategy Signals or, for a full connection walkthrough, How to Connect TradingView to MT5. For the complete parameter list with every command, this guide's companion reference is TradingView Alert Syntax for Automated Execution and PineConnector's own syntax documentation; this guide focuses on choosing between the options, not listing all of them again.


Three Questions That Decide Your Sizing Parameter

PineConnector's syntax documentation lists five volume methods. You send exactly one per message. The right one depends on what "size" means to you for this particular trade:

What you actually want Parameter Needs a stop loss?
The same position size every time, regardless of account balance vol_lots=0.1 No
Lose a fixed amount of account currency if the stop is hit vol_dollar=50 Yes
Risk a fixed percentage of your account balance per trade vol_pct_bal_loss=1 Yes
Risk a fixed percentage of current equity per trade (floating P/L included) vol_pct_eq_loss=1 Yes
Allocate a fixed percentage of balance as margin, regardless of stop vol_pct_bal_margin=5 No

The last row is easy to confuse with the two above it and means something different. A percentage of account risk (how much you're willing to lose) is not the same figure as a percentage of margin allocated (how much of your account is committed to holding the position open). vol_pct_bal_margin=5 sizes the trade so it uses roughly 5% of your balance as margin; it says nothing about what you'd lose if the stop is hit, because it isn't calculated from your stop distance at all. If what you actually mean is "I want to risk 1% of my account on this trade," that's vol_pct_bal_loss=1 or vol_pct_eq_loss=1, not a margin percentage.

The three loss-based methods (vol_dollar=, vol_pct_bal_loss=, vol_pct_eq_loss=) all require an explicit stop loss parameter in the same message. PineConnector calculates the lot size backward from your stop distance and your risk figure, and it cannot do that without a stop to measure from. A closer stop and a farther stop produce different lot sizes for the same cash or percentage risk, by design: that's the entire point of risk-based sizing, but it also means the resulting lot size will change if your stop distance changes, even with an identical risk figure.

LicenseID,buy,EURUSD,vol_dollar=50,sl_pips=10
LicenseID,sell,EURUSD,vol_pct_bal_loss=1,sl_pips=20

These figures are sizing inputs, not promised outcomes. Slippage, weekend gaps, and a broker's execution price at the moment the stop triggers can all move the realized loss away from the $50 or 1% you calculated. Treat the risk figure as a sizing target, not a fixed ceiling on what you'll actually lose.


Matching Your Stop and Target to How Your Script Stores Them

A Pine Script strategy typically holds a level in one of three shapes, and PineConnector has a parameter for each:

  • A pip distance (you decided "20 pips away," not tied to any specific price) → sl_pips=20 / tp_pips=40.
  • An exact chart price (a swing low, an EMA value, a support level your script calculated) → sl_price= / tp_price=.
  • A percentage distance from entrysl_pct=1 / tp_pct=2.

Sending the wrong one is a common way a target ends up somewhere you didn't expect. A chart-derived price is not a pip count: low[1] in Pine Script might evaluate to 1.09760, and sending that through sl_pips= would ask PineConnector for a stop 1.0976 pips away, not a stop at that price. Use the price parameter for a price, and the pip parameter for a pip count. That's necessary, but not sufficient, on its own:

LongSL = low[1]
LongTP = ta.ema(close, 50)
validLongLevels = LongSL < close and LongTP > close

if LongEntryCondition and validLongLevels
    alert('LicenseID,buy,' +syminfo.ticker+ ',sl_price=' +str.tostring(LongSL, format.mintick)+ ',tp_price=' +str.tostring(LongTP, format.mintick)+ ',vol_lots=0.01', alert.freq_once_per_bar_close)

The validLongLevels check matters on its own: a 50-period EMA isn't automatically on the correct side of price for a buy's take-profit, and PineConnector's own documentation requires a price parameter to be "on the correct side and satisfy the broker's distance rules," or the order is rejected. That check is preliminary and chart-side only; it doesn't confirm your broker will accept the resulting price or distance, which is a separate check. format.mintick as the second argument to str.tostring() rounds the price to TradingView's own tick size, which avoids floating-point noise but doesn't by itself confirm your broker accepts that exact price; brokers enforce their own minimum distance between price and any stop or target too. Check the Signals Log and your MT5 terminal for what was actually sent and accepted. The full walkthrough for this pattern, including symbol handling and comment labels, is in the alert() function guide.

A special case worth knowing: sl=0 is not the same as sl_pips=0. The bare value sl=0 is a documented request to move the stop to breakeven on an existing position. It requires the position to be in profit and needs your broker's minimum stop distance to be satisfiable, and it isn't interchangeable with the pip/price/percentage family above. There's a second legacy exception worth knowing too: the partial-close commands closelongvol/closeshortvol use risk= to mean a close-volume amount in lots (for example risk=0.01 closes 0.01 lots), not an entry-risk figure. That's a different, still-current use of the same parameter name, distinct from the older entry-sizing risk= covered above.


If Your Order Size or Target Isn't What You Expected

Work from what PineConnector actually received, not from what you meant to send. The Signals Log in the PineConnector Portal shows the literal message text for each alert; a rejected signal doesn't appear there at all, so if you don't see a signal you expected, the message likely never arrived or failed validation before PineConnector logged it. Compare the logged text against what you intended, character by character, before assuming anything about your MetaTrader terminal is wrong. Causes worth checking, not ranked by frequency (this guide has no data on which is more common):

  • Two volume or two stop methods in one message. The syntax specifies one volume method and one stop method per message; PineConnector isn't documented to merge or prioritize between conflicting ones, so don't send both vol_lots= and vol_dollar=, or both sl_pips= and sl_price=, in the same alert.
  • A loss-based volume method with no stop, or a mismatched one. vol_dollar=, vol_pct_bal_loss= and vol_pct_eq_loss= all need a stop in the same message to calculate a lot size at all. If the size looks too large or too small for the risk figure you sent, check the stop distance next. A tighter stop produces a larger lot size for the same dollar or percentage risk, and a wider stop produces a smaller one.
  • A price sent as a pip count, or a pip count sent as a price. Covered above; this produces a target that's either absurdly close to entry or nowhere near the chart level you intended.
  • A price or pip distance on the wrong side of entry. A take-profit below entry on a buy (or above entry on a sell) is invalid; PineConnector's documentation requires the price to be on the correct side. Validate this in your script, as shown above, before sending the alert.
  • Pending-order distances measured from the wrong reference. For buystop, buylimit, sellstop and selllimit, PineConnector's documentation is explicit that stop and target distances are measured from the pending entry price, not from the market price when the order is placed or filled. If your target looks offset by the same amount as your entry distance, check this next.
  • Broker-side rejection or adjustment. Brokers enforce a minimum lot size and lot step, and a minimum distance between price and any stop or target (a stop level or freeze level). PineConnector's own documentation doesn't specify how a calculated volume or price that falls outside those limits is handled; it may be adjusted, or the order may simply be rejected by your broker. Don't assume rounding happens automatically. The Signals Log shows what PineConnector sent; your MetaTrader terminal or broker confirmation shows what was actually accepted, and is the only way to know for certain.

Verifying the Result

A signal appearing in the Signals Log confirms PineConnector received and parsed your message. It does not by itself confirm your broker filled the order at the size and levels you intended. Open the account in MetaTrader (or your broker's own interface) and check the actual position: right symbol, right direction, right volume, and the stop loss or take profit at the level you expected. How to Connect TradingView to MT5 has the full verified-demo-trade checklist if you haven't run through it yet. Do this on a demo account before trusting a new sizing or stop/target setup with real funds.


Reviewed 18 September 2026. Every parameter, requirement and example above was checked against PineConnector's syntax documentation and its EA settings guide. The worked examples are illustrative, not measured results: compile any code in your own Pine Editor, and confirm the resulting size, stop and target on a demo account before trading on it live. PineConnector executes the instructions you send it. It does not select trades, manage money, or hold funds. Trading carries risk, and past performance of any strategy does not indicate future results.

Start with Core at PineConnector and size your first alert deliberately, on a demo account, before going live.


Leave a comment

Back To PiCo Blog

Ready when your strategy is

You bring the strategy.We bring the infrastructure.

Connect TradingView to MetaTrader, choose where MT5 runs and put the full PineConnector workflow through its paces from your first month.

Strategy and trading decisions remain yours. The MT5 environment can be ours.

PineConnector Edge

Run the full PineConnector workflow.

$59/mo at launch

Core plan · 1 connection · 1 hosted MT5 environment

Start with Core

Launch price — standard pricing is $69/mo after the launch period.