//+------------------------------------------------------------------+
//|                                       contenido en envelopes.mq4 |
//|                        Copyright 2017, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2017, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict
#property indicator_chart_window
//--- input parameters
input string   pares="EURUSD,GBPUSD,USDJPY,AUDCAD,AUDJPY,AUDNZD,AUDUSD,CADJPY,EURAUD,EURCAD,EURGBP,EURJPY,EURNZD,GBPAUD,GBPAUD,GBPCAD,GBPJPY,GBPNZD,NZDCAD,NZDJPY,NZDUSD,USDCAD,AUDCHF,CADCHF,CHFJPY,EURCHF,GBPCHF,NZDCHF";
input int      periodo=47;
input double   desviacion=0.3;
input int      vela_atras=1;
input ENUM_MA_METHOD metodo=MODE_SMMA;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- indicator buffers mapping
   
//---
   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[])
  {
//---
string sumadepares,par_actual;
double precio_actual,envelope_superior,envelope_inferior;
for (int i=0;i<StringLen(pares);i++)
{
par_actual=StringSubstr(pares,i,6);
precio_actual=SymbolInfoDouble(par_actual,SYMBOL_BID);
envelope_superior=iEnvelopes(par_actual,PERIOD_CURRENT,periodo,metodo,vela_atras,PRICE_CLOSE,desviacion,MODE_UPPER,0);
envelope_inferior=iEnvelopes(par_actual,PERIOD_CURRENT,periodo,metodo,vela_atras,PRICE_CLOSE,desviacion,MODE_LOWER,0);
if(precio_actual<envelope_superior && precio_actual>envelope_inferior) sumadepares=sumadepares+par_actual+" \n";

i=i+6;
Comment(sumadepares);
}



   
//--- return value of prev_calculated for next call
   return(rates_total);
  }
//+------------------------------------------------------------------+
