//+------------------------------------------------------------------+ //| MagicOscillator.mq4 | //| zfs | //| @ | //+------------------------------------------------------------------+ #property copyright "zfs" #property link "@" //---- indicator settings #property indicator_separate_window #property indicator_buffers 4 #property indicator_color3 Red #property indicator_color4 Blue #property indicator_width3 5 #property indicator_width4 5 //---- indicator buffers double AOBuffer[]; double TempBuffer[]; double OscBuyBuffer[]; double OscSellBuffer[]; int init() { SetIndexStyle(0,DRAW_NONE); SetIndexStyle(1,DRAW_NONE); SetIndexStyle(2,DRAW_HISTOGRAM); SetIndexStyle(3,DRAW_HISTOGRAM); IndicatorDigits(Digits+1); SetIndexDrawBegin(0,34); SetIndexDrawBegin(1,34); SetIndexDrawBegin(2,34); SetIndexDrawBegin(3,34); SetIndexBuffer(0,AOBuffer); SetIndexBuffer(1,TempBuffer); SetIndexBuffer(2,OscBuyBuffer); SetIndexBuffer(3,OscSellBuffer); IndicatorShortName("MAGICOSCILLATOR"); SetIndexLabel(2,NULL); SetIndexLabel(3,NULL); return(0); } int start() { int limit; int counted_bars=IndicatorCounted(); double prev,current; if(counted_bars>0) counted_bars--; limit=Bars-counted_bars; for(int i=0; i<limit; i++) { double high2=iHigh(NULL,0,i+2); double low2=iLow(NULL,0,i+2); double close2=iClose(NULL,0,i+2); double high1=iHigh(NULL,0,i+1); double low1=iLow(NULL,0,i+1); double close1=iClose(NULL,0,i+1); double ao1=iAO(NULL,0,i+1); double ao0=iAO(NULL,0,i); double close0=iClose(NULL,0,i);//òåêóùàÿ öåíà double deltab=0;double deltas=0; double deltab2=0;double deltas2=0; if (close1>(high1+low1)/2.0)deltab=close0-high1; if (close1<(high1+low1)/2.0)deltas=low1-close0; if (close2>(high2+low2)/2.0)deltab2=close1-high2; if (close2<(high2+low2)/2.0)deltas2=low2-close1; if (ao0>ao1) { if (deltas>0||deltas2>0)TempBuffer[i]=-1; else TempBuffer[i]=1; } if (ao0<ao1) { if (deltab>0||deltab2>0)TempBuffer[i]=1; else TempBuffer[i]=-1; } } for(i=0; i<limit; i++) { if (TempBuffer[i]>0) { OscBuyBuffer[i]=TempBuffer[i]; OscSellBuffer[i]=0; } if (TempBuffer[i]<0) { OscSellBuffer[i]=TempBuffer[i]; OscBuyBuffer[i]=0; } } return(0); }
Sample
Analysis
Market Information Used:
Series array that contains the highest prices of each bar
Series array that contains the lowest prices of each bar
Series array that contains close prices for each bar
Indicator Curves created:
Implements a curve of type DRAW_NONE
Implements a curve of type DRAW_HISTOGRAM
Indicators Used:
Bill Williams Awesome oscillator
Custom Indicators Used:
Order Management characteristics:
Other Features: