トレーディングセッション

cBots (自動売買)

Summary

取引セッションのスケジュールを表します。

署名

1
public abstract interface TradingSession

Namespace

cAlgo.API.Internals

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
 using cAlgo.API;
 using cAlgo.API.Internals;
 using System;
 namespace cAlgo
 {
     // このサンプルインジケーターは、シンボルの取引セッションの使用方法を示します
     [Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
     public class TradingSessionSample : Indicator
     {
         private TextBlock _isOpenedTextBlock;
         private TextBlock _timeTillCloseTextBlock;
         private TextBlock _timeTillOpenTextBlock;
         private Symbol _symbol;
         [Parameter("Use Current Symbol", DefaultValue = true)]
         public bool UseCurrentSymbol { get; set; }
         [Parameter("Other Symbol Name", DefaultValue = "GBPUSD")]
         public string OtherSymbolName { get; set; }
         protected override void Initialize()
         {
             var grid = new Grid(6, 2)
             {
                 BackgroundColor = Color.Gold,
                 Opacity = 0.6,
                 HorizontalAlignment = HorizontalAlignment.Center,
                 VerticalAlignment = VerticalAlignment.Center,
             };
             var style = new Style();
             style.Set(ControlProperty.Padding, 1);
             style.Set(ControlProperty.Margin, 2);
             style.Set(ControlProperty.BackgroundColor, Color.Black);
             style.Set(ControlProperty.FontSize, 8);
             _symbol = UseCurrentSymbol ? Symbol : Symbols.GetSymbol(OtherSymbolName);
             grid.AddChild(new TextBlock { Text = "Symbol Info", Style = style, HorizontalAlignment = HorizontalAlignment.Center }, 0, 0, 1, 2);
             grid.AddChild(new TextBlock { Text = "Time Till Open", Style = style }, 1, 0);
             _timeTillOpenTextBlock = new TextBlock { Text = _symbol.MarketHours.TimeTillOpen().ToString(), Style = style };
             grid.AddChild(_timeTillOpenTextBlock, 1, 1);
             grid.AddChild(new TextBlock { Text = "Time Till Close", Style = style }, 2, 0);
             _timeTillCloseTextBlock = new TextBlock { Text = _symbol.MarketHours.TimeTillClose().ToString(), Style = style };
             grid.AddChild(_timeTillCloseTextBlock, 2, 1);
             grid.AddChild(new TextBlock { Text = "Is Opened", Style = style }, 3, 0);
             _isOpenedTextBlock = new TextBlock { Text = _symbol.MarketHours.IsOpened().ToString(), Style = style };
             grid.AddChild(_isOpenedTextBlock, 3, <span="m">1);
             grid.AddChild<span="p">(new TextBlock { Text = "Trading Sessions #", Style = style }, 4, 0);
             grid.AddChild<span="p">(new TextBlock { Text = _symbol.MarketHours.Sessions.Count.ToString(), Style = style }, 4, 1<span="p">);
             grid.<span="n">AddChild<span="p">(new TextBlock { Text = "Trading Session Week Days", Style = style }, 5<span="p">, 0);
             var weekDays = string.Empty;
             for (var iSession = 0<span="p">; iSession < _symbol.MarketHours.Sessions<span="p">.Count; iSession++<span="p">)
             {
                 var currentSessionWeekDays = string.Format("{0}({1})-{2}({3})", _symbol.MarketHours.Sessions<span="p">[iSession].StartDay<span="p">, _symbol.MarketHours.Sessions<span="p">[iSession].StartTime, _symbol<span="p">.MarketHours.Sessions<span="p">[iSession<span="p">].EndDay<span="p">, _symbol<span="p">.MarketHours<span="p">.Sessions<span="p">[iSession<span="p">].EndTime<span="p">);
                 weekDays = iSession == 0 ? currentSessionWeekDays <span="p">: string.Format("{0}, {1}", weekDays<span="p">, currentSessionWeekDays<span="p">);
             <span="p">}
             grid<span="p">.AddChild<span="p">(new TextBlock <span="p">{ Text = weekDays, Style = style }, 5<span="p">, 1);
             Chart.AddControl<span="p">(grid<span="p">);
             Timer<span="p">.Start<span="p">(TimeSpan.FromSeconds<span="p">(1<span="p">));
         }
         protected override void OnTimer<span="p">()
         {
             _timeTillOpenTextBlock.Text = _symbol.MarketHours<span="p">.TimeTillOpen<span="p">().ToString();
             _timeTillCloseTextBlock<span="p">.Text = _symbol<span="p">.MarketHours<span="p">.TimeTillClose<span="p">().ToString<span="p">();
             _isOpenedTextBlock<span="p">.Text = _symbol<span="p">.MarketHours<span="p">.IsOpened<span="p">().ToString<span="p">();
         <span="p">}
         public override void Calculate<span="p">(int index<span="p">)
         {
         <span="p">}
     }
 <span="p">}

プロパティ

開始日

概要

取引セッションが開始される曜日

署名

1
public abstract DayOfWeek StartDay {get;}

返り値

DayOfWeek

終了日

概要

取引セッションが終了する曜日

署名

1
public abstract DayOfWeek EndDay {get<span="p">;}

返り値

DayOfWeek

開始時間

概要

取引セッションが開始される時間

署名

1
public abstract TimeSpan StartTime {get<span="p">;}

返り値

TimeSpan

終了時間

概要

取引セッションが終了する時間

署名

1
public abstract TimeSpan EndTime {get<span="p">;}

返り値

TimeSpan

関連するチュートリアル

  • 取引セッション
  • 取引セッション
目次

このページについて