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

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

# OptimizationTimeSpanParameter constructor

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

## OptimizationTimeSpanParameter(string name, TimeSpan min, TimeSpan 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 OptimizationTimeSpanParameter(string name, TimeSpan min, TimeSpan max, TimeSpan step)
```

Python:

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

### Parameters

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

Available since cAlgo.API 5.9.

### Examples

C#:

```csharp
var parameter = new OptimizationTimeSpanParameter("MaxHoldTime", TimeSpan.FromHours(1), TimeSpan.FromHours(8), TimeSpan.FromHours(1));
Print("{0} is optimized: {1}", parameter.Name, parameter.IsOptimized);
```

Python:

```python
from System import TimeSpan
parameter = OptimizationTimeSpanParameter("MaxHoldTime", TimeSpan.FromHours(1), TimeSpan.FromHours(8), TimeSpan.FromHours(1))
api.Print(f"{parameter.Name} is optimized: {parameter.IsOptimized}")
```

## OptimizationTimeSpanParameter(string name, TimeSpan 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 OptimizationTimeSpanParameter(string name, TimeSpan value)
```

Python:

```python
OptimizationTimeSpanParameter(name: str, value: TimeSpan)
```

### Parameters

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

Available since cAlgo.API 5.9.

### Examples

C#:

```csharp
var parameter = new OptimizationTimeSpanParameter("Cooldown", TimeSpan.FromMinutes(30));
Print("{0} is fixed at {1}", parameter.Name, parameter.Value);
```

Python:

```python
from System import TimeSpan
parameter = OptimizationTimeSpanParameter("Cooldown", TimeSpan.FromMinutes(30))
api.Print(f"{parameter.Name} is fixed at {parameter.Value}")
```

## OptimizationTimeSpanParameter(OptimizationTimeSpanParameter 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 OptimizationTimeSpanParameter(OptimizationTimeSpanParameter original)
```

Python:

```python
OptimizationTimeSpanParameter(original: OptimizationTimeSpanParameter)
```

### Parameters

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

Available since cAlgo.API 5.9.

