//+------------------------------------------------------------------+ //| AO&MACD_MTF_NL.mq4 | //| -Multitimeframe Normalized / Line | //| Copyright © 2005, MetaQuotes Software Corp. | //| http://www.mql5.com/ru/code/7813 | //| Some features add by AST, 2014 | //+------------------------------------------------------------------+ #property copyright "Copyright © 2005, MetaQuotes Software Corp." #property link "http://www.metaquotes.net/" //---- indicator settings #property indicator_separate_window #property indicator_buffers 6 #property indicator_level1 0.0 #property indicator_levelwidth 0 #property indicator_levelstyle STYLE_DOT #property indicator_levelcolor DimGray #property indicator_color1 Black #property indicator_color2 Green //colors for AO #property indicator_color3 Red #property indicator_color4 Black #property indicator_color5 DodgerBlue //colors for MACD #property indicator_color6 DodgerBlue #property indicator_width1 0 #property indicator_width2 2 #property indicator_width3 2 #property indicator_width4 0 #property indicator_width5 2 #property indicator_width6 2 extern string _______Parameter1_______ = "_______Awesome Oscillator_______"; extern bool AO_show=true; // Show AO extern int AO_TF=0; // Timeframe extern int AO_fast=5; // Standart AO SMA fast Period=5 extern int AO_slow=34; // Standart AO SMA slow Period=34 extern bool AO_line=true; extern string _______Parameter2_______ = "_______MACD Oscillator__________"; extern bool MACD_show=true; // Show MACD extern int MACD_TF=0; // Timeframe extern int MACD_fast=21; // Standart MACD EMA fast Period=12 extern int MACD_slow=55; // Standart MACD EMA slow Period=26 extern bool MACD_line=true; //---- indicator buffers double ExtBuffer0[]; double ExtBuffer1[]; double ExtBuffer2[]; double ExtBuffer3[]; double ExtBuffer4[]; double ExtBuffer5[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { string AO_name, MACD_name, sp; IndicatorBuffers(6); IndicatorDigits(2); //---- drawing settings if (AO_line) { SetIndexStyle(0,DRAW_NONE); SetIndexStyle(1,DRAW_LINE); SetIndexStyle(2,DRAW_LINE); } else { SetIndexStyle(0,DRAW_NONE); SetIndexStyle(1,DRAW_HISTOGRAM); SetIndexStyle(2,DRAW_HISTOGRAM); } if (MACD_line) { SetIndexStyle(3,DRAW_NONE); SetIndexStyle(4,DRAW_LINE); SetIndexStyle(5,DRAW_LINE); } else { SetIndexStyle(3,DRAW_NONE); SetIndexStyle(4,DRAW_HISTOGRAM); SetIndexStyle(5,DRAW_HISTOGRAM); } SetIndexDrawBegin(0,AO_slow); SetIndexDrawBegin(1,AO_slow); SetIndexDrawBegin(2,AO_slow); SetIndexDrawBegin(3,MACD_slow); SetIndexDrawBegin(4,MACD_slow); SetIndexDrawBegin(5,MACD_slow); //---- 6 indicator buffers mapping SetIndexBuffer(0,ExtBuffer0); SetIndexBuffer(1,ExtBuffer1); SetIndexBuffer(2,ExtBuffer2); SetIndexBuffer(3,ExtBuffer3); SetIndexBuffer(4,ExtBuffer4); SetIndexBuffer(5,ExtBuffer5); //---- name for DataWindow and indicator subwindow label if (AO_show) { if (MACD_show) sp="+ "; else sp=""; AO_name=StringConcatenate("AO (",AO_fast,",",AO_slow,") TF_",StrPer(AO_TF)); }else AO_name=""; if (MACD_show) MACD_name=StringConcatenate("MACD (",MACD_fast,",",MACD_slow,") TF_",StrPer(MACD_TF)); else MACD_name=""; IndicatorShortName(AO_name+sp+MACD_name); SetIndexLabel(0,AO_name); SetIndexLabel(1,AO_name); SetIndexLabel(2,AO_name); SetIndexLabel(3,MACD_name); SetIndexLabel(4,MACD_name); SetIndexLabel(5,MACD_name); //---- initialization done return(0); } //+------------------------------------------------------------------+ //| Awesome Oscillator | //+------------------------------------------------------------------+ int start() { int limit; int counted_bars=IndicatorCounted(); double AO_prev,AO_current,MACD_prev,MACD_current; //---- last counted bar will be recounted if(counted_bars>0) counted_bars--; limit=Bars-counted_bars; if(counted_bars==0) limit-=1+1; //---- macd for(int i=0; i=0; i--) { if (AO_show) { AO_current=ExtBuffer0[i]; AO_prev=ExtBuffer0[i+1]; if(AO_current>AO_prev) AO_up=true; if(AO_currentMACD_prev) MACD_up=true; if(MACD_current