> For the complete documentation index, see [llms.txt](https://help.signals.network/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://help.signals.network/framework-documentation/untitled/methods/orders/enterlong.md).

# EnterLong()

Generates a Buy Market order to enter a long position.

### Single Market Strategy

#### Parameters

| Name    | Type   | Description                                                                                        |
| ------- | ------ | -------------------------------------------------------------------------------------------------- |
| `label` | string | Optional parameter which can be used for labeling the signal generated when an order is triggered. |

{% hint style="warning" %}
The browser app doesn't show the custom labels in the UI at the moment. It will be updated in the future release.
{% endhint %}

#### Example

{% tabs %}
{% tab title="Basic example" %}

```csharp
// Generates a Buy Market order to enter a long position
EnterLong();
```

{% endtab %}

{% tab title="Complete example" %}

```csharp
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)
            {
                // Generates a buy market order to enter a long position
                EnterLong();
            }
            else if (smaFast.Value < smaSlow.Value && Position.InPosition)
            {
                ExitLong();
            }
        });
    }
}
```

{% endtab %}
{% endtabs %}

### Multi Market Strategy

In MMS you need to specify the market on which to execute the order as the very first argument.

#### Parameters

| Name     | Type                                                             | Description                                                                                        |
| -------- | ---------------------------------------------------------------- | -------------------------------------------------------------------------------------------------- |
| `market` | [Market](/framework-documentation/untitled/properties/market.md) | Market on which to execute the order.                                                              |
| `label`  | string                                                           | Optional parameter which can be used for labeling the signal generated when an order is triggered. |

{% hint style="warning" %}
The browser app doesn't show the custom labels in the UI at the moment. It will be updated in the future release.
{% endhint %}

#### Example

{% tabs %}
{% tab title="Basic example" %}

```csharp
// Generates a Buy Market order to enter a long position on the first
// selected market
EnterLong(Markets[0]);
```

{% endtab %}

{% tab title="Complete example" %}

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

// This code represents the Crossover strategy. 

public class MyStrategy : MultiMarketsStrategy
{
    private Bars hourlyBarsFirstAsset;
    private SMA smaSlowFirstAsset;
    private SMA smaFastFirstAsset;

    private Bars hourlyBarsSecondAsset;
    private SMA smaSlowSecondAsset;
    private SMA smaFastSecondAsset;

    private Bars hourlyBars;
    private SMA smaSlow;
    private SMA smaFast;


    private int fast = 10;
    private int slow = 25;

    private Market firstMarket;
    private Market secondMarket;

    public override void Setup(DataMarketplace data, IndicatorsMarketplace indicators)
        {
            firstMarket = Markets[0];
            secondMarket = Markets[1];

            hourlyBarsFirstAsset = data.Bars(BarPeriodType.Hour, 1).OnMarket(firstMarket).WithOffset(25);
            smaSlowFirstAsset = indicators.SMA(slow).OnSeries(hourlyBarsFirstAsset.Close);
            smaFastFirstAsset = indicators.SMA(fast).OnSeries(hourlyBarsFirstAsset.Close);

            hourlyBarsSecondAsset = data.Bars(BarPeriodType.Hour, 1).OnMarket(secondMarket).WithOffset(25);
            smaSlowSecondAsset = indicators.SMA(slow).OnSeries(hourlyBarsSecondAsset.Close);
            smaFastSecondAsset = indicators.SMA(fast).OnSeries(hourlyBarsSecondAsset.Close);
        }

    public override void RegisterActions()
    {
        OnUpdateOf(hourlyBarsFirstAsset).Do(() =>
        {
            if (smaFastFirstAsset.Value > smaSlowFirstAsset.Value && !Position.InPosition)
            {
                EnterLong(firstMarket);
            }
            else if (smaFastFirstAsset.Value < smaSlowFirstAsset.Value && Position.InPosition && Position.Market == firstMarket)
            {
                ExitLong(firstMarket);
            }
        });

        OnUpdateOf(hourlyBarsSecondAsset).Do(() =>
        {
            if (smaFastSecondAsset.Value > smaSlowSecondAsset.Value && !Position.InPosition)
            {
                EnterLong(secondMarket);
            }
            else if (smaFastSecondAsset.Value < smaSlowSecondAsset.Value && Position.InPosition && Position.Market == secondMarket)
            {
                ExitLong(secondMarket);
            }
        });
    }
}
```

{% endtab %}
{% endtabs %}
