私たちのファンページに参加してください
- ビュー:
- 932
- 評価:
- パブリッシュ済み:
- 2017.02.06 09:41
- アップデート済み:
- 2023.03.30 13:44
-
このコードに基づいたロボットまたはインジケーターが必要なら、フリーランスでご注文ください フリーランスに移動
アラート、メール、モバイルデバイスへのプッシュ通知送信機能を備えたColorX2MA指標:
アラート、電子メールメッセージ、およびプッシュ通知を実装するために、指標コードは以下のように変更されました。
- 新しい入力パラメータの導入
//---- アラートのための入力変数 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, // 1つ前のティックでのバー数 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(ColorArray[index1]!=ColorIndex && 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+=Spread[index]; string sAsk=DoubleToString(Ask,_Digits); string sBid=DoubleToString(Bid,_Digits); string sPeriod=GetStringTimeframe(ChartPeriod()); 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); } //--- } //+------------------------------------------------------------------+ //| 売りシグナル関数 | //+------------------------------------------------------------------+ void SellSignal(string SignalSirname, // 電子メールとプッシュメッセージでの指標名のテキスト double &ColorArray[], // 色インデックスバッファ int ColorIndex, // シグナル生成のための色インデックスバッファでの色インデックス const int Rates_total, // 現在のバー数 const int Prev_calculated, // 1つ前のティックでのバー数 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(ColorArray[index1]!=ColorIndex && 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+=Spread[index]; string sAsk=DoubleToString(Ask,_Digits); string sBid=DoubleToString(Bid,_Digits); string sPeriod=GetStringTimeframe(ChartPeriod()); 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); } //--- } //+------------------------------------------------------------------+ //| 時間軸を文字列として取得 | //+------------------------------------------------------------------+ string GetStringTimeframe(ENUM_TIMEFRAMES timeframe) { //---- return(StringSubstr(EnumToString(timeframe),7,-1)); //---- }
- OnCalculate() ブロックで指標計算サイクルが終了した後のBuySignal() とSellSignal() 関数への2回の呼び出しの追加
//--- BuySignal("X2MA_Alert",ColorX2MA,1,rates_total,prev_calculated,close,spread); SellSignal("X2MA_Alert",ColorX2MA,2,rates_total,prev_calculated,close,spread); //---
ここで、ColorX2MAは、線の色をインデックスの形で保存するための色インデックスバッファの名前です。
BuySignal() およびSellSignal()関数は指標コードのOnCalculate() ブロックで1回のみ呼び出されることが前提です。
この指標は SmoothAlgorithms.mqhライブラリクラスを使用します(<terminal_data_folder>\MQL5\Include にコピーします)。このクラスの使用法の詳細については 「Averaging Price Series for Intermediate Calculations Without Using Additional Buffers(追加のバッファを使用しない中間計算のための価格のシリーズの平均化)」稿に記載があります。
図1 チャートでのColorX2MA_Alert指標
図2 ColorX2MA_Alert指標のアラート生成
MetaQuotes Ltdによってロシア語から翻訳されました。
元のコード: https://www.mql5.com/ru/code/16477

異なる周期を持つ2つのRSIオシレータの差に基づくトレンドアナライザです。

アラート、メール、モバイルデバイスへのプッシュ通知送信機能を備えたBykovTrendセマフォ⁻指標です。

ColorXvaMA_Digit_StDev指標のシグナルに基づいた取引システムです。

異なる周期を持つ2つのMFIオシレータの差に基づくトレンドアナライザです。