//+------------------------------------------------------------------+ //| MagicOscillator2.00.mq4 | //| zfs | //| @ | //+------------------------------------------------------------------+ #property copyright "zfs" #property link "vasbsm@mail.ru" //---- indicator settings #property indicator_separate_window #property indicator_buffers 4 #property indicator_color2 Red #property indicator_color3 Blue #property indicator_width2 5 #property indicator_width3 5 #property indicator_minimum 0 #property indicator_maximum 100 //---- #define SIGNAL_BAR 0 //---- extern bool Alerts=true; extern int Period1=5;//основной период extern int Period2=34;//сглаживающий период extern int TypeMA=MODE_SMA;//0-3 extern int TypePrice=PRICE_MEDIAN;//0-6 extern int delta1buy=0;//отключение -1 extern int delta1sell=0;//отключение -1 extern int delta2buy=0;//отключение -1 extern int delta2sell=0;//отключение -1 extern int delta3buy=-1;//отключение -1 extern int delta3sell=-1;//отключение -1 //---- indicator buffers double TempBuffer[]; double OscBuyBuffer[]; double OscSellBuffer[]; int init() { SetIndexStyle(0,DRAW_NONE); SetIndexStyle(1,DRAW_HISTOGRAM); SetIndexStyle(2,DRAW_HISTOGRAM); IndicatorDigits(Digits); SetIndexDrawBegin(0,Period2); SetIndexDrawBegin(1,Period2); SetIndexDrawBegin(2,Period2); SetIndexBuffer(0,TempBuffer); SetIndexBuffer(1,OscBuyBuffer); SetIndexBuffer(2,OscSellBuffer); IndicatorShortName("MAGIC OSCILLATOR 2.00"); SetIndexLabel(1,NULL); SetIndexLabel(2,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; ihigh0) { h10=high0; hmax10=high1; } else { h10=high1; hmax10=high0; } if (low1(high1+low1)/2.0)deltab1=close0-high1; if (close1<(high1+low1)/2.0)deltas1=low1-close0; if (close2>(high2+low2)/2.0)deltab2=close1-high2; if (close2<(high2+low2)/2.0)deltas2=low2-close1; if (close3>(high3+low3)/2.0)deltab3=close2-high3; if (close3<(high3+low3)/2.0)deltas3=low3-close2; if (delta1buy==-1)delta1buy=9999; if (delta2buy==-1)delta2buy=9999; if (delta3buy==-1)delta3buy=9999; if (delta1sell==-1)delta1sell=9999; if (delta2sell==-1)delta2sell=9999; if (delta3sell==-1)delta3sell=9999; int Break1=0; int Break2=0; int Break3=0; if (deltas3>delta3sell*Point&&deltas3>=deltab3&&ao0>ao1)Break3=-1; if (deltab3>delta3buy*Point&&deltab3>=deltas3&&ao0delta2sell*Point&&deltas2>=deltab2&&ao0>ao1)Break2=-1; if (deltab2>delta2buy*Point&&deltab2>=deltas2&&ao0delta1sell*Point&&deltas1>=deltab1&&ao0>ao1)Break1=-1; if (deltab1>delta1buy*Point&&deltab1>=deltas1&&ao0ao1)TempBuffer[i]=Repaint; else TempBuffer[i]=-Repaint; } } } } for(i=0; i0) { OscBuyBuffer[i]=TempBuffer[i]; OscSellBuffer[i]=0; } if (TempBuffer[i]<0) { OscSellBuffer[i]=-TempBuffer[i]; OscBuyBuffer[i]=0; } } if (Alerts) { //---- Статические переменные, в которых хранятся //---- время последнего бара и направление последнего сигнала static int PrevSignal = 0, PrevTime = 0; //---- Если баром для анализа выбран не 0-й, нам нет смысла проверять сигнал //---- несколько раз. Если не начался новый бар, выходим. if(SIGNAL_BAR > 0 && Time[0] <= PrevTime ) return(0); //---- Отмечаем, что этот бар проверен PrevTime = Time[0]; //---- Если предыдущий сигнал был СЕЛЛ или это первый запуск (PrevSignal=0) if(PrevSignal <= 0) { if(OscBuyBuffer[SIGNAL_BAR]> 0 && OscSellBuffer[SIGNAL_BAR+1]> 0) { PrevSignal = 1; Alert("MAGIC (", Symbol(), ", ", Period(), ") - BUY!!!"); } } if(PrevSignal >= 0) { if(OscSellBuffer[SIGNAL_BAR]> 0 && OscBuyBuffer[SIGNAL_BAR+1]> 0) { PrevSignal = -1; Alert("MAGIC (", Symbol(), ", ", Period(), ") - SELL!!!"); } } } //-- return(0); }