Command Keys

Formulas & Calculations

Formulas & Calculations

This page is a reference for all the mathematical calculations TradeTorq uses behind Command Keys and automation engines.

Breakeven Price

The volume-weighted average entry price across all open positions in the same direction.

BE = Σ(entry_price × lot_size) ÷ Σ(lot_size)

Example

PositionDirectionEntry PriceLot Size
#1BUY44900.02
#2BUY45000.03
#3BUY45100.01

Calculation:

BE = (4490 × 0.02 + 4500 × 0.03 + 4510 × 0.01) ÷ (0.02 + 0.03 + 0.01)

BE = (89.80 + 135.00 + 45.10) ÷ 0.06

BE = 269.90 ÷ 0.06

BE = 4498.33

Risk (in Pips)

The distance between breakeven and stop loss:

Risk = |Breakeven − Stop Loss|

Measured in the instrument's pip unit. For XAUUSD (gold), 1 pip = 0.1 price unit (10 pips = $1). For EURUSD, 1 pip = 0.0001 price unit.

Risk-Reward Take Profit

TP = Breakeven ± (Risk × RR_Ratio)

  • For BUY: TP = Breakeven + (Risk × Ratio) — TP above breakeven
  • For SELL: TP = Breakeven − (Risk × Ratio) — TP below breakeven

Example Table

With Breakeven = 4500 and SL = 4440 (Risk = 60 pips):

R:RCalculationTP PricePotential Reward
1:14500 + (60 × 1)456060 pips
1:24500 + (60 × 2)4620120 pips
1:34500 + (60 × 3)4680180 pips
1:0.54500 + (60 × 0.5)453030 pips

SL at Profit Calculation

For BUY: SL = Breakeven + profit_pips

For SELL: SL = Breakeven − profit_pips

This guarantees at least profit_pips of profit if the stop loss is hit.

Move SL/TP — Pips Mode

For BUY SL: SL = Breakeven − offset_pips (SL below breakeven)

For SELL SL: SL = Breakeven + offset_pips (SL above breakeven)

For BUY TP: TP = Breakeven + offset_pips (TP above breakeven)

For SELL TP: TP = Breakeven − offset_pips (TP below breakeven)

Close Half — Lot Calculation

New lot size = Current lot size ÷ 2

Rounded to the broker's minimum lot step. Common lot steps:

  • 0.01 (micro lots) — most common
  • 0.10 (mini lots)
  • 1.00 (standard lots)

Close Custom — Volume Calculation

Volume to close = Total volume × (percentage ÷ 100)

Distributed proportionally across all positions.

What Is a Pip?

A pip (percentage in point) is the smallest standard price movement in trading:

Instrument Type1 Pip EqualsExample
Forex (most pairs)0.0001EURUSD: 1.0850 → 1.0851 = 1 pip
Forex (JPY pairs)0.01USDJPY: 155.50 → 155.51 = 1 pip
Gold (XAUUSD)0.102650.50 → 2650.60 = 1 pip
Indices1.0US500: 5200 → 5201 = 1 point

Broker-specific

Pip values and point sizes vary by broker and symbol. TradeTorq automatically uses the correct pip size for your broker's specific symbol configuration.

Validation Summary

Quick reference for when Command Key actions are valid:

ActionBUY ConditionSELL Condition
SL→BEPrice > BreakevenPrice < Breakeven
SL→ENTRYPrice > EntryPrice < Entry
TP→BEPrice < BreakevenPrice > Breakeven
TP→ENTRYPrice < EntryPrice > Entry
TP R:RSL must be setSL must be set
Previous
Premium Actions