# Define Setup Method

Now, let’s initialize our variables using the [Setup method](/framework-documentation/untitled/methods/setup.md) to define the data and indicators to be used. In this case, it will be the [simple moving averages (SMA)](/knowledge-base/indicators/trend-analysis/simple-moving-average-sma.md) and data sources that will be used to calculate technical indicator values.

### **Connecting to a data stream**

The [DataMarketplace](/framework-documentation/untitled/methods/setup/datamarketplace.md) object is an argument of the [Setup method](/framework-documentation/untitled/methods/setup.md) and you can use it in connecting your strategy to a data stream from the data marketplace which you want to use.

{% hint style="info" %}
[Intellisense](https://en.wikipedia.org/wiki/Intelligent_code_completion) is built into Signals online development environment and it will help you during the process of defining your strategy.
{% endhint %}

![](https://cdn-images-1.medium.com/max/800/0*_NIghG-j9Q0ERjm_.png)

In our case, we want hourly bars, so we will use [BarPeriodType.Hour](/framework-documentation/data.md#bars). The setup method, after we have connected our strategy to a data stream based on hourly bars, will look like this:

```csharp
public override void Setup(DataMarketplace data, IndicatorsMarketplace indicators)
{
  hourlyBars = data.Bars(BarPeriodType.Hour, 1).WithOffset(25);
}
```

The variable hourlyBars now contains historical pricing data with a 1 hour time-period. We are now able to receive hourly bars data in our strategy by simple indexing, starting from 0.

* *hourlyBars\[0]* — will get us a bar for the current hour
* *hourlyBars\[5]* — will get us a bar from 5 hours ago

*WithOffset(25)* means that our *Bar* variable will store values from up to 25 bars back. If our strategy needs to have access to older price values, we would need to increase the offset. Each price bar contains values for *open*, *high*, *low*, *close*, and *volume* for that specific period.

### **Connecting with indicators**

We already selected that we want to use SMA indicators when we defined our variables through the user interface. Now, let’s define the time period which we want to use for our SMAs and on which data stream we want to use them.

```csharp
public override void Setup(DataMarketplace data, IndicatorsMarketplace indicators) 
{
  hourlyBars = data.Bars(BarPeriodType.Hour, 1).WithOffset(25);
  smaSlow = indicators.SMA(25).OnSeries(hourlyBars.Close);
  smaFast = indicators.SMA(10).OnSeries(hourlyBars.Close);
}
```

The *smaSlow* variable contains the values of the Simple Moving Average indicator with a period of 25, calculated from hourly prices. The *smaFast* variable contains the values of the Simple Moving Average indicator with a period of 10, calculated from hourly prices. We can easily access the values of SMA through the indexing mechanism, so when we want to receive the value of *smaFast* for the current hour — *smaFast\[0]* — will do the job.

Here’s how the code looks once we set our variables and connect the strategy to hourly data and SMA indicators:

```csharp
using Signals.Indicators.SMA;
using Signals.DataSeries.Bars;
using Signals.Framework;

public class MyStrategy : SingleMarketStrategy
{
  private Bars hourlyBars;
  private SMA smaSlow;
  private SMA smaFast;
  
  public override void Setup(DataMarketplace data, IndicatorsMarketplace indicators) 
  {
    hourlyBars = data.Bars(BarPeriodType.Hour, 1).WithOffset(25);
    smaSlow = indicators.SMA(25).OnSeries(hourlyBars.Close);
    smaFast = indicators.SMA(10).OnSeries(hourlyBars.Close);
  }
  
  public override void RegisterActions()
  {
    // method for registering actions over the data e.g. your strategy logic
  }
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://help.signals.network/getting-started/tutorials/your-first-strategy/define-setup-method.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
