無料でロボットをダウンロードする方法を見る
Twitter上で私たちを見つけてください。
私たちのファンページに参加してください
興味深いスクリプト?
それではリンクにそれを投稿してください。-
他の人にそれを評価してもらいます
記事を気に入りましたか?MetaTrader 5ターミナルの中でそれを試してみてください。
ビュー:
111
評価:
(6)
パブリッシュ済み:
MQL5フリーランス このコードに基づいたロボットまたはインジケーターが必要なら、フリーランスでご注文ください フリーランスに移動

このインディケータは、MetaTrader 5のボリンジャーバンド・インディケータに含まれる標準的な移動平均法に代わるものです。私のインジケータでは、Exponential、Smoothed、LinearWeightedを含む追加メソッドから選択するオプションがあります。

このインジケータを利用するには、(Windowsの場合)以下のようなディレクトリにインジケータを配置する必要があります:

このインジケータを使用するには、(Windowsの場合)以下のようなディレク トリに配置する必要があります。

機能を追加した:

ひとつ


デフォルトでゼロに設定される:

に


LinearWeightedの平均を選ぶ実行例:


木 し


CODE:

//+------------------------------------------------------------------+
//|BBPersonalizada.mq5
//|ルーカス・ビダル
//|https://www.mql5.com
//+------------------------------------------------------------------+
#property copyright   "Lucas Vidal"
#property link        "https://www.mql5.com/ja/users/lucasmoura00"
#property description "Bollinger Bands Personalizada"
#include <MovingAverages.mqh>
//---
#property indicator_chart_window
#property indicator_buffers 4
#property indicator_plots   3
#property indicator_type1   DRAW_LINE
#property indicator_color1  LightSeaGreen
#property indicator_type2   DRAW_LINE
#property indicator_color2  LightSeaGreen
#property indicator_type3   DRAW_LINE
#property indicator_color3  LightSeaGreen
#property indicator_label1  "Bands middle"
#property indicator_label2  "Bands upper"
#property indicator_label3  "Bands lower"
//--- 入力パラメータ
enum MovingAverageMethod {
    Simple,    // 0
    Exponential,  // 1
    Smoothed,     // 2
    LinearWeighted  // 3
};
input MovingAverageMethod InpMaMethod = Simple; // メディア・メソッド
input int     InpBandsPeriod=20;       // 期間
input int     InpBandsShift=0;         // シフト
input double  InpBandsDeviations=2.0;  // 偏差値
//--- グローバル変数
int           ExtBandsPeriod,ExtBandsShift;
double        ExtBandsDeviations;
int           ExtPlotBegin=0;
//--- インジケータ・バッファ
double        ExtMLBuffer[];
double        ExtTLBuffer[];
double        ExtBLBuffer[];
double        ExtStdDevBuffer[];
//+------------------------------------------------------------------+
//| カスタムインジケータ初期化関数
//+------------------------------------------------------------------+
void OnInit()
  {
//--- 入力値のチェック
   if(InpBandsPeriod<2)
     {
      ExtBandsPeriod=20;
      PrintFormat("Incorrect value for input variable InpBandsPeriod=%d. Indicator will use value=%d for calculations.",InpBandsPeriod,ExtBandsPeriod);
     }
   else
      ExtBandsPeriod=InpBandsPeriod;
   if(InpBandsShift<0)
     {
      ExtBandsShift=0;
      PrintFormat("Incorrect value for input variable InpBandsShift=%d. Indicator will use value=%d for calculations.",InpBandsShift,ExtBandsShift);
     }
   else
      ExtBandsShift=InpBandsShift;
   if(InpBandsDeviations==0.0)
     {
      ExtBandsDeviations=2.0;
      PrintFormat("Incorrect value for input variable InpBandsDeviations=%f. Indicator will use value=%f for calculations.",InpBandsDeviations,ExtBandsDeviations);
     }
   else
      ExtBandsDeviations=InpBandsDeviations;
//--- バッファの定義
   SetIndexBuffer(0,ExtMLBuffer);
   SetIndexBuffer(1,ExtTLBuffer);
   SetIndexBuffer(2,ExtBLBuffer);
   SetIndexBuffer(3,ExtStdDevBuffer,INDICATOR_CALCULATIONS);
//--- インデックス・ラベルを設定する
   PlotIndexSetString(0,PLOT_LABEL,"Bands("+string(ExtBandsPeriod)+") Middle");
   PlotIndexSetString(1,PLOT_LABEL,"Bands("+string(ExtBandsPeriod)+") Upper");
   PlotIndexSetString(2,PLOT_LABEL,"Bands("+string(ExtBandsPeriod)+") Lower");
//--- インジケーター名
   IndicatorSetString(INDICATOR_SHORTNAME,"Bollinger Bands");
//--- インデックスの描画開始
   ExtPlotBegin=ExtBandsPeriod-1;
   PlotIndexSetInteger(0,PLOT_DRAW_BEGIN,ExtBandsPeriod);
   PlotIndexSetInteger(1,PLOT_DRAW_BEGIN,ExtBandsPeriod);
   PlotIndexSetInteger(2,PLOT_DRAW_BEGIN,ExtBandsPeriod);
//--- インデックスのシフト設定
   PlotIndexSetInteger(0,PLOT_SHIFT,ExtBandsShift);
   PlotIndexSetInteger(1,PLOT_SHIFT,ExtBandsShift);
   PlotIndexSetInteger(2,PLOT_SHIFT,ExtBandsShift);
//--- 指示値の桁数
   IndicatorSetInteger(INDICATOR_DIGITS,_Digits+1);
  }
//+------------------------------------------------------------------+
//| 移動平均の計算|
//+------------------------------------------------------------------+
double CalculateMovingAverage(int position, int period, const double &price[]) {
    switch(InpMaMethod) {
        case Simple:
            return SimpleMA(position, period, price);
        case Exponential:
            // iMA 関数のパラメータを修正する。
            return iMA(NULL, 0, period, 0, MODE_EMA, PRICE_CLOSE);
        case Smoothed:
            // SMMAの機能を実装する。
            break;
        case LinearWeighted:
            return LinearWeightedMA(position, period, price);
    }
    return 0; // 不定法の場合のパッド返還
}

//+------------------------------------------------------------------+
//| ボリンジャーバンド|
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const int begin,
                const double &price[])
  {
   if(rates_total<ExtPlotBegin)
      return(0);
//--- インデックスは、以前のbeginを受け取ったときに、beginの設定を描画する。
   if(ExtPlotBegin!=ExtBandsPeriod+begin)
     {
      ExtPlotBegin=ExtBandsPeriod+begin;
      PlotIndexSetInteger(0,PLOT_DRAW_BEGIN,ExtPlotBegin);
      PlotIndexSetInteger(1,PLOT_DRAW_BEGIN,ExtPlotBegin);
      PlotIndexSetInteger(2,PLOT_DRAW_BEGIN,ExtPlotBegin);
     }
//--- 計算開始
   int pos;
   if(prev_calculated>1)
      pos=prev_calculated-1;
   else
      pos=0;
//--- メインサイクル
   for(int i=pos; i<rates_total && !IsStopped(); i++)
     {
      //--- 中央線
      ExtMLBuffer[i]=CalculateMovingAverage(i, ExtBandsPeriod, price);
      //--- StdDevを計算し、書き留める。
      ExtStdDevBuffer[i]=StdDev_Func(i,price,ExtMLBuffer,ExtBandsPeriod);
      //--- 上の行
      ExtTLBuffer[i]=ExtMLBuffer[i]+ExtBandsDeviations*ExtStdDevBuffer[i];
      //--- 下の行
      ExtBLBuffer[i]=ExtMLBuffer[i]-ExtBandsDeviations*ExtStdDevBuffer[i];
     }
//--- OnCalculate完了。新しいprev_calculatedを返す。
   return(rates_total);
  }
//+------------------------------------------------------------------+
//| 標準偏差の計算|
//+------------------------------------------------------------------+
double StdDev_Func(const int position,const double &price[],const double &ma_price[],const int period)
  {
   double std_dev=0.0;
//--- 標準偏差の計算
   if(position>=period)
     {
      for(int i=0; i<period; i++)
         std_dev+=MathPow(price[position-i]-ma_price[position],2.0);
      std_dev=MathSqrt(std_dev/period);
     }
//--- 計算値を返す
   return(std_dev);
  }
//+------------------------------------------------------------------+




MetaQuotes Ltdによって英語から翻訳されました。
元のコード: https://www.mql5.com/en/code/49464

Geometric Moving Average Geometric Moving Average

幾何学的移動平均のMQL5バージョン。

Get Nth Active Trade from the end in MT5 Get Nth Active Trade from the end in MT5

このEAはすべてのオープントレードをスキャンし、最後からn番目のトレードを表示します。

OHLC Candles with Ask and Bid OHLC Candles with Ask and Bid

アスク価格とビッド価格をローソク足の高値と安値で結んだローソク足チャート。

シンプル・スリー・インサイド・パターン_EA シンプル・スリー・インサイド・パターン_EA

シンプルなExpert Advisorで、価格が "Three From Within "パターンを形成したときに取引を行います。