कस्टम बोलिंजर बैंड्स: MetaTrader 5 के लिए बेहतरीन संकेतक

Mike 2024.04.28 00:16 36 0 0
संलग्नक

आपके ट्रेडिंग अनुभव को और बेहतर बनाने के लिए मैंने यह कस्टम बोलिंजर बैंड्स संकेतक विकसित किया है। यह संकेतक आपको पारंपरिक मूविंग एवरेज तकनीक के अलावा कई अन्य विकल्प प्रदान करता है। इसमें आप एक्सपोनेंशियल, स्मूथेड और लीनियर वेटेड जैसे अतिरिक्त तरीकों का चयन कर सकते हैं।

इस संकेतक का उपयोग करने के लिए, आपको इसे अपने कंप्यूटर पर निम्नलिखित पथ में रखना होगा:

C:\Users\[आपका यूजरनेम]\AppData\Roaming\MetaQuotes\Terminal\Indicators\Examples

संकेतक की विशेषताएँ:

Custom Bollinger Bands


डिफ़ॉल्ट रूप से यह जीरो पर सेट है:

Default Setting


लाइनियर वेटेड का औसत लेने का उदाहरण:


Example 1  Example 2


कोड:

//+------------------------------------------------------------------+
//|                                              BBPersonalizada.mq5 |
//|                                                      Lucas Vidal |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright   "Lucas Vidal"
#property link        "https://www.mql5.com/en/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"
//--- input parameters
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;  // डेविएशन
//--- global variables
int           ExtBandsPeriod,ExtBandsShift;
double        ExtBandsDeviations;
int           ExtPlotBegin=0;
//--- indicator buffer
double        ExtMLBuffer[];
double        ExtTLBuffer[];
double        ExtBLBuffer[];
double        ExtStdDevBuffer[];
//+------------------------------------------------------------------+
//| संकेतक इनिशियलाइजेशन फंक्शन                         |
//+------------------------------------------------------------------+
void OnInit()
  {
//--- इनपुट मानों की जांच करें
   if(InpBandsPeriod<2)
     {
      ExtBandsPeriod=20;
      PrintFormat("इनपुट वेरिएबल InpBandsPeriod=%d के लिए गलत मान। संकेतक गणनाओं के लिए मान=%d का उपयोग करेगा।",InpBandsPeriod,ExtBandsPeriod);
     }
   else
      ExtBandsPeriod=InpBandsPeriod;
   if(InpBandsShift<0)
     {
      ExtBandsShift=0;
      PrintFormat("इनपुट वेरिएबल InpBandsShift=%d के लिए गलत मान। संकेतक गणनाओं के लिए मान=%d का उपयोग करेगा।",InpBandsShift,ExtBandsShift);
     }
   else
      ExtBandsShift=InpBandsShift;
   if(InpBandsDeviations==0.0)
     {
      ExtBandsDeviations=2.0;
      PrintFormat("इनपुट वेरिएबल InpBandsDeviations=%f के लिए गलत मान। संकेतक गणनाओं के लिए मान=%f का उपयोग करेगा।",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);
      //--- स्टैंडर्ड डेविएशन की गणना करें और लिखें
      ExtStdDevBuffer[i]=StdDev_Func(i,price,ExtMLBuffer,ExtBandsPeriod);
      //--- ऊपरी रेखा
      ExtTLBuffer[i]=ExtMLBuffer[i]+ExtBandsDeviations*ExtStdDevBuffer[i];
      //--- निचली रेखा
      ExtBLBuffer[i]=ExtMLBuffer[i]-ExtBandsDeviations*ExtStdDevBuffer[i];
     }
//--- OnCalculate पूरा। नए पूर्व-गणना लौटाएं।
   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);
  }
//+------------------------------------------------------------------+




सूची
टिप्पणी 0