Signals Help Center
  • About Signals
  • Getting Started
    • Tutorials
      • Your First Strategy
        • Create a New Strategy
        • Define Variables
        • Define Setup Method
        • Define Register Actions Method
        • Backtest
        • Deploy Strategy & Start Receiving Signals
    • Dashboard
    • Strategies
      • Strategy Tools and Settings
        • Editor
        • Strategy Detail
        • Backtests
          • Backtest Detail
          • Deploying a Backtest
          • Delete a Backtest
        • Deployments
          • Deployment Detail
          • Edit About, Rules & Alternative Markets
          • Undeploy an Active Deployment
          • (Un)Publish a Deployment
          • (Un)Follow a Deployment
          • Delete a Deployment
        • Followings
          • Following Detail
          • Unfollow a Deployment
          • Delete Record of Following
      • Strategies Marketplace
        • Follow a Strategy
        • Publish Strategy
      • Strategy Details
      • Strategy Metrics
        • Initial Capital
        • Initial Capital (USDT)
        • Strategy Balance
        • Strategy Balance (USDT)
        • Total Performance
        • Total Performance (USDT)
      • Strategy Types
        • Single Market Strategy
        • Multi Market Strategy
    • Account
      • Change Plan
      • Change or Reset Password
      • Change Name, Username, or E-mail
  • Framework Documentation
    • Strategy
      • Methods
        • Setup()
          • DataMarketplace
          • IndicatorsMarketplace
        • RegisterActions()
        • Orders Management
          • CancelOrder()
          • CancelAllPendingOrders()
          • EnterLong()
          • EnterLongLimit()
          • EnterShort()
          • EnterLongStop()
          • EnterShortLimit()
          • ExitLong()
          • EnterShortStop()
          • ExitLongLimit()
          • ExitShort()
          • ExitShortLimit()
          • ExitLongStop()
          • ExitShortStop()
        • Risk Management
          • SetProfitTarget()
          • SetStopLoss()
      • Properties
        • Market
        • Markets
        • PendingOrders
        • Position
        • Time
      • Types
        • IOrder
        • PendingOrder
    • Data
    • Logs
  • Knowledge Base
    • Vocabulary
      • Base currency
      • Deployment
      • Following
      • Quote currency
      • Strategy
    • Technical Indicators
      • Oscillators
        • Average Directional Index (ADX)
        • Momentum Indicator (MOM)
        • Moving Average Convergence Divergence (MACD)
        • Relative Strength Index (RSI)
        • Stochastic RSI (STOCH RSI)
      • Volatility
        • Average True Range (ATR)
        • Bollinger Bands (BB)
      • Trend Analysis
        • Exponential Moving Average (EMA)
        • Simple Moving Average (SMA)
        • Volume-weighted Moving Average (VWMA)
        • Weighted Moving Average (WMA)
      • Volume
        • Accumulation/Distribution Line (ADL)
  • Have a question?
    • FAQ
    • Ask on the forums
    • Contact us
Powered by GitBook
On this page
  • Select market(s) from the Data Marketplace
  • Initialize bars on the market(s)
  • Bars Method
  • OnMarket Method
  • WithOffset Method
  1. Framework Documentation
  2. Strategy
  3. Methods
  4. Setup()

DataMarketplace

Object for accessing data from Data Marketplace.

PreviousSetup()NextIndicatorsMarketplace

Last updated 5 years ago

Signals Framework is designed to enable you to create strategies based on any data stream. At the moment, we are offering historical data from crypto exchanges, which you can access in your strategy through the Bars method of the DataMarketplace object.

Select market(s) from the Data Marketplace

Single Market Strategies

For , the dropdown in the Markets section in the editor sidebar lets you select a single market that wil be available for your strategy. At any time, you can select a different market from the dropdown and replace the one already connected with your strategy. This way you can run the the model on different markets without a need of changing a single line of code.

Multi Market Strategies

Initialize bars on the market(s)

Bars Method

Define the time scale of the constructed bars by specifing the period type and length. For 5-minute bars, the period type should be set to Minute and period to 5.

Parameters

Name

Type

Description

periodType

BarPeriodType

Period type together with period defines the time scale of Bars which you want to use. PeriodType could be Minute, Hour, or Day.

period

int

The number of periods which define the size of the Bar. For 5-minute bars, the BarPeriodType should be set to Minute and period to 5.

Example

// Using Bars method for initializing 1 day bars
dailyBars = data.Bars(BarPeriodType.Day, 1)

// Using Bars method for initializing 5 hours bars
fiveHourBar = data.Bars(BarPeriodType.Hour, 5)
using Signals.DataSeries.Bars;
using Signals.Framework;

public class MyStrategy : SingleMarketStrategy
{
    private Bars dailyBars;

    public override void Setup(DataMarketplace data, IndicatorsMarketplace indicators)
    {
        dailyBars = data.Bars(BarPeriodType.Day, 1).WithOffset(2);
    }

    public override void RegisterActions()
    {
        OnUpdateOf(dailyBars).Do(() =>
        {
            // Prints the latest close value value
            Log("The latest close value is " + dailyBars[0].Close.ToString());
            
            // Prints the previous close value value
            Log("The previous close value is " + dailyBars[1].Close.ToString());
        });
    }
}

OnMarket Method

Parameters

Name

Type

Description

market

Market on which you want to construct the data series.

Example

// Initiating 1 day bars with the second selected market
ethBars = data.Bars(BarPeriodType.Day, 1).OnMarket(Markets[1])
using Signals.DataSeries.Bars;
using Signals.Framework;

public class MyStrategy : SingleMarketStrategy
{
    private Bars dailyBarsFirstMarket;
    private Bars dailyBarsSecondMarket;

    public override void Setup(DataMarketplace data, IndicatorsMarketplace indicators)
    {
        dailyBarsFirstMarket = data.Bars(BarPeriodType.Day, 1).OnMarket(Markets[0]).WithOffset(25);
        dailyBarsSecondMarket = data.Bars(BarPeriodType.Day, 1).OnMarket(Markets[2]).WithOffset(25);
    }

    public override void RegisterActions()
    {
        OnUpdateOf(dailyBarsFirstMarket).Do(() =>
        {
            // Prints the latest close value on the first selected market
            Log("1st Market: The latest close value is " + dailyBarsFirstMarket[0].Close.ToString());
            
            // Prints the previous close value on the first selected market
            Log("1st Market: The previous close value is " + dailyBarsFirstMarket[1].Close.ToString());
        });
        
        OnUpdateOf(dailyBarsSecondMarket).Do(() =>
        {
            // Prints the latest close value on the second selected market
            Log("2nd Market: The latest close value is " + dailyBarsSecondMarket[0].Close.ToString());
            
            // Prints the previous close value on the second selected market
            Log("2nd Market: The previous close value is " + dailyBarsSecondMarket[1].Close.ToString());
        });
    }
}

WithOffset Method

After you define what kind of data you want to use in your strategy, you need to also define the number of data points which your strategy needs to operate on, i.e. how many historical bars you can access at any moment.

Parameters

Name

Type

Description

offset

int

The number of bars that you want to access in the logic of your strategy.

Example

// Initiating 5 minute bars with 10 bars into the history
fiveMinuteBars = data.Bars(BarPeriodType.Minutes, 5).WithOffset(10);

// Initiating daily bars with 2 bars into the history
dailyBars = data.Bars(BarPeriodType.Day, 1).WithOffset(2);

if (dailyBars[0].Close > dailyBars[1].Close) {
    Log("Today's close value is higher.");
}
using Signals.DataSeries.Bars;
using Signals.Framework;

public class MyStrategy : SingleMarketStrategy
{
    private Bars dailyBars;

    public override void Setup(DataMarketplace data, IndicatorsMarketplace indicators)
    {
        dailyBars = data.Bars(BarPeriodType.Day, 1).WithOffset(2);
    }

    public override void RegisterActions()
    {
        OnUpdateOf(dailyBars).Do(() =>
        {
            // Prints the latest close value value
            Log("The latest close value is " + dailyBars[0].Close.ToString());
            
            // Prints the previous close value value
            Log("The previous close value is " + dailyBars[1].Close.ToString());
        });
    }
}

For , you can select multiple markets for a single strategy. Each selected market has indicated and index to the right of the dropdown, which can be used in code to reference the market. In the code, you can access the concrete market with array index operator indicated to the right next to each dropdown - e.g. use Markets[1] for the ETH/USDT asset pairing on Poloniex.

This is an optional method, which is useful only in . It allows you to define on which you want to construct the series on. You don't need to use this method with - if this method is not used, the default value is applied - Markets[0] - i.e. the first market selected in the strategy settings in the sidebar.

Multi Market Strategies
Multi Market Strategies
market
Single Market Strategies
Market
Single Market Strategies
Selecting a third data series, it will be accessible through Markets[2] in the code.