Intento llenar el buffer del indicador desde el otro extremo (ArraySetAsSeries (..., false)), todo funciona bien durante un tiempo, pero luego algo sucede con el buffer y el último índice del array se llena, aunque no debería. Supongo que el terminal recorta el buffer en algún momento y por ello el peso del buffer se llena hasta el último índice del array. Tal vez, el buffer de la matriz debe ser liberado en algún momento, pero ¿cuándo? ¿Puede corregir el ejemplo de prueba?
Pueden decirme por qué este indicador rara vez dibuja flechas en el historial, pero cuando se empieza a operar empieza a dibujar con frecuencia.
Luego si cierras MT4 y lo abres de nuevo, entonces en el mismo lugar donde en tiempo real el indicador como una ametralladora sacaba operaciones, es de nuevo 1-2 operaciones.
Cuando miro el historial parece que el indicador debería operar bien, pero en cuanto paso a operar en tiempo real me salen todo tipo de cosas raras.
Explique por qué, por favor. Aquí está el código del indicador:
//---- indicator settings#property indicator_chart_window#property indicator_buffers2#property indicator_color1 Blue
#property indicator_color2 Red
//---- indicator parametersexternint period = 4; //12externint shift = 0; //сдвиг по бару//---- indicator buffersdouble BufferUp[],BufferDn[];
int q,st=5;
//+------------------------------------------------------------------+//| Custom indicator initialization function |//+------------------------------------------------------------------+int init()
{
IndicatorBuffers(2);
//---- drawing settings
SetIndexStyle(0,DRAW_ARROW,2);
SetIndexArrow(0,233);
SetIndexStyle(1,DRAW_ARROW,2);
SetIndexArrow(1,234);
SetIndexBuffer(0,BufferUp);//стрелка синяя верхSetIndexBuffer(1,BufferDn);//стрелка красная вниз//---- name for DataWindow and indicator subwindow label
IndicatorShortName("T3MA-ALARM ("+period+")");
//---- initialization doneif(Digits==3 || Digits==5) q=10;
st=st*q;
return(0);
}
//+------------------------------------------------------------------+//| |//+------------------------------------------------------------------+int deinit()
{
ObjectDelete("low");
ObjectDelete("high");
}
//+----------------------------------------------------------------------+//| Moving Average of Oscillator |//+----------------------------------------------------------------------+int start()
{
//---- ArraySetAsSeries -------------------------------------------------- double Ma[],MaOn[];
double y0[],y1[],y2[];
// int i;int i;
ArraySetAsSeries(Ma,true);
//---- IndicatorCounted --------------------------------------------------int counted_bars=IndicatorCounted();
if(counted_bars<0) return(-1);
if(counted_bars>0) counted_bars--;
int limit1=Bars-counted_bars;
if(counted_bars==0) limit1-=1+MathMax(period,shift)+2;
int buffer_size=ArraySize(BufferUp);
ArrayResize(Ma,buffer_size);
ArrayResize(MaOn,buffer_size);
ArrayResize(y0,buffer_size+shift+2);
ArrayResize(y1,buffer_size+shift+2);
ArrayResize(y2,buffer_size+shift+2);
int limit=ArraySize(Ma);
//---- EMA --------------------------------------------------------------- for(i=limit1; i>=0; i--) Ma[i] =iMA(NULL,0,period,0,MODE_EMA,PRICE_CLOSE,i);
for(i=limit1; i>=0; i--) MaOn[i]=iMAOnArray(Ma,limit,period,0,MODE_EMA,i);
for(i=limit1; i>=0; i--)
{
y0[i+shift]=MaOn[i+shift];
y1[i+1+shift]=MaOn[i+1+shift];
y2[i+2+shift]=MaOn[i+2+shift];
if(y0[i+shift]-y1[i+1+shift]<0 && y1[i+1+shift]-y2[i+2+shift]>0){BufferDn[i+1]=High[i+1]+st*Point;}
if(y0[i+shift]-y1[i+1+shift]>0 && y1[i+1+shift]-y2[i+2+shift]<0){BufferUp[i+1]=Low[i+1]-st*Point;}
//---- Signal Trend Up || Dn --------------------------------------------- if(y0[i]-y1[i+1]>0) Comment("\n SWAPLONG = ",MarketInfo(Symbol(),MODE_SWAPLONG),
" SWAPSHORT = ",MarketInfo(Symbol(),MODE_SWAPSHORT),"\n BUY TREND ",DoubleToStr(Close[i],Digits));
elseif(y0[i]-y1[i+1]<0) Comment("\n SWAPLONG = ",MarketInfo(Symbol(),MODE_SWAPLONG),
" SWAPSHORT = ",MarketInfo(Symbol(),MODE_SWAPSHORT),"\n SELL TREND ",DoubleToStr(Close[i],Digits));
}
//---- donereturn(0);
}
//+---------------------------------------------------------------------+
При создании пользовательского индикатора можно указать один из 18 типов графического построения (способа отображения на главном окне графика или в подокне графика), значения которых указаны в перечислении ENUM_DRAW_TYPE. В зависимости от стиля рисования, может потребоваться от одного до четырех буферов значений (отмеченных как INDICATOR_DATA...
Vitaly, me he dado cuenta de que la gente escribe una pregunta y se dedica a sus asuntos, mientras nosotros nos divertimos con los demás. A veces hay varias páginas de extractos.
Muchas gracias. Ahora, ¿cómo puedo conseguir que abra las operaciones sólo al final de la vela actual en el marco de tiempo actual? :)) No sé cuándo abre las ofertas ahora... Las flechas parecen estar bien, y mira los candeleros, todo está bien, pero los tratos parecen estar abiertos en el medio o cerca del final de la vela, en general, en todas partes, pero no donde se necesita. :(
//---- indicator settings#property indicator_chart_window#property indicator_buffers2#property indicator_color1 Blue
#property indicator_color2 Red
//---- indicator parametersexternint period = 4; //12externint shift = 0; //сдвиг по бару//---- indicator buffersdouble BufferUp[],BufferDn[];
int q,st=5;
//+------------------------------------------------------------------+//| Custom indicator initialization function |//+------------------------------------------------------------------+int init()
{
IndicatorBuffers(2);
//---- drawing settings
SetIndexStyle(0,DRAW_ARROW,2);
SetIndexArrow(0,233);
SetIndexStyle(1,DRAW_ARROW,2);
SetIndexArrow(1,234);
SetIndexBuffer(0,BufferUp);//стрелка синяя верхSetIndexBuffer(1,BufferDn);//стрелка красная вниз//---- name for DataWindow and indicator subwindow label
IndicatorShortName("T3MA-ALARM ("+period+")");
//---- initialization doneif(Digits==3 || Digits==5) q=10;
st=st*q;
return(0);
}
//+------------------------------------------------------------------+//| |//+------------------------------------------------------------------+int deinit()
{
ObjectDelete("low");
ObjectDelete("high");
}
//+----------------------------------------------------------------------+//| Moving Average of Oscillator |//+----------------------------------------------------------------------+int start()
{
//---- ArraySetAsSeries -------------------------------------------------- double Ma[],MaOn[];
double y0[],y1[],y2[];
// int i;int i;
ArraySetAsSeries(Ma,true);
//---- IndicatorCounted --------------------------------------------------int counted_bars=IndicatorCounted();
if(counted_bars<0) return(-1);
if(counted_bars>0) counted_bars--;
int limit1=Bars-counted_bars;
if(counted_bars==0) limit1-=1+MathMax(period,shift)+2;
int buffer_size=ArraySize(BufferUp);
ArrayResize(Ma,buffer_size);
ArrayResize(MaOn,buffer_size);
ArrayResize(y0,buffer_size+shift+2);
ArrayResize(y1,buffer_size+shift+2);
ArrayResize(y2,buffer_size+shift+2);
int limit=ArraySize(Ma);
//---- EMA --------------------------------------------------------------- for(i=limit1; i>=1; i--) Ma[i] =iMA(NULL,0,period,0,MODE_EMA,PRICE_CLOSE,i);
for(i=limit1; i>=1; i--) MaOn[i]=iMAOnArray(Ma,limit,period,0,MODE_EMA,i);
for(i=limit1; i>=1; i--)
{
y0[i+shift]=MaOn[i+shift];
y1[i+1+shift]=MaOn[i+1+shift];
y2[i+2+shift]=MaOn[i+2+shift];
if(y0[i+shift]-y1[i+1+shift]<0 && y1[i+1+shift]-y2[i+2+shift]>0){BufferDn[i+1]=High[i+1]+st*Point;}
if(y0[i+shift]-y1[i+1+shift]>0 && y1[i+1+shift]-y2[i+2+shift]<0){BufferUp[i+1]=Low[i+1]-st*Point;}
//---- Signal Trend Up || Dn --------------------------------------------- if(y0[i]-y1[i+1]>0) Comment("\n SWAPLONG = ",MarketInfo(Symbol(),MODE_SWAPLONG),
" SWAPSHORT = ",MarketInfo(Symbol(),MODE_SWAPSHORT),"\n BUY TREND ",DoubleToStr(Close[i],Digits));
elseif(y0[i]-y1[i+1]<0) Comment("\n SWAPLONG = ",MarketInfo(Symbol(),MODE_SWAPLONG),
" SWAPSHORT = ",MarketInfo(Symbol(),MODE_SWAPSHORT),"\n SELL TREND ",DoubleToStr(Close[i],Digits));
}
//---- donereturn(0);
}
//+---------------------------------------------------------------------+
En general, se acostumbra a abrir operaciones en el momento en que se forma una nueva vela, cuando ya se tiene toda la información sobre la vela que se acaba de cerrar
int limit=ArraySize(Ma);
//---- EMA --------------------------------------------------------------- // а не вот сюда?for(i=limit1; i>=1; i--) Ma[i] =iMA(NULL,0,period,0,MODE_EMA,PRICE_CLOSE,i);
for(i=limit1; i>=1; i--) MaOn[i]=iMAOnArray(Ma,limit,period,0,MODE_EMA,i);
for(i=limit1; i>=1; i--)
En general, se acostumbra a abrir operaciones en el momento en que se forma una nueva vela, cuando ya se tiene toda la información sobre la vela que acaba de cerrarse
¿Dónde debo insertar este código para que funcione correctamente? Porque no lo entiendo muy bien, sólo estoy al principio de mi viaje...
Aleksei Stepanenko: Vitaly, me he dado cuenta de que la gente escribe una pregunta y se dedica a sus asuntos, mientras nosotros nos divertimos con los demás. A veces hay varias páginas de extractos.
Intento llenar el buffer del indicador desde el otro extremo (ArraySetAsSeries (..., false)), todo funciona bien durante un tiempo, pero luego algo sucede con el buffer y el último índice del array se llena, aunque no debería.
Supongo que el terminal recorta el buffer en algún momento y por ello el peso del buffer se llena hasta el último índice del array. Tal vez, el buffer de la matriz debe ser liberado en algún momento, pero ¿cuándo? ¿Puede corregir el ejemplo de prueba?
Hola.
Pueden decirme por qué este indicador rara vez dibuja flechas en el historial, pero cuando se empieza a operar empieza a dibujar con frecuencia.
Luego si cierras MT4 y lo abres de nuevo, entonces en el mismo lugar donde en tiempo real el indicador como una ametralladora sacaba operaciones, es de nuevo 1-2 operaciones.
Cuando miro el historial parece que el indicador debería operar bien, pero en cuanto paso a operar en tiempo real me salen todo tipo de cosas raras.
Explique por qué, por favor. Aquí está el código del indicador:
intente sustituir el 0 por el 1 en tres lugares
intente sustituir el 0 por el 1 en tres lugares
También movería esto
intente sustituir el 0 por el 1 en tres lugares
Muchas gracias. Ahora, ¿cómo puedo conseguir que abra las operaciones sólo al final de la vela actual en el marco de tiempo actual? :)) No sé cuándo abre las ofertas ahora... Las flechas parecen estar bien, y mira los candeleros, todo está bien, pero los tratos parecen estar abiertos en el medio o cerca del final de la vela, en general, en todas partes, pero no donde se necesita. :(
En general, se acostumbra a abrir operaciones en el momento en que se forma una nueva vela, cuando ya se tiene toda la información sobre la vela que se acaba de cerrar
También movería esto.
¿Estás seguro de que es ahí donde te mostraron?
En general, se acostumbra a abrir operaciones en el momento en que se forma una nueva vela, cuando ya se tiene toda la información sobre la vela que acaba de cerrarse
Vitaly, me he dado cuenta de que la gente escribe una pregunta y se dedica a sus asuntos, mientras nosotros nos divertimos con los demás. A veces hay varias páginas de extractos.