RegisterActions()

Use the RegisterActions method is to define the behavior of your strategy.

The purpose of this method is to define the behavior of your strategy. Once you define the Setup() method and have your strategy connected to data series and indicators, it's time to put it all together into your own trading model.

OnUpdateOf

Registration of a new action over data series can easily be done using the OnUpdateOffunction. We can demonstrate how to use this method with a dailyBars data series which should be defined in the the Setup() method. Everytime a new daily bar is created, the inside of the OnUpdateOf function is executed.

Parameters

Name

Type

Description

series

IDataSerires<TData>

Data series used as a trigger for calling the function.

Example

Every day (depending on the period of your data series), the strategy will perform the logic inside the OnUpdatefunction. You can define multiple actions over various data series and Signals Framework will take care of synchronizing those data series and execute your strategy logic.

Basic example
Complete example
Basic example
public override void RegisterActions()
{
OnUpdateOf(dailyBars).Do(() =>
{
// Your code to be executed everytime a new bar is created.
Log("The latest close value is: " + dailyBars[0].Close);
});
}
Complete example
using Signals.DataSeries.Bars;
using Signals.Framework;
using Signals.Indicators.SMA;
public class MyStrategy : SingleMarketStrategy
{
private Bars hourlyBars;
private SMA smaSlow;
private SMA smaFast;
private int fast = 10;
private int slow = 25;
public override void Setup(DataMarketplace data, IndicatorsMarketplace indicators)
{
hourlyBars = data.Bars(BarPeriodType.Hour, 1).WithOffset(25);
smaSlow = indicators.SMA(slow).OnSeries(hourlyBars.Close);
smaFast = indicators.SMA(fast).OnSeries(hourlyBars.Close);
}
public override void RegisterActions()
{
OnUpdateOf(hourlyBars).Do(() =>
{
if (smaFast.Value > smaSlow.Value && !Position.InPosition)
{
EnterLong();
}
else if (smaFast.Value < smaSlow.Value && Position.InPosition)
{
ExitLong();
}
});
}
}