HeikenHistogram.mq4
//+------------------------------------------------------------------+//| HeikenHistogram.mq4 |//| Copyright 2019, MetaQuotes Software Corp. |//| https://www.mql5.com |//+------------------------------------------------------------------+#property copyright "Copyright 2019, MetaQuotes Software Corp."#property link "https://www.mql5.com"#property version "1.00"#property strict#property indicator_separate_window#property indicator_color1 Magenta#property indicator_color2 SpringGreen#property indicator_width1 4#property indicator_width2 4#property indicator_minimum 0#property indicator_maximum 1double BufUp[];double BufDown[];//+------------------------------------------------------------------+//| Custom indicator initialization function |//+------------------------------------------------------------------+int OnInit() {//--- indicator buffers mapping SetIndexBuffer(0,BufUp,INDICATOR_DATA); SetIndexBuffer(1,BufDown,INDICATOR_DATA); SetIndexStyle(0,DRAW_HISTOGRAM); SetIndexStyle(1,DRAW_HISTOGRAM); ArraySetAsSeries(BufUp, true); ArraySetAsSeries(BufDown, true);//--- return(INIT_SUCCEEDED); }//+------------------------------------------------------------------+//| Custom indicator iteration function |//+------------------------------------------------------------------+int OnCalculate(const int rates_total, const int prev_calculated, const datetime &time[], const double &open[], const double &high[], const double &low[], const double &close[], const long &tick_volume[], const long &volume[], const int &spread[]) {//--- return value of prev_calculated for next call ArraySetAsSeries(Close, true); int limit = rates_total-prev_calculated; if(limit==0) limit=1; for(int i=limit-1; i>=0; i--) { double valOpen = iCustom(NULL, 0, "Heiken Ashi", 0, i); double valClose = iCustom(NULL, 0, "Heiken Ashi", 1, i); BufUp[i]=0; BufDown[i]=0; if(valClose>valOpen) BufUp[i]=1; else if(valClose<valOpen) BufDown[i]=1; } return(rates_total); }//+------------------------------------------------------------------+//@version=4study(title="BB7", overlay=true)length1 = input(21, title="length1")length23 = input(25, title="length2, 3")price = input(close, title="applied price")mid1 = sma(price, length1)mid23 = sma(price, length23)dev1 = stdev(price, length1)dev23 = stdev(price, length23)plot(mid23+dev23*3)plot(mid23+dev23*2)plot(mid1+dev1)plot(mid1)plot(mid23, linewidth=3)plot(mid1-dev1)plot(mid23-dev23*2)plot(mid23-dev23*3)