私たちのファンページに参加してください
WeightOscillator_Alert - MetaTrader 5のためのインディケータ
- ビュー:
- 1056
- 評価:
- パブリッシュ済み:
- 2017.03.14 08:16
- アップデート済み:
- 2023.03.30 13:44
- このコードに基づいたロボットまたはインジケーターが必要なら、フリーランスでご注文ください フリーランスに移動
このWeightOscillatorトレンド指標は、アラート、電子メール、モバイルデバイスへのプッシュ通知送信機能を備えています。
アラート、電子メールメッセージ、およびプッシュ通知を実装するために、指標コードは以下のように変更されました。
- 指標シグナル生成オプションの列挙は、入力変数が宣言される前にグローバルスコープで宣言されます。//+----------------------------------------------------+
//| シグナル生成オプションの列挙 |
//+----------------------------------------------------+
enum ENUM_SIGNAL_MODE
{
MODE_SIGNAL, // ブレイクアウトシグナル
MODE_TREND // ブレイクアウトとトレンドシグナル
}; - 新しい入力パラメータの導入//---- アラートのための入力変数
input ENUM_SIGNAL_MODE SignMode=MODE_SIGNAL; // シグナル生成モード
input uint NumberofBar=1; // シグナル生成のためのバー番号
input bool SoundON=true; // アラートの有効化
input uint NumberofAlerts=2; // アラート数
input bool EMailON=false; // シグナルのメール送信の有効化
input bool PushON=false; // シグナルのモバイルデバイスへの送信の有効化 - 指標コードの最後でのBuySignal()、SellSignal()、GetStringTimeframe()の3つの新しい関数の追加//+------------------------------------------------------------------+
//| 買いシグナル関数 |
//+------------------------------------------------------------------+
void BuySignal(string SignalSirname,// 電子メールとプッシュメッセージでの指標名のテキスト
double &ColorArray[],// 色インデックスバッファ
int ColorIndex,// シグナル生成のための色インデックスバッファでの色インデックス
const int Rates_total, // 現在のバー数
const int Prev_calculated, // ひとつ前のティックでのバーの数
const double &Close[], // 終値
const int &Spread[]) // スプレッド
{
//---
static uint counter=0;
if(Rates_total!=Prev_calculated) counter=0;
bool BuySignal=false;
bool SeriesTest=ArrayGetAsSeries(ColorArray);
int index,index1;
if(SeriesTest)
{
index=int(NumberofBar);
index1=index+1;
}
else
{
index=Rates_total-int(NumberofBar)-1;
index1=index-1;
}
if(SignMode==MODE_SIGNAL)
{
if(ColorArray[index1]!=ColorIndex && ColorArray[index]==ColorIndex) BuySignal=true;
}
else
{
if(ColorArray[index]==ColorIndex) BuySignal=true;
}
if(BuySignal && counter<=NumberofAlerts)
{
counter++;
MqlDateTime tm;
TimeToStruct(TimeCurrent(),tm);
string text=TimeToString(TimeCurrent(),TIME_DATE)+" "+string(tm.hour)+":"+string(tm.min);
SeriesTest=ArrayGetAsSeries(Close);
if(SeriesTest) index=int(NumberofBar);
else index=Rates_total-int(NumberofBar)-1;
double Ask=Close[index];
double Bid=Close[index];
SeriesTest=ArrayGetAsSeries(Spread);
if(SeriesTest) index=int(NumberofBar);
else index=Rates_total-int(NumberofBar)-1;
Bid+=_Point*Spread[index];
string sAsk=DoubleToString(Ask,_Digits);
string sBid=DoubleToString(Bid,_Digits);
string sPeriod=GetStringTimeframe(ChartPeriod());
if(SignMode==MODE_SIGNAL || (SignMode==MODE_TREND && ColorArray[index1]!=ColorIndex))
{
if(SoundON) Alert("BUY signal \n Ask=",Ask,"\n Bid=",Bid,"\n currtime=",text,"\n Symbol=",Symbol()," Period=",sPeriod);
if(EMailON) SendMail(SignalSirname+": BUY signal alert","BUY signal at Ask="+sAsk+", Bid="+sBid+", Date="+text+" Symbol="+Symbol()+" Period="+sPeriod);
if(PushON) SendNotification(SignalSirname+": BUY signal at Ask="+sAsk+", Bid="+sBid+", Date="+text+" Symbol="+Symbol()+" Period="+sPeriod);
}
else
{
if(SoundON) Alert("Up Trend signal \n Ask=",Ask,"\n Bid=",Bid,"\n currtime=",text,"\n Symbol=",Symbol()," Period=",sPeriod);
if(EMailON) SendMail(SignalSirname+": Up Trend signal alert","BUY signal at Ask="+sAsk+", Bid="+sBid+", Date="+text+" Symbol="+Symbol()+" Period="+sPeriod);
if(PushON) SendNotification(SignalSirname+": Up Trend signal at Ask="+sAsk+", Bid="+sBid+", Date="+text+" Symbol="+Symbol()+" Period="+sPeriod);
}
}
//---
}
//+------------------------------------------------------------------+
//| 売りシグナル関数 |
//+------------------------------------------------------------------+
void SellSignal(string SignalSirname,// 電子メールとプッシュメッセージでの指標名のテキスト
double &ColorArray[], // 色インデックスバッファ
int ColorIndex, // シグナル生成のための色の色インデックスバッファでのインデックス
const int Rates_total, // 現在のバー数
const int Prev_calculated, // ひとつ前のティックでのバーの数
const double &Close[], // 終値
const int &Spread[]) // スプレッド
{
//---
static uint counter=0;
if(Rates_total!=Prev_calculated) counter=0;
bool SellSignal=false;
bool SeriesTest=ArrayGetAsSeries(ColorArray);
int index,index1;
if(SeriesTest)
{
index=int(NumberofBar);
index1=index+1;
}
else
{
index=Rates_total-int(NumberofBar)-1;
index1=index-1;
}
if(SignMode==MODE_SIGNAL)
{
if(ColorArray[index1]!=ColorIndex && ColorArray[index]==ColorIndex) SellSignal=true;
}
else
{
if(ColorArray[index]==ColorIndex) SellSignal=true;
}
if(SellSignal && counter<=NumberofAlerts)
{
counter++;
MqlDateTime tm;
TimeToStruct(TimeCurrent(),tm);
string text=TimeToString(TimeCurrent(),TIME_DATE)+" "+string(tm.hour)+":"+string(tm.min);
SeriesTest=ArrayGetAsSeries(Close);
if(SeriesTest) index=int(NumberofBar);
else index=Rates_total-int(NumberofBar)-1;
double Ask=Close[index];
double Bid=Close[index];
SeriesTest=ArrayGetAsSeries(Spread);
if(SeriesTest) index=int(NumberofBar);
else index=Rates_total-int(NumberofBar)-1;
Bid+=_Point*Spread[index];
string sAsk=DoubleToString(Ask,_Digits);
string sBid=DoubleToString(Bid,_Digits);
string sPeriod=GetStringTimeframe(ChartPeriod());
if(SignMode==MODE_SIGNAL || (SignMode==MODE_TREND && ColorArray[index1]!=ColorIndex))
{
if(SoundON) Alert("SELL signal \n Ask=",Ask,"\n Bid=",Bid,"\n currtime=",text,"\n Symbol=",Symbol()," Period=",sPeriod);
if(EMailON) SendMail(SignalSirname+": SELL signal alert","SELL signal at Ask="+sAsk+", Bid="+sBid+", Date="+text+" Symbol="+Symbol()+" Period="+sPeriod);
if(PushON) SendNotification(SignalSirname+": SELL signal at Ask="+sAsk+", Bid="+sBid+", Date="+text+" Symbol="+Symbol()+" Period="+sPeriod);
}
else
{
if(SoundON) Alert("Down trend signal \n Ask=",Ask,"\n Bid=",Bid,"\n currtime=",text,"\n Symbol=",Symbol()," Period=",sPeriod);
if(EMailON) SendMail(SignalSirname+": Down trend signal alert","SELL signal at Ask="+sAsk+", Bid="+sBid+", Date="+text+" Symbol="+Symbol()+" Period="+sPeriod);
if(PushON) SendNotification(SignalSirname+": Down trend signal at Ask="+sAsk+", Bid="+sBid+", Date="+text+" Symbol="+Symbol()+" Period="+sPeriod);
}
}
//---
}
//+------------------------------------------------------------------+
//| 時間軸を文字列として取得 |
//+------------------------------------------------------------------+
string GetStringTimeframe(ENUM_TIMEFRAMES timeframe)
{
//----
return(StringSubstr(EnumToString(timeframe),7,-1));
//----
} - OnCalculate() ブロックで指標計算サイクルが終了した後のBuySignal() とSellSignal() 関数への2回の呼び出しの追加 //---
BuySignal("WeightOscillator_Alert",ColorBuffer,0,rates_total,prev_calculated,close,spread);
SellSignal("WeightOscillator_Alert",ColorBuffer,4,rates_total,prev_calculated,close,spread);
//---
ここで、ColorBufferは、指標の色を保存するための色インデックスバッファの名前です。0と4の値は、このバッファ内の色の数であり、オシレータはそれぞれで買われ/過ぎ売られ過ぎ領域にあります。
BuySignal() およびSellSignal() 関数は指標コードのOnCalculate() ブロックで1回のみ呼び出されるものとします。
この指標はSmoothAlgorithms.mqhライブラリクラスを使用するので、このファイルを<端末データフォルダ>\MQL5\Include にコピーします。このクラスの使用法の詳細については 「Averaging Price Series for Intermediate Calculations Without Using Additional Buffers(追加のバッファを使用しない中間計算のための価格のシリーズの平均化)」稿に記載があります。
図1 チャートでのWeightOscillator_Alert指標
図2 WeightOscillator_Alert指標のブレイクアウトシグナルアラート生成
図3 WeightOscillator_Alert指標のトレンドシグナルアラート生成
MetaQuotes Ltdによってロシア語から翻訳されました。
元のコード: https://www.mql5.com/ru/code/17091
入力パラメータでの時間枠選択オプションを含むFractional_Bands指標です。
Chart on Chart(チャート上のチャート)Chart on Chart指標は、現在のチャート上に他の銘柄のチャートを表示します。
雲の形で描かれた2つのフラクタルKeltnerチャネルです。
eur usd m5このエキスパートアドバイザーは、iStochastic(ストキャスティクス)のシグナルに基づいてマーチンゲールモードで動作します。