---
id: "M:cAlgo.API.OptimizationDateTimeParameter.#ctor(System.String,System.DateTime,System.DateTime,System.TimeSpan)"
kind: "constructor"
type: "T:cAlgo.API.OptimizationDateTimeParameter"
url: "https://help.ctrader.com/ctrader-algo/references/Plugin/Optimization/OptimizationDateTimeParameter/Constructor/"
---

> Documentation index for agents: https://help.ctrader.com/ctrader-algo/llms.txt · machine index: https://help.ctrader.com/ctrader-algo/api.json

# OptimizationDateTimeParameter constructor

Member of [OptimizationDateTimeParameter](https://help.ctrader.com/ctrader-algo/references/Plugin/Optimization/OptimizationDateTimeParameter/index.md).

## OptimizationDateTimeParameter(string name, DateTime min, DateTime max, TimeSpan step)

Optimizes the parameter over the range the minimum to the maximum by the step.

Environments: Desktop supported · CLI not supported · Cloud not supported.

- CLI: Available to plugins only, and plugins cannot run in the CLI.
- Cloud: Available to plugins only, and plugins cannot run in the cloud.

C#:

```csharp
public OptimizationDateTimeParameter(string name, DateTime min, DateTime max, TimeSpan step)
```

Python:

```python
OptimizationDateTimeParameter(name: str, min: DateTime, max: DateTime, step: TimeSpan)
```

### Parameters

- `name` (`string`, Python `str`): The cBot parameter name.
- `min` (`DateTime`, Python `DateTime`): The inclusive minimum of the range.
- `max` (`DateTime`, Python `DateTime`): The inclusive maximum of the range.
- `step` (`TimeSpan`, Python `TimeSpan`): The step of the range, as a time span.

Available since cAlgo.API 5.9.

### Examples

C#:

```csharp
var parameter = new OptimizationDateTimeParameter("SessionStart", new DateTime(2025, 1, 1, 6, 0, 0), new DateTime(2025, 1, 1, 12, 0, 0), TimeSpan.FromMinutes(30));
Print("{0} is optimized: {1}", parameter.Name, parameter.IsOptimized);
```

Python:

```python
from System import DateTime, TimeSpan
parameter = OptimizationDateTimeParameter("SessionStart", DateTime(2025, 1, 1, 6, 0, 0), DateTime(2025, 1, 1, 12, 0, 0), TimeSpan.FromMinutes(30))
api.Print(f"{parameter.Name} is optimized: {parameter.IsOptimized}")
```

## OptimizationDateTimeParameter(string name, DateTime value)

Holds the parameter fixed at the given value.

Environments: Desktop supported · CLI not supported · Cloud not supported.

- CLI: Available to plugins only, and plugins cannot run in the CLI.
- Cloud: Available to plugins only, and plugins cannot run in the cloud.

C#:

```csharp
public OptimizationDateTimeParameter(string name, DateTime value)
```

Python:

```python
OptimizationDateTimeParameter(name: str, value: DateTime)
```

### Parameters

- `name` (`string`, Python `str`): The cBot parameter name.
- `value` (`DateTime`, Python `DateTime`): The fixed value.

Available since cAlgo.API 5.9.

### Examples

C#:

```csharp
var parameter = new OptimizationDateTimeParameter("SessionStart", new DateTime(2025, 1, 1, 8, 0, 0));
Print("{0} is fixed at {1}", parameter.Name, parameter.Value);
```

Python:

```python
from System import DateTime
parameter = OptimizationDateTimeParameter("SessionStart", DateTime(2025, 1, 1, 8, 0, 0))
api.Print(f"{parameter.Name} is fixed at {parameter.Value}")
```

## OptimizationDateTimeParameter(OptimizationDateTimeParameter original)



Environments: Desktop supported · CLI not supported · Cloud not supported.

- CLI: Available to plugins only, and plugins cannot run in the CLI.
- Cloud: Available to plugins only, and plugins cannot run in the cloud.

C#:

```csharp
public OptimizationDateTimeParameter(OptimizationDateTimeParameter original)
```

Python:

```python
OptimizationDateTimeParameter(original: OptimizationDateTimeParameter)
```

### Parameters

- `original` (`OptimizationDateTimeParameter`, Python `OptimizationDateTimeParameter`):

Available since cAlgo.API 5.9.

