Table of Contents

Class StrategyHelper

Namespace
StockSharp.Algo.Strategies
Assembly
StockSharp.Algo.dll

Extension class for Strategy.

public static class StrategyHelper
Inheritance
StrategyHelper
Inherited Members

Methods

BuyAtLimit(Strategy, decimal, decimal?)

To create the initialized order object for buy.

[Obsolete("Use Strategy.BuyLimit method.")]
public static Order BuyAtLimit(this Strategy strategy, decimal price, decimal? volume = null)

Parameters

strategy Strategy

Strategy.

price decimal

Price.

volume decimal?

The volume. If null value is passed, then Volume value is used.

Returns

Order

The initialized order object.

Remarks

The order is not registered, only the object is created.

BuyAtMarket(Strategy, decimal?)

To create initialized object of buy order at market price.

[Obsolete("Use Strategy.BuyMarket method.")]
public static Order BuyAtMarket(this Strategy strategy, decimal? volume = null)

Parameters

strategy Strategy

Strategy.

volume decimal?

The volume. If null value is passed, then Volume value is used.

Returns

Order

The initialized order object.

Remarks

The order is not registered, only the object is created.

Cancel(IMarketRule, Order)

To create an action, cancelling the order.

public static IMarketRule Cancel(this IMarketRule rule, Order order)

Parameters

rule IMarketRule

Rule.

order Order

The order to be cancelled.

Returns

IMarketRule

Rule.

GetIsEmulation(Strategy)

To get the strategy start-up mode (paper trading or real).

[Obsolete("Use Strategy.IsBacktesting property.")]
public static bool GetIsEmulation(this Strategy strategy)

Parameters

strategy Strategy

Strategy.

Returns

bool

If the paper trading mode is used - true, otherwise - false.

Protect(MarketRule<Order, MyTrade>, Unit, Unit)

To create the action protecting orders by strategies TakeProfitStrategy and StopLossStrategy.

[Obsolete("Use ProtectiveController class.")]
public static MarketRule<Order, MyTrade> Protect(this MarketRule<Order, MyTrade> rule, Unit takePriceDelta, Unit stopPriceDelta)

Parameters

rule MarketRule<Order, MyTrade>

The rule for new orders.

takePriceDelta Unit

The delta from the price of the protected order, by which the protective take profit order is to be registered.

stopPriceDelta Unit

The delta from the price of the protected order, by which the protective stop loss order is to be registered.

Returns

MarketRule<Order, MyTrade>

Rule.

Protect(MarketRule<Order, MyTrade>, Func<MyTrade, TakeProfitStrategy>, Func<MyTrade, StopLossStrategy>)

To create the action protecting orders by strategies TakeProfitStrategy and StopLossStrategy.

[Obsolete("Use ProtectiveController class.")]
public static MarketRule<Order, MyTrade> Protect(this MarketRule<Order, MyTrade> rule, Func<MyTrade, TakeProfitStrategy> takeProfit, Func<MyTrade, StopLossStrategy> stopLoss)

Parameters

rule MarketRule<Order, MyTrade>

The rule for new orders.

takeProfit Func<MyTrade, TakeProfitStrategy>

The function that creates the strategy TakeProfitStrategy by the order.

stopLoss Func<MyTrade, StopLossStrategy>

The function that creates the strategy StopLossStrategy by the order.

Returns

MarketRule<Order, MyTrade>

Rule.

ReRegister(IMarketRule, Order, Order)

To create an action, re-registering the order.

public static IMarketRule ReRegister(this IMarketRule rule, Order oldOrder, Order newOrder)

Parameters

rule IMarketRule

Rule.

oldOrder Order

The order to be re-registered.

newOrder Order

Information about new order.

Returns

IMarketRule

Rule.

Register(IMarketRule, Order)

To create an action, registering the order.

public static IMarketRule Register(this IMarketRule rule, Order order)

Parameters

rule IMarketRule

Rule.

order Order

The order to be registered.

Returns

IMarketRule

Rule.

SellAtLimit(Strategy, decimal, decimal?)

To create the initialized order object for sell.

[Obsolete("Use Strategy.SellLimit method.")]
public static Order SellAtLimit(this Strategy strategy, decimal price, decimal? volume = null)

Parameters

strategy Strategy

Strategy.

price decimal

Price.

volume decimal?

The volume. If null value is passed, then Volume value is used.

Returns

Order

The initialized order object.

Remarks

The order is not registered, only the object is created.

SellAtMarket(Strategy, decimal?)

To create the initialized order object of sell order at market price.

[Obsolete("Use Strategy.SellMarket method.")]
public static Order SellAtMarket(this Strategy strategy, decimal? volume = null)

Parameters

strategy Strategy

Strategy.

volume decimal?

The volume. If null value is passed, then Volume value is used.

Returns

Order

The initialized order object.

Remarks

The order is not registered, only the object is created.

SetIsEmulation(Strategy, bool)

To set the strategy start-up mode (paper trading or real).

[Obsolete("Use Strategy.IsBacktesting property.")]
public static void SetIsEmulation(this Strategy strategy, bool isEmulation)

Parameters

strategy Strategy

Strategy.

isEmulation bool

If the paper trading mode is used - true, otherwise - false.

WhenActivated(ProtectiveStrategy)

To create the rule for the event Activated.

[Obsolete("Use ProtectiveController class.")]
public static IMarketRule WhenActivated(this ProtectiveStrategy strategy)

Parameters

strategy ProtectiveStrategy

The strategy, by which the event will be monitored.

Returns

IMarketRule

Rule.

WhenError(Strategy, bool)

To create a rule for event of strategy error (transition of state ErrorState into Error).

public static MarketRule<Strategy, Exception> WhenError(this Strategy strategy, bool processChildStrategyErrors = false)

Parameters

strategy Strategy

The strategy, based on which error will be expected.

processChildStrategyErrors bool

Process the child strategies errors.

Returns

MarketRule<Strategy, Exception>

Rule.

WhenNewMyTrade(Strategy)

To create a rule for the event of occurrence new strategy trade.

public static MarketRule<Strategy, MyTrade> WhenNewMyTrade(this Strategy strategy)

Parameters

strategy Strategy

The strategy, based on which trade occurrence will be traced.

Returns

MarketRule<Strategy, MyTrade>

Rule.

WhenOrderChanged(Strategy)

To create a rule for event of change of any strategy order.

public static MarketRule<Strategy, Order> WhenOrderChanged(this Strategy strategy)

Parameters

strategy Strategy

The strategy, based on which orders change will be traced.

Returns

MarketRule<Strategy, Order>

Rule.

WhenOrderRegistered(Strategy)

To create a rule for event of occurrence of new strategy order.

public static MarketRule<Strategy, Order> WhenOrderRegistered(this Strategy strategy)

Parameters

strategy Strategy

The strategy, based on which order occurrence will be traced.

Returns

MarketRule<Strategy, Order>

Rule.

WhenPnLChanged(Strategy)

To create a rule for event of profit change.

public static MarketRule<Strategy, decimal> WhenPnLChanged(this Strategy strategy)

Parameters

strategy Strategy

The strategy, based on which the profit change will be traced.

Returns

MarketRule<Strategy, decimal>

Rule.

WhenPnLLess(Strategy, Unit)

To create a rule for event of profit reduction below the specified level.

public static MarketRule<Strategy, decimal> WhenPnLLess(this Strategy strategy, Unit value)

Parameters

strategy Strategy

The strategy, based on which the profit change will be traced.

value Unit

The level. If the Type type equals to Limit, specified price is set. Otherwise, shift value is specified.

Returns

MarketRule<Strategy, decimal>

Rule.

WhenPnLMore(Strategy, Unit)

To create a rule for event of profit increase above the specified level.

public static MarketRule<Strategy, decimal> WhenPnLMore(this Strategy strategy, Unit value)

Parameters

strategy Strategy

The strategy, based on which the profit change will be traced.

value Unit

The level. If the Type type equals to Limit, specified price is set. Otherwise, shift value is specified.

Returns

MarketRule<Strategy, decimal>

Rule.

WhenPositionChanged(Strategy)

To create a rule for the event of strategy position change.

public static MarketRule<Strategy, decimal> WhenPositionChanged(this Strategy strategy)

Parameters

strategy Strategy

The strategy, based on which position change will be traced.

Returns

MarketRule<Strategy, decimal>

Rule.

WhenPositionLess(Strategy, Unit)

To create a rule for event of position event reduction below the specified level.

public static MarketRule<Strategy, decimal> WhenPositionLess(this Strategy strategy, Unit value)

Parameters

strategy Strategy

The strategy, based on which position change will be traced.

value Unit

The level. If the Type type equals to Limit, specified price is set. Otherwise, shift value is specified.

Returns

MarketRule<Strategy, decimal>

Rule.

WhenPositionMore(Strategy, Unit)

To create a rule for event of position event increase above the specified level.

public static MarketRule<Strategy, decimal> WhenPositionMore(this Strategy strategy, Unit value)

Parameters

strategy Strategy

The strategy, based on which position change will be traced.

value Unit

The level. If the Type type equals to Limit, specified price is set. Otherwise, shift value is specified.

Returns

MarketRule<Strategy, decimal>

Rule.

WhenStarted(Strategy)

To create a rule for event of start of strategy operation.

public static MarketRule<Strategy, Strategy> WhenStarted(this Strategy strategy)

Parameters

strategy Strategy

The strategy, based on which the start of strategy operation will be expected.

Returns

MarketRule<Strategy, Strategy>

Rule.

WhenStopped(Strategy)

To create a rule for event full stop of strategy operation.

public static MarketRule<Strategy, Strategy> WhenStopped(this Strategy strategy)

Parameters

strategy Strategy

The strategy, based on which the full stop will be expected.

Returns

MarketRule<Strategy, Strategy>

Rule.

WhenStopping(Strategy)

To create a rule for event of beginning of the strategy operation stop.

public static MarketRule<Strategy, Strategy> WhenStopping(this Strategy strategy)

Parameters

strategy Strategy

The strategy, based on which the beginning of stop will be determined.

Returns

MarketRule<Strategy, Strategy>

Rule.

WhenWarning(Strategy)

To create a rule for event of strategy warning (transition of state ErrorState into Warning).

public static MarketRule<Strategy, Strategy> WhenWarning(this Strategy strategy)

Parameters

strategy Strategy

The strategy, based on which the warning will be expected.

Returns

MarketRule<Strategy, Strategy>

Rule.