//+------------------------------------------------------------------+ //| Stochastic_Chart.mq4 | //| Yuriy Tokman (YTG) | //| http://ytg.com.ua/ | //+------------------------------------------------------------------+ #property copyright "Yuriy Tokman (YTG)" #property link "http://ytg.com.ua/" #property version "1.00" #property strict #property indicator_chart_window #property indicator_buffers 3 #property indicator_color1 clrDarkViolet #property indicator_color2 clrRed #property indicator_color3 clrLime input int EMA_Period = 12; input ENUM_MA_METHOD EMA_Method = 0; input ENUM_APPLIED_PRICE EMA_Price = 0; input int Kperiod = 5; input int Dperiod = 3; input int slowing = 3; input ENUM_MA_METHOD method = 0; input int price_field =0; //---- buffers double ExtMapBuffer1[]; double ExtMapBuffer2[]; double ExtMapBuffer3[]; string name=""; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- indicator buffers mapping name = "Stochastic_Chart"; IndicatorShortName(name); SetIndexStyle(0,DRAW_LINE); SetIndexBuffer(0,ExtMapBuffer1); SetIndexLabel(0,"Stochastic_Main"); SetIndexDrawBegin(0,MathMax(Kperiod,EMA_Period)); SetIndexStyle(1,DRAW_LINE); SetIndexBuffer(1,ExtMapBuffer2); SetIndexLabel(1,"MA"); SetIndexDrawBegin(1,MathMax(Kperiod,EMA_Period)); SetIndexStyle(2,DRAW_LINE); SetIndexBuffer(2,ExtMapBuffer3); SetIndexLabel(2,"Stochastic_Signal"); SetIndexDrawBegin(2,MathMax(Kperiod,EMA_Period)); //--- return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ 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 limit=rates_total/* - MathMax(EMA_Period,CCI_Period)*/ -prev_calculated; if(prev_calculated==0)limit--; else limit++; double ma=0; for( int i=0; i