Author: Copyright 2018, STSIAPAN KREIDZICH
Indicators Used
Stochastic oscillator
0 Views
0 Downloads
0 Favorites
STEP_STOCH
ÿþ//+------------------------------------------------------------------+

//|                                                   STEP_STOCH.mq4 |

//|                              Copyright 2018,  STSIAPAN KREIDZICH |

//|                                                 step_bot@mail.ru |

//+------------------------------------------------------------------+

#property copyright "Copyright 2018,  STSIAPAN KREIDZICH"

#property link      "step_bot@mail.ru"

#property version   "18.81" 

#property description "Stochastics Multi and not delayed."

#property description "Forex trade MT4 Indicator."

#property strict

#property indicator_separate_window



#property indicator_minimum 0

#property indicator_maximum 123

#property indicator_level1 25

#property indicator_level2 50

#property indicator_level3 75

#property indicator_level4 100



#property indicator_buffers 7  

#property indicator_color1  C'192,141,239'   // h4 

#property indicator_color2  C'113,113,255'   // h1 

#property indicator_color3  MediumSeaGreen   // m30

#property indicator_color4  Orange           // m15

#property indicator_color5  OrangeRed        // m5

#property indicator_color6  DarkTurquoise    // m1 

#property indicator_color7  IndianRed        // m1s 

#property indicator_levelcolor LightSlateGray

#property indicator_levelwidth 1

#property indicator_levelstyle STYLE_DOT



//--- input parameters 



input int KPeriod = 5; 

input int DPeriod = 3; 

input int Slowing = 3; 

input int Mode_   = 3; // MODE_LWMA 

input color ColorBack  = C'45,45,45'; 

input color ColorText  = Gold; 

input string When_White_chart_Recommended = "ColorText=Black, ColorBack=LightGray"; 



//---

static string short_name ="STEP_STOCH"; 

static bool   NewBar1 =0, ReInit =0; 

static int    screen_dpi, KMON=0, i, oldBars =0; 

static datetime oldbarTime1 =0; 

static color cl[7]; 



//--- buffers



static double MainBuffer[];

static double SignalBuffer[];

static double Buff_5[];

static double Buff_15[];

static double Buff_30[];

static double Buff_h1[];

static double Buff_h4[];



//+------------------------------------------------------------------+

//| Custom indicator initialization function                         |

//+------------------------------------------------------------------+

int OnInit()

  {

   IndicatorBuffers(7);

   IndicatorShortName(short_name);

   IndicatorDigits(0); 



   SetIndexStyle (0, DRAW_LINE);

   SetIndexBuffer(0, Buff_h4);

   SetIndexLabel (0,"Stoch_h4");

   SetIndexStyle (1, DRAW_LINE);

   SetIndexBuffer(1, Buff_h1);

   SetIndexLabel (1,"Stoch_h1");

   SetIndexStyle (2, DRAW_LINE);

   SetIndexBuffer(2, Buff_30);

   SetIndexLabel (2,"Stoch_M30");

   SetIndexStyle (3, DRAW_LINE);

   SetIndexBuffer(3, Buff_15);

   SetIndexLabel (3,"Stoch_M15");

   SetIndexStyle (4, DRAW_LINE);

   SetIndexBuffer(4, Buff_5);

   SetIndexLabel (4,"Stoch_M5");

   SetIndexStyle (5, DRAW_LINE);

   SetIndexBuffer(5, MainBuffer);

   SetIndexLabel (5, "Stoch M1");

   SetIndexStyle (6, DRAW_LINE);

   SetIndexBuffer(6, SignalBuffer);

   SetIndexLabel (6, "Signal M1");



   ChartSetInteger(0,CHART_SHOW_OBJECT_DESCR,1);

   ChartSetInteger(0,CHART_SHIFT,1);

   ChartSetDouble (0,CHART_SHIFT_SIZE,10);



   screen_dpi = TerminalInfoInteger(TERMINAL_SCREEN_DPI); KMON =(screen_dpi*100)/101; 



   if(ColorBack != Black) //45,45,45                                    // indicator background 

   { string stfon; string fonch = StringSetChar("",0,103); 

     int highi = (int)ChartGetInteger(0,CHART_HEIGHT_IN_PIXELS,1)*3; 



     for (int t =0; t <9; t++) 

     { stfon = IntegerToString(t); 

       ObjectCreate(stfon, OBJ_LABEL,WindowFind(short_name),0,0); 

       ObjectSet(stfon, OBJPROP_CORNER,CORNER_RIGHT_LOWER); 

       ObjectSet(stfon, OBJPROP_BACK,1);

       ObjectSet(stfon, OBJPROP_XDISTANCE,((t*highi)*KMON)/100);

       ObjectSet(stfon, OBJPROP_YDISTANCE,0); 

       ObjectSetText(stfon,fonch,highi,"Webdings",ColorBack);

     }

   }  

   ObjectCreate("lin",OBJ_HLINE,WindowFind(short_name),iTime(NULL,0,0),100);  // Trend LINE...100 

   ObjectSet("lin",OBJPROP_STYLE, STYLE_DOT); 

   ObjectSet("lin",OBJPROP_WIDTH, 1);

   ObjectSet("lin",OBJPROP_COLOR,ColorText);  

   ObjectSet("lin", OBJPROP_BACK,0); 



   ObjectCreate("Period",OBJ_LABEL,WindowFind(short_name),0,0); 

   ObjectSet("Period",OBJPROP_CORNER,0);

   ObjectSet("Period",OBJPROP_XDISTANCE,(184*KMON)/100); 

   ObjectSet("Period",OBJPROP_YDISTANCE,(2*KMON)/100); 

   ObjectSetText("Period","H4 H1 M30 M15 M5 M1 M1s",8,"Arial",ColorText);     // "H4 H1 M30 M15 M5



   ObjectCreate("stname",OBJ_LABEL,WindowFind(short_name),0,0); 

   ObjectSet("stname",OBJPROP_CORNER,0);

   ObjectSet("stname",OBJPROP_XDISTANCE,(334*KMON)/100); 

   ObjectSet("stname",OBJPROP_YDISTANCE,(3*KMON)/100);                   

   ObjectSetText("stname","Kreidzich Stochastics  M1 TIME",8,"Arial",ColorText);  



   cl[0]=indicator_color1; cl[1]=indicator_color2; cl[2]=indicator_color3; 

   cl[3]=indicator_color4; cl[4]=indicator_color5; cl[5]=indicator_color6; 

                                                   cl[6]=indicator_color7;

   for (int t=0; t<7; t++) 

   {                                                                           // Colors

   ObjectCreate("Color"+IntegerToString(t), OBJ_LABEL,WindowFind(short_name),0,0);

   ObjectSet("Color"+IntegerToString(t), OBJPROP_CORNER,0);

   ObjectSet("Color"+IntegerToString(t), OBJPROP_XDISTANCE, ((184+(t*19))*KMON)/100); 

   ObjectSet("Color"+IntegerToString(t), OBJPROP_YDISTANCE,(-10*KMON)/100); 

   ObjectSetText("Color"+IntegerToString(t),"_",18,"Arial Bold",cl[t]); 

   } 

                                                                               // <Minute Time Stoch

   ObjectCreate("StochMinute",OBJ_LABEL,WindowFind(short_name),0,0); 

   ObjectSet("StochMinute",OBJPROP_CORNER,3);

   ObjectSet("StochMinute",OBJPROP_XDISTANCE,(1*KMON)/100); 

   ObjectSet("StochMinute",OBJPROP_YDISTANCE,(1*KMON)/100);

   ObjectSetText("StochMinute","< Minute ",9,"Arial",ColorText); 



   ObjectCreate("scale",OBJ_LABEL,WindowFind(short_name),0,0); 

   ObjectSet("scale",OBJPROP_CORNER,3);

   ObjectSet("scale",OBJPROP_XDISTANCE,(1*KMON)/100); 

   ObjectSet("scale",OBJPROP_YDISTANCE,(16*KMON)/100);

   ObjectSetText("scale","Time Stoch",8,"Arial",ColorText); 



  ReInit=1; 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[])

  {

   MainBuffer[0]   =iStochastic(NULL,1,KPeriod,DPeriod,Slowing,Mode_,0,MODE_MAIN,0);

   SignalBuffer[0] =iStochastic(NULL,1,KPeriod,DPeriod,Slowing,Mode_,0,MODE_SIGNAL,0);



   if(iTime(NULL,1,0)==oldbarTime1) NewBar1=0; 

   else NewBar1=1; oldbarTime1=iTime(NULL,1,0); 



   if(NewBar1 || ReInit || (oldBars!=Bars))

   { 

     GETSTOCH();

     i=0; 

     while(i < Bars-1) 

     { if(ObjectFind("min"+IntegerToString(i))) ObjectDelete("min"+IntegerToString(i)); 

       i++;

     }                                        

     i=0; 

     while(i < WindowBarsPerChart()-15) 

     { string minut="min"+IntegerToString(i);

       ObjectCreate(minut,OBJ_VLINE,WindowFind(short_name),iTime(NULL,Period(),i),0); 

       ObjectSet(minut,OBJPROP_BACK,1); 

       ObjectSet(minut,OBJPROP_STYLE,STYLE_DOT); 

       ObjectSet(minut,OBJPROP_WIDTH,1); 

       ObjectSet(minut,OBJPROP_COLOR,DarkGray);

       ObjectCreate(minut,OBJ_LABEL,WindowFind(short_name),iTime(NULL,Period(),i),0); 

       string min="0"; if(i>0) min="-"+IntegerToString(i); 

       ObjectSetText(minut,min); 

       i=i+15; if (i>240) break;

    }}

  oldBars=Bars; ReInit=0; return(rates_total);

  }

//+------------------------------------------------------------------+

void GETSTOCH()  

{

    i=Bars-1; while (i>=0) {

    MainBuffer[i] = iStochastic(NULL,1,KPeriod*1,DPeriod*1,Slowing*1,Mode_,0,MODE_MAIN,i);

    SignalBuffer[i]=iStochastic(NULL,1,KPeriod*1,DPeriod*1,Slowing*1,Mode_,0,MODE_SIGNAL,i);

    Buff_5[i] = iStochastic(NULL,1,KPeriod*5,DPeriod*5,Slowing*5,Mode_,0,MODE_MAIN,i);

    Buff_15[i] =iStochastic(NULL,1,KPeriod*15,DPeriod*15,Slowing*15,Mode_,0,MODE_MAIN,i);

    Buff_30[i] =iStochastic(NULL,1,KPeriod*30,DPeriod*30,Slowing*30,Mode_,0,MODE_MAIN,i);

    Buff_h1[i] =iStochastic(NULL,1,KPeriod*60,DPeriod*60,Slowing*60,Mode_,0,MODE_MAIN,i);

    Buff_h4[i] =iStochastic(NULL,1,KPeriod*240,DPeriod*240,Slowing*60,Mode_,0,MODE_MAIN,i); 

     i--;                  } 

}

// End file

Comments

Markdown supported. Formatting help

Markdown Formatting Guide

Element Markdown Syntax
Heading # H1
## H2
### H3
Bold **bold text**
Italic *italicized text*
Link [title](https://www.example.com)
Image ![alt text](image.jpg)
Code `code`
Code Block ```
code block
```
Quote > blockquote
Unordered List - Item 1
- Item 2
Ordered List 1. First item
2. Second item
Horizontal Rule ---