//+------------------------------------------------------------------+ //| Kaufman_RSI.mq4 | //| Copyright © -2005, by konKop & wellx | //| http://www.metaquotes.net | //+------------------------------------------------------------------+ #property copyright "baramantan" #property link "baramantan@mail.ru" #property indicator_separate_window #property indicator_buffers 4 #property indicator_color1 Sienna #property indicator_color2 Blue #property indicator_color3 OrangeRed #property indicator_color4 Red //---- input parameters extern int periodAMA=10; extern int nfast=3; extern int nslow=10;//30 extern double G=4.0; extern double dK=450; extern int RSI=200; //---- buffers double kAMAbuffer[]; double kAMAupsig[]; double kAMAdownsig[]; double NewIndikator[]; double trend[]; //+------------------------------------------------------------------+ int k=0,cbars=0,prevbars=0,prevtime=0; double slowSC,fastSC,AMA0; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { //---- indicators IndicatorBuffers(5); SetIndexStyle(0,DRAW_LINE); SetIndexBuffer(0,kAMAbuffer); SetIndexStyle(1,DRAW_ARROW,0,3); SetIndexArrow(1,159); SetIndexBuffer(1,kAMAupsig); SetIndexStyle(2,DRAW_ARROW,0,3); SetIndexArrow(2,159); SetIndexBuffer(2,kAMAdownsig); SetIndexStyle(3,DRAW_LINE); SetIndexBuffer(3,NewIndikator); SetIndexBuffer(4,trend); //SetIndexDrawBegin(0,nslow+nfast); //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator deinitialization function | //+------------------------------------------------------------------+ int deinit() { return(0); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int start() { //---------------NewIndikator int i,pos=0; double noise=0.000000001,AMA,signal,ER; double dSC,ERSC,SSC,ddK; //---- TODO: add your code here slowSC=(2.0 /(nslow+1)); fastSC=(2.0 /(nfast+1)); if(Bars<=(periodAMA+2)) return(0); //---- check for possible errors int counted_bars=IndicatorCounted(); if(counted_bars<0) return(-1); if(counted_bars>0) counted_bars--; int limit=Bars-counted_bars; if(counted_bars==0) limit-=1+periodAMA+1; for(pos=limit-1;pos>=0;pos--) { NewIndikator[pos]=iRSI(NULL,0,RSI,0,pos); kAMAupsig[pos] =NULL; kAMAdownsig[pos]=NULL; if(pos==Bars-periodAMA-2) AMA0=iRSI(NULL,0,RSI,0,pos+1); signal=MathAbs(iRSI(NULL,0,RSI,0,pos)-iRSI(NULL,0,RSI,0,pos+periodAMA)); noise=0.000000001; for(i=0;i (dK*Point)) && (ddK > 0)) {kAMAupsig[pos] =AMA;kAMAdownsig[pos]=EMPTY_VALUE;trend[pos]=1;break;} if((MathAbs(ddK)) > (dK*Point) && (ddK < 0)) {kAMAdownsig[pos]=AMA;kAMAupsig[pos] =EMPTY_VALUE;trend[pos]=-1;break;} kAMAupsig[pos] =EMPTY_VALUE; kAMAdownsig[pos]=EMPTY_VALUE; break; } AMA0=AMA; } //---- return(0); } //+------------------------------------------------------------------+