#property copyright "Aleksei Parvatkin, 22/05/2009" #property link "alexpar@list.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 Goldenrod #property indicator_width3 0 #property indicator_width4 0 #property indicator_width5 1 #property indicator_width6 1 //---- input parameters extern int RSIPeriod=5; extern int MAPeriod=5; extern bool TwoBar=true; // Ïðîâåðÿòü ïåðåãèá ïî äâóì áàðàì (ñëåâà îò ýêñòðåìóìà, ñïðàâà âñåãäà ïî îäíîì áàðó) //---- buffers double macd_m[]; double macd_s[]; double ma_rsi1[]; double ma_rsi2[]; 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,ma_rsi1); SetIndexStyle(1,DRAW_LINE); SetIndexBuffer(1,ma_rsi2); 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; ma_rsi1[i]=iCustom(NULL, 0, "MA_RSI",RSIPeriod,0,MAPeriod,PRICE_CLOSE,i); ma_rsi2[i]=iCustom(NULL, 0, "MA_RSI",RSIPeriod,0,MAPeriod,PRICE_CLOSE,i+1); macd_m[i]=iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_MAIN,i); macd_s[i]=iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_SIGNAL,i); cnt[i]=cnt[i+1]; buy1[i]=EMPTY_VALUE; sell1[i]=EMPTY_VALUE; close[i]=EMPTY_VALUE; if(ma_rsi1[i]>ma_rsi2[i]){ if(ma_rsi1[i+1]<=ma_rsi2[i+1]&& macd_m[i+1]>macd_s[i+1]){ close[i]=Low[i]-Point*7; } if(ma_rsi1[i+3]>ma_rsi1[i+2] || !TwoBar){ if(ma_rsi1[i+2]>ma_rsi1[i+1]){ if(ma_rsi1[i+1]<ma_rsi1[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(ma_rsi1[i]<ma_rsi2[i]){ if(ma_rsi1[i+1]>=ma_rsi2[i+1]&& macd_m[i+1]<macd_s[i+1]){ close[i]=High[i]+Point*7; } if(ma_rsi1[i+3]<ma_rsi1[i+2] || !TwoBar){ if(ma_rsi1[i+2]<ma_rsi1[i+1]){ if(ma_rsi1[i+1]>ma_rsi1[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:
MACD Histogram
Custom Indicators Used:
MA_RSI
Order Management characteristics:
Other Features: