TradersYard / Social Trading
Possibilities to interact with TradersYard via TradersYard X Script
​
Data types
ISocialChannel
Description
is used to store information about TraderYard channels.
Fields
DisplayName - TraderYard displayed group name.
Channel - unique identifier
SocialNetworkPost
Description
is used to store posts that can be shared at TraderYard.
Fields
Message - a text which will be displayed at TY post.
ImageFunc - function for generate post image
Channels - list of ISocialChannel where posts will be shared
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
1
GetSharingSourceForTY(Action<IEnumerable<ISocialChannel>, Exception> callback);
Copied!
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
1
protected override void OnInit()
2
{
3
GetSharingSourceForTY(GetChenalDes);
4
}
5
​
6
private void GetChenalDes(IEnumerable<ISocialChannel> channels, Exception exception)
7
{
8
if (exception == null)
9
{
10
foreach (var channel in channels)
11
if (channel.DisplayName.Equals("My Account"))
12
Log(string.Format("You can share post to {0}", channel.DisplayName),InfoLogLevel.Info);
13
}
14
else
15
{
16
Log(string.Format("You cant get TY channels list because: {0}", exception.Message), InfoLogLevel.Alert);
17
}
18
}
Copied!
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
1
Chart.GetPost();
Copied!
Parameter
none
Return Value SocialNetworkPost - post from the current chart which will contain chart image and message with instrument and timeframe.
Example
1
protected override void OnCalculate()
2
{
3
var post = Chart?.GetPost();
4
}
Copied!
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
1
Chart.GetChartPostWithAnalytics();
Copied!
Parameter
none
Return Value SocialNetworkPost - post from the current chart which will contain chart image with drawings and message with instrument and timeframe.
Example
1
protected override void OnCalculate()
2
{
3
var post = Chart?.GetChartPostWithAnalytics();
4
}
Copied!
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
1
Chart.GetChartPostWithOrdersSetup();
Copied!
Parameter
none
Return Value SocialNetworkPost - post from the current chart which will contain chart image with orders and message with instrument and timeframe.
Example
1
protected override void OnCalculate()
2
{
3
var post = Chart?.GetChartPostWithOrdersSetup();
4
}
Copied!
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
1
Chart.GetChartPostWithAtPlusPlusSetupTool();
Copied!
Parameter
none
Return Value SocialNetworkPost - post from the current chart which will contain chart image with orders and message with instrument and timeframe.
Example
1
protected override void OnCalculate()
2
{
3
var post = Chart?.GetChartPostWithAtPlusPlusSetupTool();
4
}
Copied!
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
1
SharePostToTY(post, source);
Copied!
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
1
private bool _messageNotSend = true;
2
private ISocialChannel chanelToShare;
3
​
4
protected override void OnInit()
5
{
6
GetShearingSourceForTY(GetChenalDes);
7
}
8
​
9
protected override void OnCalculate()
10
{
11
if (_messageNotSend && chanelToShare != null)
12
{
13
var post = Chart.GetChartPostWithAnalytics();
14
SharePostToTY(post, chanelToShare);
15
_messageNotSend = false;
16
}
17
}
18
​
19
private void GetChenalDes(IEnumerable<ISocialChannel> channels, Exception exception)
20
{
21
if (exception == null)
22
{
23
foreach (var channel in channels)
24
if (channel.DisplayName.Equals("My Account"))
25
chanelToShare = channel;
26
}
27
else
28
{
29
Log(string.Format("You cant get TY channels list because: {0}", exception.Message), InfoLogLevel.Alert);
30
}
31
}
Copied!
Data types
ISocialChannel
Description
is used to store information about TraderYard channels.
Fields
DisplayName - TraderYard displayed group name.
Channel - unique identifier
SocialNetworkPost
Description
is used to store posts that can be shared at TraderYard.
Fields
Message - a text which will be displayed at TY post.
ImageFunc - function for generate post image
Channels - list of ISocialChannel where posts will be shared
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
1
GetSharingSourceForTY(Action<IEnumerable<ISocialChannel>, Exception> callback);
Copied!
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
1
protected override void OnInit()
2
{
3
GetSharingSourceForTY(GetChenalDes);
4
}
5
​
6
private void GetChenalDes(IEnumerable<ISocialChannel> channels, Exception exception)
7
{
8
if (exception == null)
9
{
10
foreach (var channel in channels)
11
if (channel.DisplayName.Equals("My Account"))
12
Log(string.Format("You can share post to {0}", channel.DisplayName),InfoLogLevel.Info);
13
}
14
else
15
{
16
Log(string.Format("You cant get TY channels list because: {0}", exception.Message), InfoLogLevel.Alert);
17
}
18
}
Copied!
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
1
Chart.GetPost();
Copied!
Parameter
none
Return Value SocialNetworkPost - post from the current chart which will contain chart image and message with instrument and timeframe.
Example
1
protected override void OnCalculate()
2
{
3
var post = Chart?.GetPost();
4
}
Copied!
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
1
Chart.GetChartPostWithAnalytics();
Copied!
Parameter
none
Return Value SocialNetworkPost - post from the current chart which will contain chart image with drawings and message with instrument and timeframe.
Example
1
protected override void OnCalculate()
2
{
3
var post = Chart?.GetChartPostWithAnalytics();
4
}
Copied!
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
1
Chart.GetChartPostWithOrdersSetup();
Copied!
Parameter
none
Return Value SocialNetworkPost - post from the current chart which will contain chart image with orders and message with instrument and timeframe.
Example
1
protected override void OnCalculate()
2
{
3
var post = Chart?.GetChartPostWithOrdersSetup();
4
}
Copied!
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
1
Chart.GetChartPostWithAtPlusPlusSetupTool();
Copied!
Parameter
none
Return Value SocialNetworkPost - post from the current chart which will contain chart image with orders and message with instrument and timeframe.
Example
1
protected override void OnCalculate()
2
{
3
var post = Chart?.GetChartPostWithAtPlusPlusSetupTool();
4
}
Copied!
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
1
SharePostToTY(post, source);
Copied!
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
1
private bool _messageNotSend = true;
2
private ISocialChannel chanelToShare;
3
​
4
protected override void OnInit()
5
{
6
GetShearingSourceForTY(GetChenalDes);
7
}
8
​
9
protected override void OnCalculate()
10
{
11
if (_messageNotSend && chanelToShare != null)
12
{
13
var post = Chart.GetChartPostWithAnalytics();
14
SharePostToTY(post, chanelToShare);
15
_messageNotSend = false;
16
}
17
}
18
​
19
private void GetChenalDes(IEnumerable<ISocialChannel> channels, Exception exception)
20
{
21
if (exception == null)
22
{
23
foreach (var channel in channels)
24
if (channel.DisplayName.Equals("My Account"))
25
chanelToShare = channel;
26
}
27
else
28
{
29
Log(string.Format("You cant get TY channels list because: {0}", exception.Message), InfoLogLevel.Alert);
30
}
31
}
Copied!
Copy link