インディケータ: ATRStops_v1.1_Alert

 

ATRStops_v1.1_Alert:

NRTRとして実装されたトレンド指標で、アラート、電子メール、及びプッシュ通知を備えています。

図1  ATRStops_v1.1_Alert指標

作者: Nikolay Kositsin

 
ヘルプ、なぜかターミナルが上の赤い線を引かず、下の青い線しか引かない。
 
Альберт Туйкин:
ターミナルで、何らかの理由で上の赤い線が描画されず、下の青い線だけが描画されます。
インジケーターは正常に動作しています!
 
Nikolay Kositsin:
インジケーターは全く問題なく機能する!

ほとんどのチャートで完璧に機能する。しかし、2つのチャートでは赤線が引けない。
 
Альберт Туйкин:

ほとんどのチャートではうまくいく。しかし2つのチャートでは赤線が引けない :(
問題を抱えたとき、それを周囲にどう伝えるかは、その人次第だ。
 

スクリーンショットを追加しました。

例えば、RTS指数チャートではすべて機能していますが、RTS先物チャートでは青い線しかありません。

ファイル:
k3nkgna35.JPG  195 kb
 
Альберт Туйкин:

スクリーンショットを追加しました。

例えば、RTSインデックス・チャートではすべてが機能していますが、RTS先物チャートでは青い線しかありません。

このコードの作者がソースコードの中でグローバルボトムとシーリングのサイズを小さく設定しすぎたことは明らかです。近日中にコードを変更する予定です。
//+------------------------------------------------------------------+
//|ATRStops_v1.1_Alert.mq5
//|著作権 © 2006, Forex-TSD.com
//| IgorAD,igorad2003@yahoo.co.uk 記 
//|http://finance.groups.yahoo.com/group/TrendLaboratory| トレンドラボラトリー 
//+------------------------------------------------------------------+
//---- インジケータの著者名
#property copyright "Copyright © 2006, Forex-TSD.com "
//---- 著者のウェブサイトへのリンク
#property link      "http://www.forex-tsd.com/"
//---- インジケータのバージョン番号
#property version   "1.10"
//---- メイン・ウィンドウにインジケータを描画する。
#property indicator_chart_window
//---- 4つのバッファが、インジケータの計算と描画に使用される。
#property indicator_buffers 4
//---- 4つのグラフィックを使用
#property indicator_plots   4
//+----------------------------------------------+
//|| 強気インジケータの描画パラメータ
//+----------------------------------------------+
//---- インジケータ1を線で描く
#property  indicator_type1   DRAW_LINE
//---- 青色が指示線の色として使用される
#property  indicator_color1  clrBlue
//---- インジケーター・ライン1 - 実線
#property  indicator_style1  STYLE_SOLID
//---- インジケータ1の線の太さは2
#property  indicator_width1  2
//---- 表示インジケーター・ラインマーカー
#property  indicator_label1  "Upper ATRStops_v1.1"
//+----------------------------------------------+
//|| 弱気インジケータのレンダリングパラメータ
//+----------------------------------------------+
//---- インジケータ2を線で描く
#property  indicator_type2   DRAW_LINE
//---- 指示線の色としてインド赤を使用する。
#property  indicator_color2  clrIndianRed
//---- インジケーター・ライン2 - 実線
#property  indicator_style2  STYLE_SOLID
//---- インジケータ2の線の太さは2
#property  indicator_width2  2
//---- 表示インジケーター・ラインマーカー
#property  indicator_label2  "Lower ATRStops_v1.1"
//+----------------------------------------------+
//|| 強気インジケータの描画パラメータ
//+----------------------------------------------+
//---- インジケータ3をアイコンとして描画
#property  indicator_type3   DRAW_ARROW
//---- インジケーター・カラーとして青を使用
#property  indicator_color3  clrBlue
//---- インジケーター3の厚さは4
#property  indicator_width3  4
//---- 表示ラベル
#property  indicator_label3  "Buy ATRStops_v1.1"
//+----------------------------------------------+
//|| 弱気インジケータのレンダリングパラメータ
//+----------------------------------------------+
//---- インジケータ4をアイコンとして描画
#property  indicator_type4   DRAW_ARROW
//---- 指示色として赤が使用されている。
#property  indicator_color4  clrRed
//---- インジケーター4の厚さは4
#property  indicator_width4  4
//---- 表示ラベル
#property  indicator_label4  "Sell ATRStops_v1.1"
//+----------------------------------------------+
//|| インジケータ入力パラメータ
//+----------------------------------------------+
input uint   Length=10;           // 指標期間
input uint   ATRPeriod=5;         // ATR指標期間
input double Kv=2.5;              // ATRボラティリティ
input int    Shift=0;             // インジケーターを小節単位で水平方向に移動させる。
input uint NumberofBar=1;         // 信号用バー番号
input bool SoundON=true;          // 警告の解像度
input uint NumberofAlerts=2;      // アラートの数
input bool EMailON=false;         // シグナルの郵送を有効にする
input bool PushON=false;          // 携帯電話への信号送信を有効にする
//+----------------------------------------------+
//---- 動的配列の宣言。
//---- インジケータ・バッファとして使用される
double ExtMapBufferUp[];
double ExtMapBufferDown[];
double ExtMapBufferUp1[];
double ExtMapBufferDown1[];
//---- インジケータ・ハンドル用の整数変数の宣言
int ATR_Handle;
//---- 整数データ開始変数の宣言
int min_rates_total;
//+------------------------------------------------------------------+
//| カスタムインジケータ初期化関数
//+------------------------------------------------------------------+ 
int OnInit()
  {
//---- ATR インジケータのハンドルを取得する
   ATR_Handle=iATR(NULL,0,ATRPeriod);
   if(ATR_Handle==INVALID_HANDLE)
     {
      Print(「ATRインジケータハンドルの取得に失敗しました。);
      return(1);
     }

//---- データ開始変数の初期化
   min_rates_total=int(ATRPeriod+Length);

//---- 動的配列ExtMapBufferUp[]をインジケータ・バッファに変える
   SetIndexBuffer(0,ExtMapBufferUp,INDICATOR_DATA);
//---- インジケータ1をShiftで水平方向にシフトする。
   PlotIndexSetInteger(0,PLOT_SHIFT,Shift);
//---- インジケータの描画カウントダウンの開始を 1 ずらす。
   PlotIndexSetInteger(0,PLOT_DRAW_BEGIN,min_rates_total);
//---- タイムスリリーのように、バッファ内のアイテムにインデックスを付ける。 
   ArraySetAsSeries(ExtMapBufferUp,true);
//---- チャート上に表示されないインジケータの値を設定する。
   PlotIndexSetDouble(0,PLOT_EMPTY_VALUE,EMPTY_VALUE);

//---- 動的配列ExtMapBufferDown[]をインジケータバッファに変える
   SetIndexBuffer(1,ExtMapBufferDown,INDICATOR_DATA);
//---- インジケータ2をシフト・ポジションで水平方向に移動させる。
   PlotIndexSetInteger(1,PLOT_SHIFT,Shift);
//---- カウントダウン2の描画開始位置をずらす。
   PlotIndexSetInteger(1,PLOT_DRAW_BEGIN,min_rates_total);
//---- タイムスリリーのように、バッファ内のアイテムにインデックスを付ける。 
   ArraySetAsSeries(ExtMapBufferDown,true);
//---- チャート上に表示されないインジケータの値を設定する。
   PlotIndexSetDouble(1,PLOT_EMPTY_VALUE,EMPTY_VALUE);

//---- 動的配列ExtMapBufferUp1[]をインジケータバッファに変換する
   SetIndexBuffer(2,ExtMapBufferUp1,INDICATOR_DATA);
//---- インジケータ1をShiftで水平方向にシフトする。
   PlotIndexSetInteger(2,PLOT_SHIFT,Shift);
//---- インジケータの描画開始位置のシフト 3
   PlotIndexSetInteger(2,PLOT_DRAW_BEGIN,min_rates_total);
//---- タイムスリリーのように、バッファ内のアイテムにインデックスを付ける。 
   ArraySetAsSeries(ExtMapBufferUp1,true);
//---- チャート上に表示されないインジケータの値を設定する。
   PlotIndexSetDouble(2,PLOT_EMPTY_VALUE,EMPTY_VALUE);
//---- インジケーターの文字
   PlotIndexSetInteger(2,PLOT_ARROW,175);

//---- 動的配列ExtMapBufferDown1[]をインジケータバッファに変換する。
   SetIndexBuffer(3,ExtMapBufferDown1,INDICATOR_DATA);
//---- インジケータ2をシフト・ポジションで水平方向に移動させる。
   PlotIndexSetInteger(3,PLOT_SHIFT,Shift);
//---- インジケータ描画開始位置のシフト 4
   PlotIndexSetInteger(3,PLOT_DRAW_BEGIN,min_rates_total);
//---- タイムスリリーのように、バッファ内のアイテムにインデックスを付ける。 
   ArraySetAsSeries(ExtMapBufferDown1,true);
//---- チャート上に表示されないインジケータの値を設定する。
   PlotIndexSetDouble(3,PLOT_EMPTY_VALUE,EMPTY_VALUE);
//---- インジケーターの文字
   PlotIndexSetInteger(3,PLOT_ARROW,175);

//---- 短いインジケータ名の変数の初期化
   string shortname;
   StringConcatenate(shortname,"ATRStops_v1.1(",Length,", ",ATRPeriod,", ",DoubleToString(Kv,4),", ",Shift,")");
//--- 別のサブウィンドウとツールチップに表示する名前を作成する
   IndicatorSetString(INDICATOR_SHORTNAME,shortname);
//--- 指標値の表示精度の決定
   IndicatorSetInteger(INDICATOR_DIGITS,_Digits);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| カスタム・インジケータ反復関数
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,    // 現在のティックにおけるバーの履歴量
                const int prev_calculated,// 直前のティックにおける棒グラフの履歴量
                const datetime &time[],
                const double &open[],
                const double& high[],     // インジケータ計算のための最大価格の配列
                const double& low[],      // インジケータ計算のための価格の最小値の配列
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
  {
//---- 計算に必要な小節数をチェックする。
   if(BarsCalculated(ATR_Handle)<rates_total || rates_total<min_rates_total) return(0);

//---- ローカル変数の宣言 
   double ATR[];
   double smin0,smax0;
   int limit,to_copy,bar,trend0;
   static double smin1,smax1;
   static int trend1;

//---- 配列内の要素のインデックス付け(時系列と同様 
   ArraySetAsSeries(close,true);
   ArraySetAsSeries(high,true);
   ArraySetAsSeries(low,true);
   ArraySetAsSeries(ATR,true);

//---- バーの再計算サイクルの開始リミット番号を計算する。
   if(prev_calculated>rates_total || prev_calculated<=0) // インジケータの最初の計算開始をチェック
     {
      limit=rates_total-min_rates_total-1;               // すべてのバーの計算の開始番号
      trend1=0;
      smin1=-999999;
      smax1=+999999;
     }
   else
     {
      limit=rates_total-prev_calculated;                 // 新しいバーを計算するための開始番号
     }

   to_copy=int(limit+Length);
//---- 新たに現れたデータを配列にコピーする
   if(CopyBuffer(ATR_Handle,0,0,to_copy,ATR)<=0) return(0);

//---- メイン・インジケータの計算サイクル
   for(bar=limit; bar>=0; bar--)
     {      
      ExtMapBufferUp[bar]=EMPTY_VALUE;
      ExtMapBufferDown[bar]=EMPTY_VALUE;
      ExtMapBufferUp1[bar]=EMPTY_VALUE;
      ExtMapBufferDown1[bar]=EMPTY_VALUE;
      
      smin0=-999999;
      smax0=+999999;
      
      for(int iii=0; iii<int(Length); iii++)
        {
         int barx=bar+iii;
         smin0=MathMax(smin0,high[barx]-Kv*ATR[barx]);
         smax0=MathMin(smax0,low[barx]+Kv*ATR[barx]);
        }
        
      trend0=trend1;
      if(close[bar]>smax1) trend0=+1;
      if(close[bar]<smin1) trend0=-1;

      if(trend0>0)
        {
         if(smin0<smin1) smin0=smin1;
         ExtMapBufferUp[bar]=smin0;
        }
        
      if(trend0<0)
        {
         if(smax0>smax1) smax0=smax1;
         ExtMapBufferDown[bar]=smax0;
        }

      if(ExtMapBufferUp[bar+1]==EMPTY_VALUE && ExtMapBufferUp[bar]!=EMPTY_VALUE) ExtMapBufferUp1[bar]=ExtMapBufferUp[bar];
      if(ExtMapBufferDown[bar+1]==EMPTY_VALUE && ExtMapBufferDown[bar]!=EMPTY_VALUE) ExtMapBufferDown1[bar]=ExtMapBufferDown[bar];

      if(bar>0)
        {
         smin1=smin0;
         smax1=smax0;
         trend1=trend0;
        }
     }
//--- 
   BuySignal("ATRStops_v1.1_Alert",ExtMapBufferUp1,rates_total,prev_calculated,close,spread);
   SellSignal("ATRStops_v1.1_Alert",ExtMapBufferDown1,rates_total,prev_calculated,close,spread);
//--- 
   return(rates_total);
  }
//+------------------------------------------------------------------+
//| 買いシグナル機能|
//+------------------------------------------------------------------+
void BuySignal(string SignalSirname,      // メールとプッシュ・シグナル用のインジケータ名のテキスト
               double &BuyArrow[],        // 買いシグナルを含むインジケータ・バッファ
               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(BuyArrow);
   int index;
   if(SeriesTest) index=int(NumberofBar);
   else index=Rates_total-int(NumberofBar)-1;
   if(NormalizeDouble(BuyArrow[index],_Digits) && BuyArrow[index]!=EMPTY_VALUE) 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]*_Point;
      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 &SellArrow[],       // 買いシグナルを含むインジケータ・バッファ
                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(SellArrow);
   int index;
   if(SeriesTest) index=int(NumberofBar);
   else index=Rates_total-int(NumberofBar)-1;
   if(NormalizeDouble(SellArrow[index],_Digits) && SellArrow[index]!=EMPTY_VALUE) 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]*_Point;
      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));
//----
  }
//+------------------------------------------------------------------+
 
ありがとう!
 

こんにちは、

プロパティに英語を追加してもらえますか?

ありがとうございます。

 
gkb #: プロパティに英語を追加してもらえますか?

オリジナルの出版物は2017年にロシアのCodeBaseに 掲載されました。MetaQuotesは この出版物の翻訳を行ったものです。

ロシア語からの翻訳:MetaQuotes Ltd.
元のコード:https://www.mql5.
com/ru/code/17881

だから、原著者がそんなことをするとは思えない。Google翻訳を使って、自分でコードのコメントを英語に変えることはできるだろう。