I通知

cBots (自動売買)

概要

すべての通知を表すインターフェースです。

シグネチャ

1
public abstract interface INotifications

 

名前空間

cAlgo.API.Internals

 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
 
 using cAlgo.API;
 namespace cAlgo
 {
     // このサンプルインジケータは、API通知を使用してサウンドを再生したり、メールを送信する方法を示します
     [Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
     public class NotificationsSample : Indicator
     {
         private int _lastNotifiedBarIndex;
         [Parameter("サウンドファイルのパス", DefaultValue = "C:\\Windows\\Media\\notify.wav")]
         public string SoundFilePath { get; set; }
         [Parameter("送信者のメールアドレス")]
         public string SenderEmail { get; set; }
         [Parameter("受信者のメールアドレス")]
         public string ReceiverEmail { get; set; }
         protected override void Initialize()
         {
         }
         public override void Calculate(int index)
         {
             if (!IsLastBar || _lastNotifiedBarIndex == index) return;
             _lastNotifiedBarIndex = index;
             if (Bars.Last(1).Close > Bars.Last(1).Open)
             {
                 Notify("上昇バーがクローズしました");
             }
             else if (Bars.Last(1).Close < Bars.Last(1).Open)
             {
                 Notify("下落バーがクローズしました");
             }
         }
         private void Notify(string message)
         {
             if (!string.IsNullOrWhiteSpace(SoundFilePath))
             {
                 Notifications.PlaySound(SoundFilePath);
             }
             if (!string.IsNullOrWhiteSpace(SenderEmail) && !string.IsNullOrWhiteSpace(ReceiverEmail))
             {
                 Notifications.SendEmail(SenderEmail, ReceiverEmail, "通知", message);
             }
         }
     }
 }

メソッド

PlaySound (2)

PlaySound (1 of 2)

概要

通知音を再生します。

備考

このメソッドはバックテストと最適化中には動作しません。インジケーターで使用する場合は、リアルタイム値のために IsRealTime/IsLastBar と組み合わせて使用してください。

シグネチャ

1
public abstract void PlaySound(string fileName)

 

パラメータ

名前説明
fileNamestringサウンドファイルのパス

戻り値

void

1
 Notifications.PlaySound(@"C:\SampleDestination\SampleSound.mp3");

PlaySound (2 of 2)

概要

指定された SoundType を再生します。

備考

このメソッドはバックテストと最適化中には動作しません。インジケーターで使用する場合は、リアルタイム値のために IsRealTime/IsLastBar と組み合わせて使用してください。

シグネチャ

1
public abstract void PlaySound(SoundType soundType)

 

パラメータ

名前説明
soundTypeSoundType再生される SoundType

戻り値

void

1
 Notifications.PlaySound(SoundType.PositiveNotification);

関連項目

  • cAlgo.API.SoundType

SendEmail

概要

通知メールを送信します。

備考

このメソッドはバックテストと最適化中には動作しません。メール通知を送信する前に、適切な設定が必要です。[設定] -> [メール設定] で設定を行ってください。

シグネチャ

1
public abstract void SendEmail(string from, string to, string subject, string <span="class="n">text)

 

パラメータ

名前説明
fromstring送信者のアドレス
tostring受信者のアドレス
subjectstringメールの件名
textstringメールの本文

戻り値

void

1
2
 Notifications.SendEmail("from@email.com", "to@email.com",
             "通知メールの件名", "メール本文");
目次

このページについて