---
id: "P:cAlgo.API.OptimizationProcess.BestPass"
kind: "property"
type: "T:cAlgo.API.OptimizationProcess"
url: "https://help.ctrader.com/ctrader-algo/references/Plugin/Optimization/OptimizationProcess/BestPass/"
---

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

# OptimizationProcess.BestPass

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

## BestPass

Gets the best pass by the configured criteria or custom fitness, or null if no pass has completed.

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
OptimizationPass BestPass {get;}
```

Python:

```python
optimizationProcess.BestPass: OptimizationPass
```

### Returns

`OptimizationPass` — 

Available since cAlgo.API 5.9.

### Examples

C#:

```csharp
Optimization.PassCompleted += args =>
{
    var bestPass = args.Process.BestPass;
    if (bestPass != null)
        Print("Current best pass: {0}, fitness {1}", bestPass.Id, bestPass.Fitness);
};
```

Python:

```python
def on_start(self):
    api.Optimization.PassCompleted += self.on_pass_completed

def on_pass_completed(self, args):
    bestPass = args.Process.BestPass
    if bestPass is not None:
        api.Print(f"Current best pass: {bestPass.Id}, fitness {bestPass.Fitness}")
```

