Errores, fallos, preguntas - página 917

 
Konstantin83:

Al guardar un archivo csv, los datos no se dividen en columnas. Incluso el script del ejemplo estándar muestra todos los datos en una columna.

Especifique el separador:

filehandle=FileOpen("fractals.csv",FILE_WRITE|FILE_CSV,",");
 
tol64:

Especifique el separador:

No funcionó. Al abrir en Excel dice formato de archivo desconocido y tampoco divide las columnas. Pero si no se especifica un separador y no se especifica una extensión de archivo, también dice formato desconocido, pero el texto se rompe en columnas...
 
Konstantin83:
No funcionó. Al abrir en Excel dice formato de archivo desconocido y tampoco divide las columnas. Pero si no se especifica un separador y no se especifica una extensión de archivo, también dice formato desconocido, pero el texto se divide en columnas...

Hay más cosas que hacer así:

filehandle=FileOpen("fractals.csv",FILE_WRITE|FILE_CSV|FILE_ANSI,",");
 
Hay un problema con los gráficos en las señales. ¿O sólo soy yo?
 

¿Es posible crear un indicador que tenga una línea de amortiguación, por ejemplo, la línea close[] y un comentario en la parte superior izquierda? He intentado hacer un ejemplo sencillo para que mi terminal se cuelgue

#property indicator_chart_window
#property indicator_buffers 1
#property indicator_plots   1
//--- plot Histogram
#property indicator_label1  "1"
#property indicator_type1   DRAW_LINE
#property indicator_color1  clrBlue
#property indicator_style1  STYLE_SOLID
#property indicator_width1  2
double MAbuf1[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- indicator buffers mapping
   ChartGetInteger(0,CHART_VISIBLE_BARS);
   SetIndexBuffer(0,MAbuf1,INDICATOR_DATA);
   return(0);
  }
//+------------------------------------------------------------------+
//| 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 start=0;
//--- если расчет уже производился на предыдущем запуске OnCalculate
   if(prev_calculated>0) start=prev_calculated-1; // установим начало расчетов с предпослденего бара
//--- заполняем индикаторный буфер значениями
   for(int i=start;i<rates_total;i++)
     {
      //----------------------Обнуляем буферы
      MAbuf1[i]=0;
      MAbuf1[i]=close[i];
      Comment("Work");


     }
//--- вернем значение prev_calculated для следующего вызова функции
   return(rates_total);
  }
 
Quitar el comentario del bucle - debería facilitarlo.
 
Dima_S:
Quitar el comentario del bucle - debería facilitarlo.
Gracias, no me di cuenta de que sería una carga tan grande para el sistema
 
¿Cuándo se aplicará la opción #recurso a los archivos de los indicadores? ¿Alguien lo sabe? Realmente quiero combinar todo el proyecto en un archivo .ex5.
 
MoneyJinn:
¿Cuándo se aplicará la opción #recurso a los archivos de los indicadores? ¿Alguien lo sabe? Me gustaría mucho combinar todo el proyecto en un archivo .ex5.
Parece que han prometido esa posibilidad, pero no han dicho cuándo.
 

Por favor, explique por qué el segundo búfer (label2) es cero

#property indicator_chart_window
#property indicator_buffers 2
#property indicator_plots   2
//--- plot Label1
#property indicator_label1  "Label1"
#property indicator_type1   DRAW_LINE
#property indicator_color1  clrRed
#property indicator_style1  STYLE_SOLID
#property indicator_width1  1
//--- plot Label2
#property indicator_label2  "Label2"
#property indicator_type2   DRAW_LINE
#property indicator_color2  clrWhite
#property indicator_style2  STYLE_SOLID
#property indicator_width2  1
//--- indicator buffers
double ExtLineBuffer[];
double ExtLineBuffer2[];
int    InpMAPeriod=13;         // Period
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- indicator buffers mapping
   SetIndexBuffer(0,ExtLineBuffer,INDICATOR_DATA);
   SetIndexBuffer(1,ExtLineBuffer2,INDICATOR_DATA);
   PlotIndexSetDouble(0,PLOT_EMPTY_VALUE,0.0);
   
//---
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const int begin,
                const double &price[])
  {
//--- check for bars count
   if(rates_total<InpMAPeriod-1+begin)
      return(0);// not enough bars for calculation
//--- first calculation or number of bars was changed
   if(prev_calculated==0)
      ArrayInitialize(ExtLineBuffer,0);
//--- sets first bar from what index will be draw
      InpMAPeriod=20;
   int i,limit;
//--- first calculation or number of bars was changed
   if(prev_calculated==0)// first calculation
     {
      limit=InpMAPeriod+begin;
      //--- set empty value for first limit bars
      for(i=0;i<limit-1;i++) ExtLineBuffer[i]=0.0;
      //--- calculate first visible value
      double firstValue=0;
      for(i=begin;i<limit;i++)
         firstValue+=price[i];
      firstValue/=InpMAPeriod;
      ExtLineBuffer[limit-1]=firstValue;
      //ExtLineBuffer[i]=1;
     }
   else limit=prev_calculated-1;
//--- main loop
   for(i=limit;i<rates_total && !IsStopped();i++)
   ExtLineBuffer[i]=ExtLineBuffer[i-1]+(price[i]-price[i-InpMAPeriod])/InpMAPeriod;
   ExtLineBuffer2[i]=ExtLineBuffer[i];
//--- return value of prev_calculated for next call
   Comment(ExtLineBuffer[rates_total-1]);
   return(rates_total);
  }
//+------------------------------------------------------------------+

1) Por alguna razón, la función OnCalculate no tiene problemas con los búferes múltiples, donde hay cierre, apertura, etc. por separado.

2) Me encantaría usarlo, pero falla el algoritmo de cálculo de medias móviles que se describe en el código anterior

ExtLineBuffer2[i] trató de asignar diferentes valores incluyendo constantes - siempre cero