//+------------------------------------------------------------------+
//|                                                  iStoh_test3.mq4 |
//|                                          Copyright 2013, artamir |
//|                                          http:\\forexmd.ucoz.org |
//+------------------------------------------------------------------+
#property copyright "Copyright 2013, artamir"
#property link      "http:\\forexmd.ucoz.org"

#property indicator_separate_window
#property indicator_minimum 1
#property indicator_maximum 100
#property indicator_buffers 8
#property indicator_color1 LightGreen
#property indicator_color2 Red
#property indicator_color3 Yellow
#property indicator_color4 LightGreen
#property indicator_color5 Red
#property indicator_color6 Yellow

#include <sysOther.mqh>
#include <sysStructure.mqh>
#include <sysNormalize.mqh>
#include <iStoh.mqh>

double M[];
double S[];
double A[];
double MH4[];
double SH4[];
double AH4[];


int Sth, Sth_h4;

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
   //---- indicators
   aSth_Init();	     //инициализация массива,
	Sth = aSth_set();   //предопределенные параметры на текущем тф
   Sth_h4 = aSth_set(5,3,3,MODE_SMA,0,"",240);//Задаем значения для тф = H4(240 мин.)
   //----
   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0,M);
   SetIndexEmptyValue(0,0.0);
   
   SetIndexStyle(1,DRAW_LINE);
   SetIndexBuffer(1,S);
   SetIndexEmptyValue(1,0.0);
   
   SetIndexStyle(2,DRAW_LINE);
   SetIndexBuffer(2,A);
   SetIndexEmptyValue(2,0.0);
   
   SetIndexStyle(3,DRAW_LINE);
   SetIndexBuffer(3,MH4);
   SetIndexEmptyValue(3,0.0);
   
   SetIndexStyle(4,DRAW_LINE);
   SetIndexBuffer(4,SH4);
   SetIndexEmptyValue(4,0.0);
   
   SetIndexStyle(5,DRAW_LINE);
   SetIndexBuffer(5,AH4);
   SetIndexEmptyValue(5,0.0);
   //----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int   cb=IndicatorCounted();
   int   lim = Bars - cb;
   
   if(lim<=0)lim++;
  
   for(int i=lim; i>=0; i--){
      M[i] = iSth_get(Sth, MODE_MAIN, i);
      S[i] = iSth_get(Sth, MODE_SIGNAL, i);
      A[i] = iSth_get(Sth, ST_MODE_AVG, i);
      
      MH4[i] = iSth_get(Sth_h4, MODE_MAIN, i);
      SH4[i] = iSth_get(Sth_h4, MODE_SIGNAL, i);
      AH4[i] = iSth_get(Sth_h4, ST_MODE_AVG, i);
   }
//----
   
//----
   return(0);
  }
