Table of Contents

Class ChartStrategy

Namespace
ATAS.Strategies.Chart
Assembly
ATAS.Strategies.dll

Represents an abstract class for a chart strategy that extends the functionality of an Indicator and implements the IChartStrategy and ILoggerSource interfaces.

public abstract class ChartStrategy : Indicator, INotifyPanelPropertyChanged, IPropertiesEditorOwner, IMarketTimeProvider, IChartStrategy, IStrategy, ILoggerSource
Inheritance
object
ChartStrategy
Implements
Inherited Members
Extension Methods

Constructors

ChartStrategy(bool)

Protected constructor for the ChartStrategy class.

protected ChartStrategy(bool useCandles = false)

Parameters

useCandles bool

A boolean value indicating whether candles are used.

Properties

AveragePrice

Gets the average price of the strategy's trades.

[Browsable(false)]
public decimal AveragePrice { get; }

Property Value

decimal

BestAsk

Gets the best ask market data associated with this chart strategy.

Added in ATAS 8.0.15.

[Browsable(false)]
public MarketDataArg BestAsk { get; }

Property Value

MarketDataArg

BestBid

Gets the best bid market data associated with this chart strategy.

Added in ATAS 8.0.15.

[Browsable(false)]
public MarketDataArg BestBid { get; }

Property Value

MarketDataArg

ChildLoggerSources

Gets the log sources that belong to the strategy in the logging settings tree.

Added in ATAS 8.0.15.

[Browsable(false)]
public ICachedCollection<ILoggerSource> ChildLoggerSources { get; }

Property Value

ICachedCollection<ILoggerSource>

ClosedPnL

Gets the closed profit and loss of the strategy.

[Browsable(false)]
public decimal ClosedPnL { get; }

Property Value

decimal

Connector

Added in ATAS 8.0.15.

[Browsable(false)]
public IDataFeedConnector Connector { get; set; }

Property Value

IDataFeedConnector

Remarks

Chart strategies are never given a connector: the host leaves this property null and the strategy works with the chart data it is attached to. Only ATM strategies get a value here, and it is the StrategyDataFeed wrapper - never a raw connector - so market-data subscriptions and security search throw System.NotSupportedException there as well.

CurrentPosition

Gets the current position volume of the strategy.

[Browsable(false)]
public decimal CurrentPosition { get; }

Property Value

decimal

IsActivated

Gets a value indicating whether the strategy is running (Started).

[Browsable(false)]
public bool IsActivated { get; }

Property Value

bool

LoggerId

Gets or sets the identifier of the strategy in the platform logging settings.

[Browsable(false)]
public Guid LoggerId { get; set; }

Property Value

Guid

LoggerName

Gets or sets the name the strategy writes its log messages under.

Added in ATAS 8.0.15.

[Browsable(false)]
public string LoggerName { get; set; }

Property Value

string

LoggingLevel

Gets or sets the lowest level of the messages the strategy writes to the log.

[Browsable(false)]
public LoggingLevel LoggingLevel { get; set; }

Property Value

LoggingLevel

MyTrades

Added in ATAS 8.0.15.

[Browsable(false)]
public IEnumerable<MyTrade> MyTrades { get; }

Property Value

IEnumerable<MyTrade>

OpenPnL

Gets the open profit and loss of the strategy.

[Browsable(false)]
public decimal OpenPnL { get; }

Property Value

decimal

Orders

Added in ATAS 8.0.15.

[Browsable(false)]
public IEnumerable<Order> Orders { get; }

Property Value

IEnumerable<Order>

ParentLoggerSource

Gets or sets the log source the strategy belongs to in the logging settings tree.

Added in ATAS 8.0.15.

[Browsable(false)]
public ILoggerSource ParentLoggerSource { get; set; }

Property Value

ILoggerSource

Portfolio

Added in ATAS 8.0.15.

[Browsable(false)]
public Portfolio Portfolio { get; set; }

Property Value

Portfolio

Remarks

This property does not support setting. Attempting to set this property will throw a System.NotSupportedException.

Exceptions

NotSupportedException

Security

Added in ATAS 8.0.15.

[Browsable(false)]
public Security Security { get; set; }

Property Value

Security

Remarks

This property does not support setting. Attempting to set this property will throw a System.NotSupportedException.

Exceptions

NotSupportedException

State

Gets the current state of the strategy.

[Browsable(false)]
public StrategyStates State { get; protected set; }

Property Value

StrategyStates

TPlusLimit

Gets or sets the T+ limits for the strategy.

[Browsable(false)]
public TPlusLimits? TPlusLimit { get; set; }

Property Value

TPlusLimits?

Remarks

This property does not support setting. Attempting to set this property will throw a System.NotSupportedException.

Exceptions

NotSupportedException

Methods

CanProcess(int)

Determines if the strategy can process data for the specified bar.

protected virtual bool CanProcess(int bar)

Parameters

bar int

The index of the current bar.

Returns

bool

true if the strategy can process data for the specified bar, false otherwise.

CancelOrder(Order)

Added in ATAS 8.0.15.

public void CancelOrder(Order order)

Parameters

order Order

The order to be canceled.

CancelOrderAsync(Order)

Added in ATAS 8.0.15.

public Task CancelOrderAsync(Order order)

Parameters

order Order

The order to be canceled.

Returns

Task

ModifyOrder(Order, Order)

Added in ATAS 8.0.15.

public void ModifyOrder(Order order, Order newOrder)

Parameters

order Order

The order to be modified.

newOrder Order

The new order with updated parameters.

ModifyOrderAsync(Order, Order)

Added in ATAS 8.0.15.

public Task ModifyOrderAsync(Order order, Order newOrder)

Parameters

order Order

The order to be modified.

newOrder Order

The new order with updated parameters.

Returns

Task

OnBestBidAskChanged(MarketDataArg)

Added in ATAS 8.0.15.

protected override void OnBestBidAskChanged(MarketDataArg depth)

Parameters

depth MarketDataArg

The MarketDataArg representing the market depth data.

OnContainerChanged(IIndicatorContainer)

Added in ATAS 8.0.15.

protected override void OnContainerChanged(IIndicatorContainer container)

Parameters

container IIndicatorContainer

The new value of the IIndicatorContainer that the indicator is attached to.

OnCurrentPositionChanged()

Method called when the volume of the current position changes.

protected virtual void OnCurrentPositionChanged()

OnDataProviderChanged(IIndicatorDataProvider, IIndicatorDataProvider)

Added in ATAS 8.0.15.

protected override void OnDataProviderChanged(IIndicatorDataProvider oldDataProvider, IIndicatorDataProvider newDataProvider)

Parameters

oldDataProvider IIndicatorDataProvider

The old IIndicatorDataProvider value.

newDataProvider IIndicatorDataProvider

The new IIndicatorDataProvider value.

OnNewMyTrade(MyTrade)

Added in ATAS 8.0.15.

protected override void OnNewMyTrade(MyTrade myTrade)

Parameters

myTrade MyTrade

The new trade executed by the indicator's own strategy.

OnStarted()

Method called when the strategy is started.

protected virtual void OnStarted()

OnStopped()

Method called when the strategy is stopped.

protected virtual void OnStopped()

OnStopping()

Method called when the strategy is stopping.

protected virtual void OnStopping()

OnSuspended()

Method called when the strategy is suspended.

protected virtual void OnSuspended()

OpenOrder(Order)

Added in ATAS 8.0.15.

public void OpenOrder(Order order)

Parameters

order Order

The order to be opened.

OpenOrderAsync(Order)

Added in ATAS 8.0.15.

public Task OpenOrderAsync(Order order)

Parameters

order Order

The order to be opened.

Returns

Task

RaiseShowNotification(string, string, LoggingLevel)

Raises a notification message with the specified message, title (optional), and logging level level. If the title is not provided, the name of the strategy is used as the title. Depending on the logging level, the message is logged using the corresponding logging method (Info, Warning, or Error). Finally, the ShowNotification event is raised to notify subscribers about the notification.

Added in ATAS 8.0.15.

protected void RaiseShowNotification(string message, string title = null, LoggingLevel level = LoggingLevel.Info)

Parameters

message string

The notification message.

title string

The title of the notification (optional).

level LoggingLevel

The logging level of the notification (defaults to Info).

SetProperty<TValue>(ref TValue, TValue, string, Action<TValue, TValue>)

Sets the value of a property propertyName to newValue. If the new value is different from the current value, the property is updated and a PropertyChanged event is raised. Additionally, if an onChanged action is provided, it will be invoked with the old and new values after the property has been updated. Returns true if the property was updated, false otherwise.

Added in ATAS 8.0.15.

protected bool SetProperty<TValue>(ref TValue storage, TValue newValue, string propertyName, Action<TValue, TValue> onChanged = null)

Parameters

storage TValue

A reference to the property value.

newValue TValue

The new value to be set.

propertyName string

The name of the property.

onChanged Action<TValue, TValue>

An optional action to be invoked when the property value changes.

Returns

bool

true if the property was updated, false otherwise.

Type Parameters

TValue

The type of the property value.

ShrinkPrice(decimal)

Rounds the given price price to the nearest tick size of the security and returns the result.

protected decimal ShrinkPrice(decimal price)

Parameters

price decimal

The price value to be rounded.

Returns

decimal

The rounded price value.

Start()

Starts the strategy without waiting for it; use StartAsync() instead.

[Obsolete("Use StartAsync instead.")]
public void Start()

StartAsync()

Added in ATAS 8.0.15.

public Task StartAsync()

Returns

Task

Stop()

Stops the strategy without waiting for it; use StopAsync() instead.

[Obsolete("Use StopAsync instead.")]
public void Stop()

StopAsync()

Added in ATAS 8.0.15.

public Task StopAsync()

Returns

Task

StopWithNotification(string)

Added in ATAS 8.0.15.

[Obsolete("Use StopAsync instead.")]
public void StopWithNotification(string message)

Parameters

message string

The message to be displayed as a notification.

StopWithNotificationAsync(string)

Shows a warning notification with the message and stops the strategy. Does nothing for a stopped strategy.

Added in ATAS 8.0.15.

public Task StopWithNotificationAsync(string message)

Parameters

message string

The text of the notification.

Returns

Task

A task that completes when the strategy is stopped.

Suspend()

Suspends the strategy without waiting for it; use SuspendAsync() instead.

[Obsolete("Use SuspendAsync instead.")]
public void Suspend()

SuspendAsync()

Suspends a running strategy: calls OnStopping(), moves it to Suspended, then calls OnSuspended() and OnStopped(). Does nothing for a stopped strategy.

Added in ATAS 8.0.15.

public Task SuspendAsync()

Returns

Task

A task that completes when the strategy is suspended.

Events

LoggerSettingsChanged

Occurs when LoggerName or LoggingLevel changes.

public event Action LoggerSettingsChanged

Event Type

Action

ShowNotification

Occurs when the strategy needs to show a notification or alert.

public event EventHandler<StrategyNotificationEventArgs> ShowNotification

Event Type

EventHandler<StrategyNotificationEventArgs>

StateChanged

Occurs when the state of the strategy changes.

public event EventHandler<StrategyStateChangedEventArgs> StateChanged

Event Type

EventHandler<StrategyStateChangedEventArgs>