# What Are Averaging, Martingale, and Logarithmic Distribution

> A simple explanation of Dollar Cost Averaging (DCA), Martingale strategy, and logarithmic order distribution in Veles trading bots.

## Averaging (DCA — Dollar Cost Averaging)

Veles bots belong to the **DCA-bot** category.
**DCA (Dollar Cost Averaging)** is a strategy where the total buy or sell volume of an asset is split into multiple parts.
Orders are placed step-by-step (as a grid), allowing you to **lower the average entry price** on buys or **raise it** on sells.

**Core idea:**
- The price moves against your position → the bot places an additional order (buys more or shorts more).
- The **average entry price** moves closer to the current price.
- When the market reverses, the exit point is reached faster.

**Important:** a safe grid rarely executes fully.
If all grid orders trigger frequently — it means your grid is **too short**, and the bot will often go into *invest mode* (a long floating drawdown).

From the **active trade card**, you can manually add extra orders beyond the grid — this helps exit from drawdowns, but requires additional margin.

## Example: Calculating the Average Price

The coin price averaging formula:

`P = (Q1 * P1 + Q2 * P2 + Q3 * P3) / (Q1 + Q2 + Q3)`

P is the price of the coin after averaging
Q1, Q2, Q3 — the amount of coins in the orders
P1, P2, P3 — coin prices in the averaging orders

Pair: **SOL/USDT**, current price: 202.91 USDT.
Grid coverage: 10%, 3 orders.

- Order 1: 202.91 → 16.4 SOL
- Order 2: 192.76 → 17.2 SOL
- Order 3: 182.61 → 18.2 SOL

**Average position price** after all orders execute = **192.4 USDT**

## What is the Martingale Strategy

A **Martingale** means each next order in the grid is **larger than the previous one** by a fixed percentage.
This accelerates the shift of the average entry price toward the market price, allowing a quicker recovery.

**Example (Martingale 20%):**

- Order 1: 202.91 → 13.5 SOL
- Order 2: 192.76 → 17.1 SOL
- Order 3: 182.61 → 21.6 SOL

Average entry price drops to **191.18 USDT**, better than equal-volume orders.

**Formula:**
> New Order Volume = Previous Order Volume × (1 + Martingale %)

The higher the Martingale %, the faster the bot “pulls” the average price closer — but the **greater the margin risk**.

:::note
The Martingale % is applied not to the volume in the coin, but to the face value.
Therefore, on Short bots with a small Martingale %, you may observe a decrease in coin volume due to an increase in the asset's price.
:::

## Logarithmic Order Distribution

By default, grid orders are placed **linearly** — evenly spaced in price.
That’s not always efficient:

- In low volatility, only the first few orders may trigger.
- Much of the deposit remains unused.

### Logarithmic Coefficient

You can control grid density with this parameter:

- **Greater than 1** → more orders near the current price.
  - Pros: more capital is actively working during small moves.
  - Cons: higher risk during sharp drops.

- **Less than 1** → fewer orders near the current price, more below.
  - Pros: lower liquidation risk during deep corrections.
  - Cons: lower profit, slower capital utilization.

## Ready-Made Grid Schemes

To simplify setup for new users, here are three base templates you can use as a starting point.

### 🔴 Aggressive Scheme
- Logarithm: **1.5 – 2.0**
- Martingale %: **30 – 50 %**
- Pros: Fast recovery and profit even after small reversals.
- Cons: High risk; requires significant margin support.

### 🟡 Balanced Scheme
- Logarithm: **≈ 1.0** (linear spacing)
- Martingale %: **15 – 25 %**
- Pros: Good balance between recovery speed and safety.
- Cons: May require manual control during strong drawdowns.

### 🟢 Conservative Scheme
- Logarithm: **0.5 – 0.8**
- Martingale %: **0 – 10 %**
- Pros: Minimal liquidation risk; ideal for calm markets.
- Cons: Profit-target distance may be far from the current price.

## Summary

- **Averaging (DCA)** reduces entry risk by splitting the position.
- **Martingale** accelerates recovery but increases margin exposure.
- **Logarithmic distribution** allows flexible control over grid density.
- **Ready-made templates** help beginners trade safely and efficiently.

Choose the configuration that matches your **trading style** and **risk tolerance**, then fine-tune it for each specific asset.
