Aiuto per la codifica - pagina 384

 

Ricevo un errore/avviso quando compilo. Qualcuno può per favore renderlo compatibile con le ultime build di MT4... a meno che questo errore non sia un grosso problema.

Molte grazie

jbozman

File:
 
jbozman:
Ricevo un errore/avviso quando compilo. Qualcuno può per favore renderlo compatibile con le ultime build di MT4... a meno che questo errore non sia un grosso problema.

Molte grazie

jbozman

jbozman

Prova ora: price_lines_jlmv_1.mq4

File:
 
mladen:
jbozman Provalo ora: price_lines_jlmv_1.mq4

Nessun errore. Compilato e sembra a posto. Sei forte!

j

 

per favore aiutatemi ... se compilo ... non ho errori

ma a Expert Tab metatrader hanno errore

2014.11.02 15:20:17.495 array out of range in '#MTF__B.mq4' (84,25)[/PHP]

[PHP]

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

//| #MTF__B.mq4 |

//| Copyright 2014, MetaQuotes Software Corp. |

//| https://www.mql5.com |

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

#property copyright "Copyright 2014, MetaQuotes Software Corp."

#property link "https://www.mql5.com"

#property version "1.00"

#property strict

#property indicator_chart_window

#property indicator_chart_window

#property indicator_buffers 2

#property indicator_color1 clrDodgerBlue

#property indicator_color2 clrDeepPink

#property indicator_width1 0

#property indicator_width2 0

//---- input parameters

/*************************************************************************

PERIOD_M1 1

PERIOD_M5 5

PERIOD_M15 15

PERIOD_M30 30

PERIOD_H1 60

PERIOD_H4 240

PERIOD_D1 1440

PERIOD_W1 10080

PERIOD_MN1 43200

You must use the numeric value of the timeframe that you want to use

when you set the TimeFrame' value with the indicator inputs.

---------------------------------------

PRICE_CLOSE 0 Close price.

PRICE_OPEN 1 Open price.

PRICE_HIGH 2 High price.

PRICE_LOW 3 Low price.

PRICE_MEDIAN 4 Median price, (high+low)/2.

PRICE_TYPICAL 5 Typical price, (high+low+close)/3.

PRICE_WEIGHTED 6 Weighted close price, (high+low+close+close)/4.

You must use the numeric value of the Applied Price that you want to use

when you set the 'applied_price' value with the indicator inputs.

**************************************************************************/

extern int TimeFrame=30;

extern int barn=1000;

double ExtMapBuffer1[];

double ExtMapBuffer2[];

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

//| Custom indicator initialization function |

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

int init()

{

//---- indicator line

SetIndexBuffer(0,ExtMapBuffer1);

SetIndexBuffer(1,ExtMapBuffer2);

SetIndexStyle(0,DRAW_ARROW,0,5);

SetIndexStyle(1,DRAW_ARROW,0,5);

SetIndexArrow(0,158);

SetIndexArrow(1,158);

return(0);

}

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

//| |

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

int start()

{

datetime TimeArray[];

int i,limit,y=0,counted_bars=IndicatorCounted();

// Plot defined time frame on to current time frame

ArrayCopySeries(TimeArray,MODE_TIME,NULL,TimeFrame);

limit=Bars-counted_bars;

for(i=0,y=0;i<limit;i++)

{

if (Time<TimeArray[y]) y++; ///// line of error here ...

/***********************************************************

Add your main indicator loop below. You can reference an existing

indicator with its iName or iCustom.

Rule 1: Add extern inputs above for all neccesary values

Rule 2: Use 'TimeFrame' for the indicator time frame

Rule 3: Use 'y' for your indicator's shift value

**********************************************************/

ExtMapBuffer1=iCustom(NULL,TimeFrame,"indicator",1,4,0,y) ;

ExtMapBuffer2=iCustom(NULL,TimeFrame,"indicator",1,4,1,y) ;

}

//

return(0);

}

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

grazie

 
rizkyd:
per favore aiutatemi ... se compilo ... no ho errore

ma in Expert Tab metatrader ha un errore

2014.11.02 15:20:17.495 array out of range in '#MTF__B.mq4' (84,25)[/PHP]

[PHP]

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

//| #MTF__B.mq4 |

//| Copyright 2014, MetaQuotes Software Corp. |

//| https://www.mql5.com |

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

#property copyright "Copyright 2014, MetaQuotes Software Corp."

#property link "https://www.mql5.com"

#property version "1.00"

#property strict

#property indicator_chart_window

#property indicator_chart_window

#property indicator_buffers 2

#property indicator_color1 clrDodgerBlue

#property indicator_color2 clrDeepPink

#property indicator_width1 0

#property indicator_width2 0

//---- input parameters

/*************************************************************************

PERIOD_M1 1

PERIOD_M5 5

PERIOD_M15 15

PERIOD_M30 30

PERIOD_H1 60

PERIOD_H4 240

PERIOD_D1 1440

PERIOD_W1 10080

PERIOD_MN1 43200

You must use the numeric value of the timeframe that you want to use

when you set the TimeFrame' value with the indicator inputs.

---------------------------------------

PRICE_CLOSE 0 Close price.

PRICE_OPEN 1 Open price.

PRICE_HIGH 2 High price.

PRICE_LOW 3 Low price.

PRICE_MEDIAN 4 Median price, (high+low)/2.

PRICE_TYPICAL 5 Typical price, (high+low+close)/3.

PRICE_WEIGHTED 6 Weighted close price, (high+low+close+close)/4.

You must use the numeric value of the Applied Price that you want to use

when you set the 'applied_price' value with the indicator inputs.

**************************************************************************/

extern int TimeFrame=30;

extern int barn=1000;

double ExtMapBuffer1[];

double ExtMapBuffer2[];

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

//| Custom indicator initialization function |

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

int init()

{

//---- indicator line

SetIndexBuffer(0,ExtMapBuffer1);

SetIndexBuffer(1,ExtMapBuffer2);

SetIndexStyle(0,DRAW_ARROW,0,5);

SetIndexStyle(1,DRAW_ARROW,0,5);

SetIndexArrow(0,158);

SetIndexArrow(1,158);

return(0);

}

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

//| |

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

int start()

{

datetime TimeArray[];

int i,limit,y=0,counted_bars=IndicatorCounted();

// Plot defined time frame on to current time frame

ArrayCopySeries(TimeArray,MODE_TIME,NULL,TimeFrame);

limit=MathMin(Bars-counted_bars,Bars-1);

for(i=0,y=0;i<limit;i++)

{

if (Time<TimeArray[y]) y++; ///// line of error here ...

/***********************************************************

Add your main indicator loop below. You can reference an existing

indicator with its iName or iCustom.

Rule 1: Add extern inputs above for all neccesary values

Rule 2: Use 'TimeFrame' for the indicator time frame

Rule 3: Use 'y' for your indicator's shift value

**********************************************************/

ExtMapBuffer1=iCustom(NULL,TimeFrame,"indicator",1,4,0,y) ;

ExtMapBuffer2=iCustom(NULL,TimeFrame,"indicator",1,4,1,y) ;

}

//

return(0);

}

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

grazie

Prova a sostituire questa linea

limit=Bars-counted_bars;

con questo :

limit=MathMin(MathMax(Bars-counted_bars,2*TimeFrame/Period()),Bars-1);

 
mladen:
Prova a sostituire questa linea

limit=Bars-counted_bars;

con questo :

limit=MathMin(MathMax(Bars-counted_bars,2*TimeFrame/Period()),Bars-1);

grazie mladen

 

Ciao Mladen,

Sto avendo problemi a codificare questo EA poiché le regole di entrata sono qualcosa che non ho mai fatto prima.

Per esempio, in questo trade, è semplice scrivere la regola di entrata poiché la freccia verde e rossa appaiono allo stesso tempo. Quindi all'apertura della prossima candela, prendiamo una posizione corta.

Ma, in questo prossimo esempio, ottengo prima la freccia verde senza una freccia rossa. Quindi non prendo la posizione finché non appare la freccia rossa. Inoltre, tutte le candele che sono dopo la freccia verde e prima della freccia rossa devono essere UP, altrimenti questo non è un trade valido.

Come diavolo faccio a codificare questa regola specifica? So come codificarla per la candela corrente, ma non so come specificare queste condizioni. Qualsiasi aiuto sarebbe fantastico!

File:
capture1.jpg  19 kb
capture.jpg  22 kb
 
Jason2005:
Ciao Mladen,

Sto avendo problemi a codificare questo EA poiché le regole di entrata sono qualcosa che non ho mai fatto prima.

Per esempio, in questo trade, è semplice scrivere la regola di entrata poiché la freccia verde e rossa appaiono allo stesso tempo. Quindi all'apertura della prossima candela, prendiamo una posizione corta.

Ma, in questo prossimo esempio, ottengo prima la freccia verde senza una freccia rossa. Quindi non prendo il trade finché non appare la freccia rossa. Inoltre, tutte le candele che sono dopo la freccia verde e prima della freccia rossa devono essere UP, altrimenti questo non è un trade valido.

Come diavolo faccio a codificare questa regola specifica? So come codificarla per la candela corrente, ma non so come specificare queste condizioni. Qualsiasi aiuto sarebbe fantastico!

Jason

Perché non copi le condizioni logiche dal codice che sta creando quelle frecce?

 
mladen:
Jason Perché non copi le condizioni logiche dal codice che sta creando quelle frecce?

Non sono sicuro di aver capito bene quello che stai dicendo...

Quello che sto cercando di capire è come nelle mie condizioni di acquisto o di vendita faccio capire all'EA che quando appare la freccia rossa (cioè il trigger) la condizione è che ci deve essere stata una freccia verde prima e che tutte le candele che seguono quella freccia devono essere UP o DOWN a seconda di quello che serve. Ma non so quando sarebbe apparsa quella freccia verde...

 
Jason2005:
Non sono del tutto sicuro di capire quello che stai dicendo... Quello che sto cercando di scoprire è come nelle mie condizioni di acquisto o vendita faccio capire all'EA che quando appare la freccia rossa (cioè il trigger) la condizione è che ci deve essere stata una freccia verde prima e che tutte le candele che seguono quella freccia devono essere UP o DOWN a seconda di quello che serve. Ma non so quando sarebbe apparsa quella freccia verde...

Ciao Jason2005,

Le frecce rosse e verdi sono valori nei buffer del tuo indicatore.... non del tuo EA....

Usa iCustom nel tuo EA per chiamare i valori del tuo indicatore nei buffer... e poi usali per la tua strategia di trading.

Ci sono molti buoni post qui in questo forum su come usare iCustom nel tuo EA...

Nel frattempo... se alleghi i tuoi indicatori qui... qualcuno potrebbe aiutarti a mostrare quali buffer di indicatori puoi usare nelle tue dichiarazioni iCustom.

Spero che questo aiuti,

Robert

Motivazione: