# Scheduled Trading

> How to restrict bot trading by day of week, hour of day, and day of month using time-based indicators in Veles Finance.

**Scheduled Trading** is the ability to restrict bot activity by calendar and time of day using built-in time-based indicators.

Use cases include:

- trade only on weekdays, skipping weekends;
- run the bot only during specific hours — for example, daytime only;
- avoid trading at night or at the end of the month;
- activate the bot on specific days of the month.

:::note[Note]
All time-based indicators operate in **UTC+0**. If you want to schedule trading in your local timezone, convert your local time to UTC+0 manually.

Example: if your local time is UTC+2, subtract 2 hours — 08:00 local = **06:00 UTC**.
:::

---

## Day of the Week

**The "Day of the Week" indicator** returns the current day of the week in UTC+0.

| Value | Day |
|-------|-----|
| 1 | Monday |
| 2 | Tuesday |
| 3 | Wednesday |
| 4 | Thursday |
| 5 | Friday |
| 6 | Saturday |
| 7 | Sunday |

:::note[Note]
The field accepts any numeric value — there are no restrictions on the input. If you enter 10, the condition will never be met, as no such day of the week exists.
:::

### How It Works

The indicator checks the current day of the week and compares it to the configured value. If the condition is met, the bot is allowed to open trades. If not, entry is blocked.

### Configuration Examples

**Example 1 — Trade only on weekdays**

Condition:
```
Day of the Week > 0
Day of the Week < 6
```
The bot trades Monday (1) through Friday (5).

---

**Example 2 — Trade only on weekends**

Condition:
```
Day of the Week > 5
```
The bot trades on Saturday (6) and Sunday (7).

---

**Example 3 — Trade only on Monday**

Condition:
```
Day of the Week > 0
Day of the Week < 2
```
The bot trades only on Monday (1).

---

## Hour of the Day

**The "Hour of the Day" indicator** returns the current hour in UTC+0 as an integer from 0 to 23.

| Value | UTC Period |
|-------|------------|
| 0 | 00:00–00:59 |
| 1 | 01:00–01:59 |
| … | … |
| 23 | 23:00–23:59 |

### How It Works

The indicator checks the current UTC hour and compares it to the configured boundaries. If the hour falls within the range, the bot is active.

:::caution[Important]
Ranges that cross midnight (pass through 00:00) **cannot be expressed as a single AND condition**. Use **OR logic** — i.e., OR groups in flexible indicators.
:::

### Configuration Examples

**Example 1 — Trade during the day (08:00–19:59 UTC)**

Condition:
```
Hour of the Day > 7
Hour of the Day < 20
```
The bot trades from 08:00 to 19:59 UTC.

---

**Example 2 — Trade at night (22:00–02:59 UTC)**

This range crosses midnight — use OR groups:

```
Group 1: Hour of the Day > 21
OR
Group 2: Hour of the Day < 3
```

The bot trades from 22:00 to 02:59 UTC.

---

## Day of the Month

**The "Day of the Month" indicator** returns the current calendar date as a number from 1 to 31.

### How It Works

The indicator compares the current date to the configured boundaries. If the day number falls within the range, the bot trades.

:::note[Note]
If you set a condition referencing day 31, it will only trigger in months that have 31 days (January, March, May, July, August, October, December). In shorter months, this condition **will never be met**.
:::

### Configuration Examples

**Example 1 — Trade in the first half of the month**

Condition:
```
Day of the Month < 16
```
The bot is active from the 1st to the 15th.

---

**Example 2 — Trade in the second half of the month**

Condition:
```
Day of the Month > 15
```
The bot is active from the 16th to the end of the month.

---

**Example 3 — Trade only on the 15th**

Condition:
```
Day of the Month > 14
Day of the Month < 16
```

---

## Standard Indicators

In standard mode, time-based indicators are added as regular entry or exit filters.

1. Open the bot settings and go to the filters section.
2. Click **"Add filter"** and select the desired time indicator (e.g., "Day of the Week").
3. Choose a comparison operator.
4. Enter a numeric value.
5. Add a second condition if you need a range.

[Video](https://static.veles.finance/videos/filters-schedule-en.mp4)

:::caution[Important]
Standard mode does not support OR grouping. If you need a nighttime range that crosses midnight, or multiple separate time windows — use **flexible indicators** instead.
:::

---

## Flexible Indicators

In flexible indicators, time conditions work like regular indicators: they can be compared to a constant, combined with AND / OR, and composed into complex logic.

Example — nighttime range crossing midnight:

```
Group 1:
Indicator: Hour of the Day
Operator: greater than
Value: Constant 21

OR

Group 2:
Indicator: Hour of the Day
Operator: less than
Value: Constant 3
```

:::tip[Tip]
Use flexible indicators when you need OR logic — for example, trade on weekdays **or** Saturday morning, or when a time range crosses 00:00.
:::

---

## Backtesting Support

Time-based indicators are fully supported in backtests.

- The schedule is applied to historical data — the bot skips trades during restricted periods.
- If you blocked trading on weekends or at night, **no trades are opened** during those periods in the calculation.
- Backtest results accurately reflect bot behavior with the configured schedule, letting you validate the strategy before going live.

:::tip[Tip]
Always verify your schedule in a backtest before launching the bot: confirm that trades open only during the intended hours and days.
:::

---

## Summary

Time-based indicators give you precise control over bot activity:

- **Day of the Week** — trade only on weekdays, weekends, or a specific day.
- **Hour of the Day** — trade during daytime, nighttime, or any hourly range.
- **Day of the Month** — restrict activity to the beginning, middle, or end of the month.

**Remember:** all values are calculated in UTC+0. Convert your local time before configuring a schedule.
