거래 로봇을 무료로 다운로드 하는 법을 시청해보세요
당사를 Facebook에서 찾아주십시오!
당사 팬 페이지에 가입하십시오
스크립트가 흥미로우신가요?
그렇다면 링크 to it -
하셔서 다른 이들이 평가할 수 있도록 해보세요
스크립트가 마음에 드시나요? MetaTrader 5 터미널에서 시도해보십시오
조회수:
68
평가:
(6)
게시됨:
MQL5 프리랜스 이 코드를 기반으로 한 로봇이나 지표가 필요하신가요? 프리랜스로 주문하세요 프리랜스로 이동

저는 '단순' 방법만 제공하는 메타트레이더 5 볼린저 밴드 인디케이터의 표준 이동평균 방법에 대한 대안을 제공하기 위해 이 지표를 개발했습니다. 내 인디케이터를 사용하면 지수, 평활, 선형가중 등 추가 방법을 선택할 수 있습니다.

이 인디케이터를 사용하려면 다음 경로와 유사한 디렉터리(Windows의 경우)에 인디케이터를 배치해야 합니다:

C:\사용자\루카스\앱데이터\로밍\메타쿼트\터미널\지표\예제

기능이 추가되었습니다:

하나


기본적으로 0으로 설정되어 있습니다:

두


선형 가중 평균을 선택하는 실행 예시:


tree 네


CODE:

//+------------------------------------------------------------------+
//|BBPersonalizada.mq5 |
//|루카스 비달 |
//|https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright   "Lucas Vidal"
#property link        "https://www.mql5.com/ko/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);
//--- 인덱스는 이전 시작을 받았을 때 시작 설정을 그립니다.
   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];
     }
//--- 계산 완료. 새로운 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;
//--- 계산된 StdDev
   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 버전의 기하평균 이동 평균입니다.

X2MA_KLx3_Cloud X2MA_KLx3_Cloud

컬러 배경으로 렌더링된 켈트너의 채널.

피셔 트랜스폼_HTF_신호 피셔 트랜스폼_HTF_신호

피셔트랜스폼_HTF_Signal 인디케이터는 추세 방향을 색상 추세 표시와 함께 그래픽 개체로 표시하고 추세가 바뀌면 경고 또는 소리 신호를 보냅니다.

^X_비선형 회귀 ^X_비선형 회귀

가격 차트의 미래 값을 보간하는 비선형 회귀 채널입니다.