---
id: "T:cAlgo.API.Internals.Algo"
kind: "class"
namespace: "cAlgo.API.Internals"
url: "https://help.ctrader.com/ctrader-algo/references/General/Algo/"
---

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

# Algo (class)

The container class for the main cAlgo.API Interfaces.

Environments: Desktop supported · CLI supported · Cloud supported.

## Definition

```csharp
public class Algo
```

## Examples

C#:

```csharp
public partial class AlgoSample : Robot
{
    protected override void OnStart()
    {
        Print("Symbol: {0}, TimeFrame: {1}, Server time: {2}", SymbolName, TimeFrame, Server.Time);
        Print("Open positions: {0}, Pending orders: {1}", Positions.Count, PendingOrders.Count);
    }
}
```

Python:

```python
class AlgoSample():
    def on_start(self):
        api.Print(f"Symbol: {api.SymbolName}, TimeFrame: {api.TimeFrame}, Server time: {api.Server.Time}")
        api.Print(f"Open positions: {api.Positions.Count}, Pending orders: {api.PendingOrders.Count}")
```

config.json:

```json
{
  "AccessRights": "None"
}
```

## Methods

- `public void BeginInvokeOnMainThread(Action action)` — Invokes asynchronously the specified code on the main cBot or Indicator thread. [details](https://help.ctrader.com/ctrader-algo/references/General/Algo/BeginInvokeOnMainThread/index.md)
- `public IndicatorDataSeries CreateDataSeries()` — Initialization of an IndicatorDataSeries. [details](https://help.ctrader.com/ctrader-algo/references/General/Algo/CreateDataSeries/index.md)
- `protected internal void OnException(Exception exception)` — Called on each unhandled exception. [details](https://help.ctrader.com/ctrader-algo/references/General/Algo/OnException/index.md)
- `protected void OnTimer()` — Called when the timer interval has elapsed. [details](https://help.ctrader.com/ctrader-algo/references/General/Algo/OnTimer/index.md)
- `public void Print(object value)` — Prints text representation of the specified object to the log. [details](https://help.ctrader.com/ctrader-algo/references/General/Algo/Print/index.md)
- `public void Print(object[] parameters)` — Prints a message to the Log [details](https://help.ctrader.com/ctrader-algo/references/General/Algo/Print/index.md)
- `public void Print(string message, object[] parameters)` — Prints a message to the Log. [details](https://help.ctrader.com/ctrader-algo/references/General/Algo/Print/index.md)
- `public void RefreshData()` — Updates Bars, Positions, PendingOrders, History, etc. And sends postponed events after Thread sleep call. If you put the main thread on sleep by calling Thread sleep method then you have to call RefreshData after Thread wakes up to send the postponed events while thread was sleeping. [details](https://help.ctrader.com/ctrader-algo/references/General/Algo/RefreshData/index.md)
- `public void Sleep(TimeSpan timespan)` — Suspends the algorithm until the specified timespan elapses. [details](https://help.ctrader.com/ctrader-algo/references/General/Algo/Sleep/index.md)
- `public void Sleep(int milliseconds)` — Suspends the algorithm until the specified number of milliseconds elapses. [details](https://help.ctrader.com/ctrader-algo/references/General/Algo/Sleep/index.md)
- `public void Sleep(DateTime dateTime)` — Suspends the algorithm until the specified datetime . [details](https://help.ctrader.com/ctrader-algo/references/General/Algo/Sleep/index.md)

## Properties

- `public AlgoRegistry AlgoRegistry {get;}` — Provides access to installed Algorithms. [details](https://help.ctrader.com/ctrader-algo/references/General/Algo/AlgoRegistry/index.md)
- `public Application Application {get;}` — Represents the application. [details](https://help.ctrader.com/ctrader-algo/references/General/Algo/Application/index.md)
- `public double Ask {get;}` — Gets the symbol ask price. [details](https://help.ctrader.com/ctrader-algo/references/General/Algo/Ask/index.md)
- `public IAssetConverter AssetConverter {get;}` — Converts an asset to another asset. [details](https://help.ctrader.com/ctrader-algo/references/General/Algo/AssetConverter/index.md)
- `public Assets Assets {get;}` — Returns list of all available assets. [details](https://help.ctrader.com/ctrader-algo/references/General/Algo/Assets/index.md)
- `public Bars Bars {get;}` — The collection of Bar objects. [details](https://help.ctrader.com/ctrader-algo/references/General/Algo/Bars/index.md)
- `public double Bid {get;}` — Gets the symbol bid price. [details](https://help.ctrader.com/ctrader-algo/references/General/Algo/Bid/index.md)
- `public Chart Chart {get;}` — Represents the chart where cBot or Indicator is launched. [details](https://help.ctrader.com/ctrader-algo/references/General/Algo/Chart/index.md)
- `public ChartIndicators ChartIndicators {get;}` — Gets the ChartIndicators of an algorithm. [details](https://help.ctrader.com/ctrader-algo/references/General/Algo/ChartIndicators/index.md)
- `public ChartRobots ChartRobots {get;}` — Gets the ChartRobots of an algorithm. [details](https://help.ctrader.com/ctrader-algo/references/General/Algo/ChartRobots/index.md)
- `public ChartTemplates ChartTemplates {get;}` — Provides access to Chart Templates. [details](https://help.ctrader.com/ctrader-algo/references/General/Algo/ChartTemplates/index.md)
- `public Clipboard Clipboard {get;}` — Provides access to system Clipboard. [details](https://help.ctrader.com/ctrader-algo/references/General/Algo/Clipboard/index.md)
- `public Compiler Compiler {get;}` — Provides access to algo compiler. [details](https://help.ctrader.com/ctrader-algo/references/General/Algo/Compiler/index.md)
- `public HistoricalOrders HistoricalOrders {get;}` — Provides access to historical orders. [details](https://help.ctrader.com/ctrader-algo/references/General/Algo/HistoricalOrders/index.md)
- `public History History {get;}` — Represents the collection of all historical trades of the account. [details](https://help.ctrader.com/ctrader-algo/references/General/Algo/History/index.md)
- `public Http Http {get;}` — Send HTTP requests. [details](https://help.ctrader.com/ctrader-algo/references/General/Algo/Http/index.md)
- `public IIndicatorsAccessor Indicators {get;}` — Access to the built-in Indicators. [details](https://help.ctrader.com/ctrader-algo/references/General/Algo/Indicators/index.md)
- `public string InstanceId {get;}` — Returns unique ID of current running instance. [details](https://help.ctrader.com/ctrader-algo/references/General/Algo/InstanceId/index.md)
- `public string InstanceTitle {get; set;}` — Gets or sets instance title. [details](https://help.ctrader.com/ctrader-algo/references/General/Algo/InstanceTitle/index.md)
- `public bool IsBacktesting {get;}` — True if a cBot is in the Backtesting mode, otherwise False. [details](https://help.ctrader.com/ctrader-algo/references/General/Algo/IsBacktesting/index.md)
- `public LocalStorage LocalStorage {get;}` — Access the local storage API. [details](https://help.ctrader.com/ctrader-algo/references/General/Algo/LocalStorage/index.md)
- `public MarketData MarketData {get;}` — Provides access to the Depth of Market Data. [details](https://help.ctrader.com/ctrader-algo/references/General/Algo/MarketData/index.md)
- `public MarketSession MarketSessions {get;}` — Returns current market sessions. [details](https://help.ctrader.com/ctrader-algo/references/General/Algo/MarketSessions/index.md)
- `public Messages Messages {get;}` — Access the messaging API. [details](https://help.ctrader.com/ctrader-algo/references/General/Algo/Messages/index.md)
- `public INotifications Notifications {get;}` — Represents the notifications, such as sounds and email. [details](https://help.ctrader.com/ctrader-algo/references/General/Algo/Notifications/index.md)
- `public PendingOrders PendingOrders {get;}` — The array of all Pending Orders of the account. [details](https://help.ctrader.com/ctrader-algo/references/General/Algo/PendingOrders/index.md)
- `public Positions Positions {get;}` — The list of all open positions of the account. [details](https://help.ctrader.com/ctrader-algo/references/General/Algo/Positions/index.md)
- `public PriceAlerts PriceAlerts {get;}` — Provides access to Price Alerts. [details](https://help.ctrader.com/ctrader-algo/references/General/Algo/PriceAlerts/index.md)
- `public RunningMode RunningMode {get;}` — Defines if a cBot is running in real time, in the silent backtesting mode, in the visual backtesting mode, or in the optimization mode. [details](https://help.ctrader.com/ctrader-algo/references/General/Algo/RunningMode/index.md)
- `public IServer Server {get;}` — Server related information. [details](https://help.ctrader.com/ctrader-algo/references/General/Algo/Server/index.md)
- `public Symbol Symbol {get;}` — Represents the current symbol provides access to its properties and certain methods [details](https://help.ctrader.com/ctrader-algo/references/General/Algo/Symbol/index.md)
- `public string SymbolName {get;}` — Gets or sets the symbol name. [details](https://help.ctrader.com/ctrader-algo/references/General/Algo/SymbolName/index.md)
- `public Symbols Symbols {get;}` — Gets the symbol names. [details](https://help.ctrader.com/ctrader-algo/references/General/Algo/Symbols/index.md)
- `public DateTime Time {get;}` — Returns the current server time. The shortcut to the Server.Time property. [details](https://help.ctrader.com/ctrader-algo/references/General/Algo/Time/index.md)
- `public TimeFrame TimeFrame {get;}` — Access to the TimeFrame values. [details](https://help.ctrader.com/ctrader-algo/references/General/Algo/TimeFrame/index.md)
- `public TimeFrames TimeFrames {get;}` — Gets collection of available TimeFrames. [details](https://help.ctrader.com/ctrader-algo/references/General/Algo/TimeFrames/index.md)
- `public DateTime TimeInUtc {get;}` — Returns the current server time in UTC. The shortcut to the Server.TimeInUtc property. [details](https://help.ctrader.com/ctrader-algo/references/General/Algo/TimeInUtc/index.md)
- `public TimeZoneInfo TimeZone {get;}` — TimeZone of a cBot or an Indicator. [details](https://help.ctrader.com/ctrader-algo/references/General/Algo/TimeZone/index.md)
- `public Timer Timer {get;}` — Access to the Timer object. [details](https://help.ctrader.com/ctrader-algo/references/General/Algo/Timer/index.md)
- `public Transactions Transactions {get;}` — Access account transactions. [details](https://help.ctrader.com/ctrader-algo/references/General/Algo/Transactions/index.md)
- `public Watchlists Watchlists {get;}` — Gets the watchlist. [details](https://help.ctrader.com/ctrader-algo/references/General/Algo/Watchlists/index.md)

## Events

- `public event Action<MarketSessionChangedEventArgs> MarketSessionsChanged;` — Occurs when market sessions change. [details](https://help.ctrader.com/ctrader-algo/references/General/Algo/MarketSessionsChanged/index.md)

## Deprecated members

- `public ChartObjects ChartObjects {get;}` — Use Chart instead.
- `public MarketSeries MarketSeries {get;}` — Deprecated.

