# TradersYard Social Trading

### **GetSharingSourceForTY(Action\<IEnumerable\<ISocialChannel>, Exception> callback)**

**Description**

This method is used to get the user TraderYard groups list where post can be shared. Can be used in OnInit() and OnCalculate()

**Usage**

```csharp
GetSharingSourceForTY(Action<IEnumerable<ISocialChannel>, Exception> callback);
```

**Parameter**

callback - method which will be called when will get a list of the user group in ISocialChannel and if some error will\
arise Exception will contain an explanation.

**Return Value**\
none

**Example**

```csharp
protected override void OnInit()
{
  GetSharingSourceForTY(GetChenalDes);
}

private void GetChenalDes(IEnumerable<ISocialChannel> channels, Exception exception)
{  
  if (exception == null)
  {
    foreach (var channel in channels)
      if (channel.DisplayName.Equals("My Account"))
        Log(string.Format("You can share post to {0}", channel.DisplayName),InfoLogLevel.Info);
  }
  else
  {
    Log(string.Format("You cant get TY channels list because: {0}", exception.Message), InfoLogLevel.Alert);
  }  
}
```

&#x20;

### **GetPost()**

**Description**

This method is used to get post from the current chart. Which will contain a chart image and message with instrument and timeframe.

**Usage**

```csharp
Chart.GetPost();
```

**Parameter**

none

**Return Value**\
SocialNetworkPost - post from the current chart which will contain chart image and message with instrument and timeframe.

**Example**

```csharp
protected override void OnCalculate()
{
  var post = Chart?.GetPost();
}
```

&#x20;

### **GetChartPostWithAnalytics**

**Description**

This method is used to get post from the current chart with drawings. Which will contain a chart image(with displayed drawings) and a message with instrument and timeframe. This method also can throw “TradersYardException“ exceptions when chart doesn't have a drawing.

**Usage**

```csharp
Chart.GetChartPostWithAnalytics();
```

**Parameter**

none

**Return Value**\
SocialNetworkPost - post from the current chart which will contain chart image with drawings and message with instrument and timeframe.

**Example**

```csharp
protected override void OnCalculate()
{
  var post = Chart?.GetChartPostWithAnalytics();
}
```

&#x20;

### **GetChartPostWithOrdersSetup**

**Description**

This method is used to get post from the current chart with orders. Which will contain a chart image(include orders) and message with instrument and timeframe. This method also can throw “KeyNotFoundException“ exceptions when the chart doesn't have an open order.

**Usage**

```csharp
Chart.GetChartPostWithOrdersSetup();
```

**Parameter**

none

**Return Value**\
SocialNetworkPost - post from the current chart which will contain chart image with orders and message with instrument and timeframe.

**Example**

```csharp
protected override void OnCalculate()
{
  var post = Chart?.GetChartPostWithOrdersSetup();
}
```

&#x20;

### **GetChartPostWithAtPlusPlusSetupTool**

**Description**

This method is used to get post from the current chart with drawings. Which will contain a chart image(with displayed orders), a message with instrument and timeframe, and AT Analysis as attached file. This method also can throw “KeyNotFoundException“ exceptions when the chart doesn't have an open order or “TradingAtPlusPlusSetupSharedContent“ when ATpp not running currently.

**Usage**

```csharp
Chart.GetChartPostWithAtPlusPlusSetupTool();
```

**Parameter**

none

**Return Value**\
SocialNetworkPost - post from the current chart which will contain chart image with orders and message with instrument and timeframe.

**Example**

```csharp
protected override void OnCalculate()
{
  var post = Chart?.GetChartPostWithAtPlusPlusSetupTool();
}
```

&#x20;

### **SharePostToTY(SocialNetworkPost post, ISocialChannel source)**

**Description**

This method uses for sharing posts to TradersYard. For this method, there is a restriction that it can be performed no more than once every 0.5s. Otherwise, the OverflowException will be throw.

**Usage**

```csharp
SharePostToTY(post, source);
```

**Parameter**

post - a post to be published in TradersYard. One of the fields ImageFunc, Message, Document mast is set it is also possible to set all fields.

source - a group where post will be created. Can be empty if the field Channels of the post are set.

**Return Value**\
none

**Example**

```csharp
private bool _messageNotSend = true;
private ISocialChannel chanelToShare;

protected override void OnInit()
{
  GetShearingSourceForTY(GetChenalDes);
}

protected override void OnCalculate()
{
  if (_messageNotSend && chanelToShare != null)
  {
    var post = Chart.GetChartPostWithAnalytics();
    SharePostToTY(post, chanelToShare);
    _messageNotSend = false;
  }
}

private void GetChenalDes(IEnumerable<ISocialChannel> channels, Exception exception)
{
  if (exception == null)
  {
    foreach (var channel in channels)
      if (channel.DisplayName.Equals("My Account"))
        chanelToShare = channel;
  }
  else
  {
    Log(string.Format("You cant get TY channels list because: {0}", exception.Message), InfoLogLevel.Alert);
  }
}
```


---

# 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://script.agenatrader.com/tradersyard-social-trading.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.
