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
| Position | Direction | Entry Price | Lot Size |
|---|---|---|---|
| #1 | BUY | 4490 | 0.02 |
| #2 | BUY | 4500 | 0.03 |
| #3 | BUY | 4510 | 0.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:R | Calculation | TP Price | Potential Reward |
|---|---|---|---|
| 1:1 | 4500 + (60 × 1) | 4560 | 60 pips |
| 1:2 | 4500 + (60 × 2) | 4620 | 120 pips |
| 1:3 | 4500 + (60 × 3) | 4680 | 180 pips |
| 1:0.5 | 4500 + (60 × 0.5) | 4530 | 30 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 Type | 1 Pip Equals | Example |
|---|---|---|
| Forex (most pairs) | 0.0001 | EURUSD: 1.0850 → 1.0851 = 1 pip |
| Forex (JPY pairs) | 0.01 | USDJPY: 155.50 → 155.51 = 1 pip |
| Gold (XAUUSD) | 0.10 | 2650.50 → 2650.60 = 1 pip |
| Indices | 1.0 | US500: 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:
| Action | BUY Condition | SELL Condition |
|---|---|---|
| SL→BE | Price > Breakeven | Price < Breakeven |
| SL→ENTRY | Price > Entry | Price < Entry |
| TP→BE | Price < Breakeven | Price > Breakeven |
| TP→ENTRY | Price < Entry | Price > Entry |
| TP R:R | SL must be set | SL must be set |