/* Âõîä íà âîññòàíîâëåíèè òðåíäà ïîñëå îòêàòà íà 2 ÌÀ. */ #property copyright "MainCook: Integer" #property link "for-good-letters@yandex.ru" #property indicator_chart_window #property indicator_buffers 7 #property indicator_color1 CLR_NONE #property indicator_color2 CLR_NONE #property indicator_color3 DeepSkyBlue #property indicator_color4 Red #property indicator_color5 DeepSkyBlue #property indicator_color6 Red #property indicator_color7 Yellow #property indicator_width3 0 #property indicator_width4 0 #property indicator_width5 1 #property indicator_width6 1 //---- input parameters extern int FastMAPeriod=21; // Ïåðèîä áûñòðîé ÌÀ extern int FastMAMethod=1; // Ìåòîä áûñòðîé ÌÀ: 0-SMA, 1-EMA, 2-SMMA, 3-LWMA extern int FastMAPrice=0; // Öåíà áûñòðîé ÌÀ: 0-Close, 1-Open, 2-High, 3-Low, 4-Median, 5-Typical, 6-Weighted extern int SlowMAPeriod=34; // Ïåðèîä ìåäëåííîé ÌÀ extern int SlowMAMethod=1; // Ìåòîä ìåäëåííîé ÌÀ: 0-SMA, 1-EMA, 2-SMMA, 3-LWMA extern int SlowMAPrice=0; // Öåíà ìåäëåííîé: ÌÀ 0-Close, 1-Open, 2-High, 3-Low, 4-Median, 5-Typical, 6-Weighted extern bool TwoBar=true; // Ïðîâåðÿòü ïåðåãèá ÌÀ ïî äâóì áàðàì (ñëåâà îò ýêñòðåìóìà, ñïðàâà âñåãäà ïî îäíîì áàðó) //---- buffers double fma[]; double sma[]; double buy[]; double sell[]; double buy1[]; double sell1[]; double close[]; double cnt[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { //---- indicators IndicatorBuffers(8); SetIndexStyle(0,DRAW_LINE); SetIndexBuffer(0,fma); SetIndexStyle(1,DRAW_LINE); SetIndexBuffer(1,sma); SetIndexStyle(2,DRAW_ARROW); SetIndexArrow(2,225); SetIndexBuffer(2,buy); SetIndexStyle(3,DRAW_ARROW); SetIndexArrow(3,226); SetIndexBuffer(3,sell); SetIndexStyle(4,DRAW_ARROW); SetIndexArrow(4,233); SetIndexBuffer(4,buy1); SetIndexStyle(5,DRAW_ARROW); SetIndexArrow(5,234); SetIndexBuffer(5,sell1); SetIndexStyle(6,DRAW_ARROW); SetIndexArrow(6,251); SetIndexBuffer(6,close); SetIndexBuffer(7,cnt); SetIndexLabel(0,"Fast MA"); SetIndexLabel(1,"Slow MA"); SetIndexLabel(2,""); SetIndexLabel(3,""); SetIndexLabel(4,""); SetIndexLabel(5,""); SetIndexLabel(6,""); //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int start() { int limit=Bars-IndicatorCounted(); for(int i=limit-1;i>=0;i--){ buy[i]=EMPTY_VALUE; sell[i]=EMPTY_VALUE; fma[i]=iMA(NULL,0,FastMAPeriod,0,FastMAMethod,FastMAPrice,i); sma[i]=iMA(NULL,0,SlowMAPeriod,0,SlowMAMethod,SlowMAPrice,i); cnt[i]=cnt[i+1]; buy1[i]=EMPTY_VALUE; sell1[i]=EMPTY_VALUE; close[i]=EMPTY_VALUE; if(fma[i]>sma[i]){ if(fma[i+1]<=sma[i+1]){ close[i]=Low[i]-Point*5; } if(fma[i+3]>fma[i+2] || !TwoBar){ if(fma[i+2]>fma[i+1]){ if(fma[i+1]<fma[i]){ buy[i]=Low[i]-Point*5; if(cnt[i]<0){ cnt[i]=0; } cnt[i]++; if(cnt[i]==1){ buy1[i]=Low[i]-Point*5; } } } } } if(fma[i]<sma[i]){ if(fma[i+1]>=sma[i+1]){ close[i]=High[i]+Point*5; } if(fma[i+3]<fma[i+2] || !TwoBar){ if(fma[i+2]<fma[i+1]){ if(fma[i+1]>fma[i]){ sell[i]=High[i]+Point*5; if(cnt[i]>0){ cnt[i]=0; } cnt[i]--; if(cnt[i]==-1){ sell1[i]=High[i]+Point*5; } } } } } } return(0); } //+------------------------------------------------------------------+
Sample
Analysis
Market Information Used:
Series array that contains the lowest prices of each bar
Series array that contains the highest prices of each bar
Indicator Curves created:
Implements a curve of type DRAW_LINE
Implements a curve of type DRAW_ARROW
Indicators Used:
Moving average indicator
Custom Indicators Used:
Order Management characteristics:
Other Features: