Attachments forums

List of attachments posted on this forum.


All files on forums: 161555

Re: Metatrader 5 Versions of indicators.

baraozemo, Wed Apr 26, 2017 5:21 am

Hi,
I need help with bb.

I want to detect the "bollingers bands" opening in the mt5, (see graphic)
the code samples that I have only get Touch or break in bb with the price, but it's not I need,
I need to get the "BB" opening like in this graphic.

Code: Select all

   int               m_BBHand;         
   double            m_BBup[];
   double            m_BBlow[];
   double            m_BBmidle[];    
   MqlRates          m_BBrate[];          // To be used to store the prices, volumes and spread of each bar   

int OnInit()
{
      m_BBHand=iBands(_Symbol,BB_TimeFrame,BB_Period,BB_Shift,BB_deviation,PRICE_CLOSE);
      ChartIndicatorAdd(0,(int)ChartGetInteger(1,CHART_WINDOWS_TOTAL),m_BBHand);

}

void OnTick()
{
         ArraySetAsSeries(m_BBrate,true);
        
         ZeroMemory(m_BBup);
         ZeroMemory(m_BBlow);
         ZeroMemory(m_BBmidle);         
         ArraySetAsSeries(m_BBup,true);
         ArraySetAsSeries(m_BBlow,true);
         ArraySetAsSeries(m_BBmidle,true);
         if(CopyRates(_Symbol,BB_TimeFrame,0,3,m_BBrate)<0)
           {
            return(false);
           }
         if(CopyBuffer(m_BBHand,0,1,3,m_BBmidle)<0 || 
            CopyBuffer(m_BBHand,1,1,3,m_BBup)<0 || 
            CopyBuffer(m_BBHand,2,1,3,m_BBlow)<0)
            {
            return(false);
            }           
         }       

      bool  buyreg,sellreg=false;

         //but  this code get candle crossing the bands (and it's not that I need)
         ///I need is only to get the "bands opening" (see the attached graphic) 
            buyreg=m_BBrate[1].close>m_BBlow[1] && m_BBrate[1].open<m_BBlow[1];// White (bull) candle crossed the Lower Band from below to above
           sellreg=m_BBrate[1].close<m_BBup[1]&& m_BBrate[1].open>m_BBup[1];// Black (bear) candle crossed the Upper Band from above to below
}
All files in topic