# Price Delta

## Overview

**Price Delta** is a mechanism to simulate controlled price movement for a symbol over a defined time interval.

The system:

- Applies a **fixed price shift (in pips)** during a selected period
- Smoothly transitions into and out of this shift
- Prevents unrealistic instant price jumps

This feature is primarily used for:

- testing trading scenarios
- simulating volatility
- validating risk, margin, and liquidation logic

---

## Core Concepts

### 1. Time Range (From / To)

Defines the **main active interval** where the full price change is applied.

- **From** — start time of full delta
- **To** — end time of full delta

During this interval:

> Price is shifted by the full configured delta

---

### 2. Price Delta (Pips)

Defines the magnitude of the price change.

- Positive → price increases
- Negative → price decreases

**Formula:**

```
Adjusted Price = Base Price ± Delta
```

---

### 3. Smooth Change Steps

Defines how many incremental steps are used to **gradually apply and remove** the delta.

- Steps are applied:
    
    
    - before the main interval
    - after the main interval
- Prevents sharp jumps in the chart

---

### 4. Step Duration

Defines how long each smoothing step lasts.

- Unit: minutes
- Total smoothing duration =
    
    ```
    steps × step_duration
    ```

---

## Full Behavior Model

The system consists of **3 phases**:

---

### 1. Pre-Smoothing Phase

- Starts before `From`
- Price gradually moves from:
    
    ```
    0 → full delta
    ```

---

### 2. Active Phase

- Between `From` and `To`
- Price remains at:
    
    ```
    full delta
    ```

---

### 3. Post-Smoothing Phase

- Starts after `To`
- Price gradually returns:
    
    ```
    full delta → 0
    ```

---

## Example — Correct Timeline

### Configuration

<table id="bkmrk-parameter-value-symb"><thead><tr><th>Parameter</th><th>Value</th></tr></thead><tbody><tr><td>Symbol</td><td>EUR/USD</td></tr><tr><td>From</td><td>10:00</td></tr><tr><td>To</td><td>11:00</td></tr><tr><td>Delta</td><td>+100 pips</td></tr><tr><td>Smooth Steps</td><td>10</td></tr><tr><td>Step Duration</td><td>10 minutes</td></tr></tbody></table>

---

### Calculations

- Smoothing duration:
    
    ```
    10 × 10 min = 100 minutes
    ```

---

### Timeline

```
08:20 → smoothing starts
10:00 → full +100 pips reached
10:00–11:00 → constant +100 pips
11:00 → smoothing down starts
12:40 → price returns to normal
```

---

### Step Behavior

#### Pre-smoothing

```
08:20 → +10 pips
08:30 → +20 pips
...
09:50 → +100 pips
10:00 → full delta active
```

---

#### Active Phase

```
10:00 → 11:00
```

Price = **+100 pips**

---

#### Post-smoothing

```
11:00 → +90 pips
11:10 → +80 pips
...
12:40 → 0 pips
```

---

## Visual Model

```
Price
  |
  |          ─────────────── (+100 pips)
  |        /                \
  |      /                    \
  |_____/                      \______
      ↑                        ↑
   smoothing              smoothing
     start                  end

```

---

## Important Rules

### 1. Delta is Absolute

- Applied relative to current/base price
- Not cumulative over time

---

### 2. Smoothing Applies on Both Sides

- `N` steps before `From`
- `N` steps after `To`

---

### 3. No Instant Application

The system does NOT support:

- immediate price override
- single candle injection

All changes must follow:

> defined timeline + smoothing

---

### 4. Time Validity

- Time must be within:
    
    ```
    00:00 – 23:59
    ```
- If smoothing goes before `00:00`:  
    → it moves to the **previous day**

---

## Edge Cases

### 1. Smoothing in the Past

If:

- smoothing start time is already in the past

Then:

- steps may be skipped or not applied correctly

---

### 2. Zero Steps

If:

```
Smooth Steps = 0
```

Then:

- instant jump at `From`
- instant revert at `To`

---

### 3. Negative Delta

Works identically:

```
Delta = -50 pips
```

Result:

- price decreases smoothly
- holds lower level
- returns gradually