होम तकनीकी संकेतक पोस्ट

BalanceOfPower_Histogram_Alert: MetaTrader 5 के लिए एक उपयोगी संकेतक

संलग्नक
16403.zip (22.71 KB, डाउनलोड 0 बार)

लेखक: RoboFx

Balance of Power (BOP) संकेतक एक रंगीन हिस्टोग्राम के रूप में कार्य करता है, जो वर्तमान प्रवृत्ति की ताकत और दिशा को दर्शाता है। इसमें अलर्ट्स, ई-मेल भेजने और मोबाइल डिवाइस पर पुश-नोटिफिकेशंस भेजने की सुविधा होती है। यह हिस्टोग्राम ओवरबॉट और ओवरसोल्ड स्तरों के लिए इनपुट पैरामीटर्स के अनुसार रंगित होता है और हिस्टोग्राम की गति की दिशा भी बताता है।

संकेतक कोड में अलर्ट्स, ई-मेल संदेश और पुश-नोटिफिकेशंस को लागू करने के लिए निम्नलिखित परिवर्तन किए गए हैं:

  1. नए इनपुट पैरामीटर्स पेश किए गए हैं:
    //---- अलर्ट्स के लिए इनपुट वेरिएबल्स 
    input uint NumberofBar=1;       //सिग्नल के लिए बार संख्या
    input bool SoundON=true;       //अलर्ट्स सक्षम करें
    input uint NumberofAlerts=2;       //अलर्ट्स की संख्या
    input bool EMailON=false;       //सिग्नल को ई-मेल भेजने के लिए सक्षम करें
    input bool PushON=false;       //मोबाइल डिवाइस पर सिग्नल भेजने के लिए सक्षम करें
    
  2. संकेतक कोड के अंत में तीन नए फ़ंक्शन जोड़े गए हैं: BuySignal(), SellSignal() और GetStringTimeframe()
    //+------------------------------------------------------------------+
    //| खरीद सिग्नल फ़ंक्शन                                  |
    //+------------------------------------------------------------------+
    void BuySignal(string SignalSirname,// ई-मेल और पुश संदेशों के लिए संकेतक नाम का टेक्स्ट
          double &ColorArray[],// रंग इंडेक्स बफर
          int ColorIndex,// सिग्नल उत्पन्न करने के लिए रंग इंडेक्स
          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(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, // पिछले टिक पर बार की संख्या
                    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));
    //----
      }
    
  3. OnCalculate() ब्लॉक में संकेतक की गणना चक्र के बाद BuySignal() और SellSignal() फ़ंक्शंस को कॉल किया गया है:
    //---     
       BuySignal("BalanceOfPower_Histogram_Alert",ColorIndBuffer,0,rates_total,prev_calculated,close,spread);
       SellSignal("BalanceOfPower_Histogram_Alert",ColorIndBuffer,7,rates_total,prev_calculated,close,spread);
    //---
    

जहां ColorIndBuffer वह नाम है जो मोमबत्ती के रंग को इंडेक्स के रूप में संग्रहीत करता है।

यह मान लिया गया है कि BuySignal() और SellSignal() फ़ंक्शंस को संकेतक कोड के OnCalculate() ब्लॉक में केवल एक बार कॉल किया जाएगा।

संकेतक SmoothAlgorithms.mqh लाइब्रेरी की कक्षाओं का उपयोग करता है (इसे <terminal_data_folder>\MQL5\Include में कॉपी करें)। कक्षाओं का उपयोग विस्तार से वर्णित किया गया है लेख में "अतिरिक्त बफर का उपयोग किए बिना मध्यवर्ती गणनाओं के लिए मूल्य श्रृंखलाओं का औसत".

यह संकेतक मूल रूप से MQL5 में लिखा गया था और पहली बार कोड बेस पर 07.02.2013 को प्रकाशित किया गया था।

चित्र1. BalanceOfPower_Histogram_Alert संकेतक चार्ट पर

चित्र1. BalanceOfPower_Histogram_Alert संकेतक चार्ट पर

चित्र.2 BalanceOfPower_Histogram_Alert संकेतक अलर्ट उत्पन्न कर रहा है।

चित्र.2 BalanceOfPower_Histogram_Alert संकेतक अलर्ट उत्पन्न कर रहा है।

संबंधित पोस्ट

टिप्पणी (0)