//+------------------------------------------------------------------+ //| s-StochFlet.mq4 | //| Copyright © 2011, MetaQuotes Software Corp. | //| http://www.metaquotes.net | //+------------------------------------------------------------------+ #property copyright "Copyright © 2011, MetaQuotes Software Corp." #property link "http://www.metaquotes.net" #property indicator_separate_window #property indicator_minimum 0 #property indicator_maximum 100 #property indicator_buffers 5 #property indicator_color1 clrGoldenrod #property indicator_color2 clrWhite #property indicator_color3 clrLimeGreen #property indicator_color4 clrDeepPink #property indicator_color5 clrDeepSkyBlue #property indicator_level1 80 #property indicator_level2 50 #property indicator_level3 20 #property indicator_levelcolor clrOliveDrab #property indicator_levelwidth 1 #property indicator_levelstyle STYLE_DOT #property strict input int KPeriod = 21; input int DPeriod = 12; input int Slowing = 3; input ENUM_MA_METHOD method = MODE_SMA; input ENUM_STO_PRICE price = 0; // 0 - Low/High or 1 - Close/Close input int ExtWPRPeriod = 14; input double ZoneHighPer = 70; input double ZoneLowPer = 30; input bool alertsOn = false; // Alerts on true/false? input bool alertsOnCurrent = true; // Alerts on still opened bar true/false? input bool alertsMessage = true; // Alerts pop-up message true/false? input bool alertsSound = false; // Alerts sound true/false? input bool alertsNotify = false; // Alerts push notification true/false? input bool alertsEmail = false; // Alerts email true/false? input string soundFile = "alert2.wav"; // Sound file double sto[],sig[],huu[],hdd[],wpr[],trend[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int OnInit() { IndicatorBuffers(6); SetIndexBuffer(0,sto,INDICATOR_DATA); SetIndexStyle(0,DRAW_LINE,EMPTY,2); SetIndexLabel(0,"s-StochFlet"); SetIndexBuffer(1,sig,INDICATOR_DATA); SetIndexStyle(1,DRAW_LINE,EMPTY,2); SetIndexLabel(1,"Signal"); SetIndexBuffer(2,huu,INDICATOR_DATA); SetIndexStyle(2,DRAW_HISTOGRAM,EMPTY,2); SetIndexBuffer(3,hdd,INDICATOR_DATA); SetIndexStyle(3,DRAW_HISTOGRAM,EMPTY,2); SetIndexBuffer(4,wpr,INDICATOR_DATA); SetIndexStyle(4,DRAW_LINE,EMPTY,1); SetIndexBuffer(5,trend); IndicatorSetString(INDICATOR_SHORTNAME,"s-StochFlet"); return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| Stochastic oscillator | //+------------------------------------------------------------------+ int OnCalculate(const int rates_total,const int prev_calculated,const datetime &time[], const double &open[], const double &high[], const double &low[], const double &close[], const long &tick_volume[], const long &volume[], const int &spread[]) { int i=rates_total-prev_calculated+1; if (i>=rates_total) i=rates_total-1; // // // for (; i>=0 && !_StopFlag; i--) { sto[i] = iStochastic(NULL,0,KPeriod,DPeriod,Slowing,method,price,MODE_MAIN,i); sig[i] = iStochastic(NULL,0,21, DPeriod,Slowing,method,price,MODE_SIGNAL,i); wpr[i] = 100+(iWPR(NULL,0,ExtWPRPeriod,i)); if (isig[i]) && (sto[i+1]sig[i+1]) && (sto[i+1]>ZoneHighPer) && (sig[i+1]>ZoneHighPer)) trend[i] =-1; } if (i=0; i--) if (tf==iTfTable[i]) return(sTfTable[i]); return(""); }