The Buy Flow
When SignalPipe receives a buy signal, it follows one of three paths depending on the current state of your positions.
Path 1: New Position
If you do not have an active deal for the instrument and you have not reached your max active deals limit:
- Reserve a deal slot -- SignalPipe uses a database transaction to atomically check for existing deals and reserve a slot. This prevents duplicate deals from concurrent webhook deliveries.
- Open a market position -- A market buy position is opened on Capital.com for the specified size.
- Wait for confirmation -- Capital.com confirms the position with a deal reference. SignalPipe polls for the fill price and deal ID.
- Set take-profit level -- The TP level is calculated as:
filled_price * (1 + take_profit_percent / 100), rounded to the nearest cent. The take-profit is set directly on the position via Capital.com's position modification API. - Save the deal -- The deal is recorded in the database with all position details, entry price, invested amount, and TP target.
Example: New Position
- Signal: BUY 10 units of AAPL
- Fill price: $150.00
- Take-profit setting: 5%
- TP level: $150.00 * 1.05 = $157.50
- Result: Position opened with 10 units, TP set at $157.50
Path 2: Existing Position (DCA Safety Order)
If you already have an active deal for the instrument, the buy signal is treated as a safety order. A new sub-position is opened on Capital.com (each DCA step is a separate position). Safety orders are always processed regardless of the "Accept New Deals" setting -- this ensures existing deals can continue to be managed.
- Open a new sub-position -- Additional units are purchased at the current market price as a separate position.
- Wait for confirmation -- Same polling mechanism as a new position.
- Recalculate weighted average entry -- The new average is:
(old_total_cost + new_cost) / new_total_size. - Update TP on all sub-positions -- All open sub-positions in the deal have their take-profit level updated to the recalculated TP price.
- Update the deal -- The deal record is updated with the new sub-position, recalculated averages, and new TP target.
Example: Safety Order
- Existing deal: 10 units of AAPL, avg entry $150.00, TP at $157.50
- New signal: BUY 15 units of AAPL
- Fill price: $140.00
- New total cost: (10 $150) + (15 $140) = $1,500 + $2,100 = $3,600
- New total size: 25
- New avg entry: $3,600 / 25 = $144.00
- New TP level: $144.00 * 1.05 = $151.20
- Result: All sub-positions updated to TP $151.20
Notice how the safety order lowered the average entry from $150.00 to $144.00, and the TP target moved from $157.50 down to $151.20 -- making it much more likely to be reached.
Path 3: At Max Active Deals
If you have already reached your configured maximum number of active deals and the buy signal is for a new instrument (not an existing position):
- The signal is silently skipped -- no position is opened
- An entry is added to the activity log noting the skip
- HTTP 200 is returned to TradingView (no error)
This is by design. The max deals limit prevents over-allocation of your account. When an existing deal closes (via TP fill or sell signal), the slot becomes available for the next buy signal.
Order Validation
Before placing any buy order, SignalPipe validates:
- Size must be greater than 0 -- Invalid sizes are rejected and logged
- Instrument availability -- If the epic does not exist on Capital.com, the order is rejected by the API and logged as an error