Bollinger Band Squeeze/ Keltner Highlighter and Exploration

 

Hello


I'm looking formula similar to this for amibroker. Does anybody maybe have similar ? It can be a little different of course...i will be try to reprogramming.

http://www.wisestocktrader.com/indicators/2464-bollinger-band-squeeze-highlighter-and-exploration


Thx for help


lukibest

 
anybody ??
 
Hi



i reprogramming this function like that: Yellow field in one mql and in second mql file i have devation which i found here. I would like to connect those two file in one but i suppose problem is with scale. i can't display devation. It is possible to paint yellow field and devation in one chart with own scale?

Yellow field file:

int Length = 6;
double Price;
 
// Keltner 
int kLength = 6;
double kN = 1.9;
double kATR;
double kUpper ;
double kLower ;
double  bbN;
// Bollinger
double bbLength;
//bbN = 1.4;
double bbStDevValues;
double bbUpper;
double bbLower;
double IsBBSqueeze[];
double bbup[];


//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
//----


   IndicatorBuffers(2);
 //SetIndexDrawBegin(0,Length);
//---- indicators
   SetIndexStyle(0,DRAW_HISTOGRAM);
   SetIndexBuffer(0,IsBBSqueeze);
   
   SetIndexStyle(1,DRAW_LINE);
   SetIndexBuffer(1,bbup);
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   double std;
   int    counted_bars=IndicatorCounted();
   int limit=Bars-counted_bars;
   
 for(int i=0; i<limit; i++)
 {
 Price= iMA(NULL,0,Length,0,MODE_EMA,PRICE_CLOSE,i);
 
//Price = EMA(Close, Length);
 
// Keltner 
kLength = Length;

kATR=iATR(NULL,0,kLength,i);
//kATR = ATR(kLength);
kUpper = Price + kN * kATR;
kLower = Price - kN * kATR;
 bbN= 1.8;//Param("bbN", 1.40,1,2.80,0.01);
// Bollinger
bbLength = Length;
//bbN = 1.4;
bbStDevValues= iStdDev(NULL,0,bbLength,0,0,PRICE_CLOSE,i);

std=bbN*iStdDev(NULL,0,bbLength,0,0,0,i);
//bbStDevValues =  StDev(Close, bbLength);
bbUpper = Price + bbN * bbStDevValues;
bbLower = Price - bbN * bbStDevValues;

IsBBSqueeze[i] = bbUpper <= kUpper && bbLower >= kLower;

bbup[i]=0; //Price + bbN  +std;   
   
  }
   
   
//----
   
//----
   return(0);
  }
devation file:

//+------------------------------------------------------------------+
//|                                                    BBflat_sw.mq4 |
//|                                                          by Raff |
//+------------------------------------------------------------------+
#property indicator_separate_window
#property indicator_buffers 4
#property indicator_color1 Aqua
#property indicator_color2 Red
#property indicator_color3 Red
#property indicator_color4 Yellow
#property indicator_levelcolor  SlateGray
#property indicator_level1 0.0004
#property indicator_level2 -0.0004
//----
extern int period=9;
extern int shift=0;
extern int method=0;
extern int price=0;
extern double deviation=1.5;
//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
double ExtMapBuffer3[];
double ExtMapBuffer4[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0,ExtMapBuffer1);
   SetIndexStyle(1,DRAW_LINE);
   SetIndexBuffer(1,ExtMapBuffer2);
   SetIndexStyle(2,DRAW_LINE);
   SetIndexBuffer(2,ExtMapBuffer3);
   SetIndexStyle(3,DRAW_LINE);
   SetIndexBuffer(3,ExtMapBuffer4);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int limit, counted_bars=IndicatorCounted();
   double ima, std;
   if(counted_bars<0) return(-1);
   if(counted_bars>0) counted_bars--;
   limit=Bars-counted_bars;
   for(int i=0; i<limit; i++)
     {
      ima=iMA(NULL,0,period,shift,method,price,i);
      std=deviation*iStdDev(NULL,0,period,shift,method,price,i);
      ExtMapBuffer1[i]=0;//iStdDev(NULL,0,period,shift,method,price,i);;
      ExtMapBuffer2[i]=std;
      ExtMapBuffer3[i]=-std;
      //ExtMapBuffer4[i]=Close[i]-ima;
     }
//----
   return(0);
  }
//+------------------------------------------------------------------+

Reason: