//+------------------------------------------------------------------+ //| Heiken Ashi.mq4 | //| Copyright c 2004, MetaQuotes Software Corp. | //| http://www.metaquotes.net | //+------------------------------------------------------------------+ //| For Heiken Ashi we recommend next chart settings ( press F8 or | //| select on menu 'Charts'->'Properties...'): | //| - On 'Color' Tab select 'Black' for 'Line Graph' | //| - On 'Common' Tab disable 'Chart on Foreground' checkbox and | //| select 'Line Chart' radiobutton | //+------------------------------------------------------------------+ #property copyright "Copyright © 2004, MetaQuotes Software Corp." #property link "http://www.metaquotes.net" #property indicator_separate_window #property indicator_buffers 3 #property indicator_color1 Red #property indicator_color2 Lime #property indicator_color3 Yellow #property indicator_width1 2 #property indicator_width2 2 #property indicator_width3 2 #property indicator_minimum 0.0 #property indicator_maximum 50.5 //---- parameters extern int MaMetod =2; extern int MaPeriod=6; extern int MaMetod2 =3; extern int MaPeriod2=2; //---- buffers double haDOJI[]; double haDN[]; double haUP[]; //---- int ExtCountedBars=0; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //|------------------------------------------------------------------| int init() { //---- indicators SetIndexStyle(0,DRAW_ARROW); SetIndexBuffer(0, haDN); SetIndexArrow(0, 167); SetIndexStyle(1,DRAW_ARROW); SetIndexBuffer(1, haUP); SetIndexArrow(1, 167); SetIndexStyle(2,DRAW_ARROW); SetIndexBuffer(2, haDOJI); SetIndexArrow(2, 167); //---- indicator buffers mapping SetIndexBuffer(0,haDN); SetIndexBuffer(1,haUP); SetIndexBuffer(2,haDOJI); //---- initialization done return(0); } //+------------------------------------------------------------------+ //| Custom indicator deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- TODO: add your code here //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int start() { //double haOpen, haHigh, haLow, haClose; if(Bars<=10) return(0); ExtCountedBars=IndicatorCounted(); //---- check for possible errors if (ExtCountedBars<0) return(-1); //---- last counted bar will be recounted if (ExtCountedBars>0) ExtCountedBars--; int pos=Bars-ExtCountedBars-1; while(pos>=0) { double haOpen = iCustom(NULL,0,"HPT - Heiken Ashi Smoothed",MaMetod,MaPeriod,MaMetod2,MaPeriod2,2,pos) ; double haClose = iCustom(NULL,0,"HPT - Heiken Ashi Smoothed",MaMetod,MaPeriod,MaMetod2,MaPeriod2,3,pos) ; double haOpen1 = iCustom(NULL,0,"HPT - Heiken Ashi Smoothed",MaMetod,MaPeriod,MaMetod2,MaPeriod2,0,pos) ; double haClose1 = iCustom(NULL,0,"HPT - Heiken Ashi Smoothed",MaMetod,MaPeriod,MaMetod2,MaPeriod2,1,pos) ; haUP[pos]=EMPTY_VALUE; haDN[pos]=EMPTY_VALUE; haDOJI[pos]=EMPTY_VALUE; if (haOpen>haClose&&haOpen1>haClose1) { haDN[pos]=50; } else if (haOpen