Come codificare? - pagina 338

 
at120:
Ciao Malden!

Grazie per il tuo supporto! ;-)

Anche quando scrivo il codice come mi hai detto:

(Penso di sì...)

#property indicator_chart_window

double buffer[];

double mom1[];

int init() { SetIndexBuffer(0,buffer); SetIndexBuffer(1,mom1);return(0); }

int deinit() { return(0); }

int start()

{

int counted_bars=IndicatorCounted();

if(counted_bars<0) return(-1);

if(counted_bars>0) counted_bars--;

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

for(int i = limit; i>=0; i--)

{

mom1 = iCustom(NULL,0,"custom name",0,i);

buffer = (

Mom(mom1,10,Bars,i);

//doesn't work - no value in indi

// Mom(mom1,10,Bars,i); //error: parameter conversation not allowed

// mom1 // this works

);

}

return(0);

}

double Mom(const double& series[], int period, int totcount, int index)

{

if (totcount<1 || period<1) return (EMPTY_VALUE);

if (indextotcount-1) return (EMPTY_VALUE);

return (series-series);

}

);

Quindi quando uso la "prima" versione, non ottengo nessun valore...

Quando uso la seconda versione, ottengo l'errore... hmmm.

Solo chiamare il mom1 funziona... ma questo non è il valore giusto...

Grazie per il tuo aiuto!

Ciao, AT

Sostituisci il "nome personalizzato" con il nome del tuo indicatore (indicatore esistente), aggiungi i parametri alla chiamata iCustom() e funzionerà. Quel nome è stato messo lì solo come esempio

Inoltre, non hai definito il numero di buffer (né usando la #proprietà indicator_buffers, né usando la funzione IndicatorBuffers()) L'indicatore "pensa" che ci siano 0 buffer e non inizializzerà mai questi stronzi alla dimensione reale. Definite il numero di buffer che userete

_______________________

 

Ciao Mladen!

Grazie per le tue informazioni... Ho già fatto questo... Il codice si presenta così:

#property indicator_separate_window

#property indicator_color3 Red

#property indicator_width1 3

#property indicator_buffers 3

#property indicator_color1 LawnGreen

#property indicator_color2 Red

#include // here the mom() function is incl.

double buffer[];

double mom1[];

int init() { SetIndexBuffer(0,buffer); SetIndexBuffer(1,mom1);return(0); }

int deinit() { return(0); }

int start()

{

int counted_bars=IndicatorCounted();

if(counted_bars<0) return(-1);

if(counted_bars>0) counted_bars--;

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

for(int i = limit; i>=0; i--)

{

mom1 = iCustom(NULL,0,"myIndi",0,i);

buffer = (

Mom(mom1,10,Bars,i); //doesn't work - no value in indi

// Mom(mom1,10,Bars,i); //error: parameter conversation not allowed

// mom1 // this works, but no subfunction incl.

);

}

return(0);

}

//normaly in mqh incl.

double Mom(const double& series[], int period, int totcount, int index)

{

if (totcount<1 || period<1) return (EMPTY_VALUE);

if (indextotcount-1) return (EMPTY_VALUE);

return (series-series);

}

);

L'errore di conversazione è ancora lì...

Grazie per il tuo aiuto!

Ciao, AT

 
at120:
Ciao Mladen!

Grazie per le tue informazioni... Ho già fatto questo... Il codice si presenta così:

#property indicator_separate_window

#property indicator_color3 Red

#property indicator_width1 3

#property indicator_buffers 3

#property indicator_color1 LawnGreen

#property indicator_color2 Red

#include // here the mom() function is incl.

double buffer[];

double mom1[];

int init() { SetIndexBuffer(0,buffer); SetIndexBuffer(1,mom1);return(0); }

int deinit() { return(0); }

int start()

{

int counted_bars=IndicatorCounted();

if(counted_bars<0) return(-1);

if(counted_bars>0) counted_bars--;

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

for(int i = limit; i>=0; i--)

{

mom1 = iCustom(NULL,0,"myIndi",0,i);

buffer = (

Mom(mom1,10,Bars,i); //doesn't work - no value in indi

// Mom(mom1,10,Bars,i); //error: parameter conversation not allowed

// mom1 // this works, but no subfunction incl.

);

}

return(0);

}

//normaly in mqh incl.

double Mom(const double& series[], int period, int totcount, int index)

{

if (totcount<1 || period<1) return (EMPTY_VALUE);

if (indextotcount-1) return (EMPTY_VALUE);

return (series-series);

}

);

L'errore di conversazione è ancora lì...

Grazie per il tuo aiuto!

Ciao, AT

Ecco una versione senza errori di compilazione: _test.mq4

Non ho idea di cosa sia "myIndi" quindi non ho potuto testare se iCustom() restituisce valori dal tuo indicatore "myIndi"

File:
copiler.gif  52 kb
_test.mq4  2 kb
 

Ciao Mladen!

Il mio indi è una normale uscita dal JMA.mq4 / JMA Indi.

Potrebbe anche essere un'uscita MA o qualsiasi altra cosa. "myIndi" non è un indi speciale.

E la chiamata dell'indi funziona in una normale finestra indi...

Il mio codice assomiglia a questo:

#property indicator_separate_window

#property indicator_color3 Red

#property indicator_width1 3

#property indicator_buffers 3

#property indicator_color1 LawnGreen

#property indicator_color2 Red

#include // here the mom() function is incl.

double buffer[];

double mom1[];

int init() { SetIndexBuffer(0,buffer); SetIndexBuffer(1,mom1);return(0); }

int deinit() { return(0); }

int start()

{

int counted_bars=IndicatorCounted();

if(counted_bars<0) return(-1);

if(counted_bars>0) counted_bars--;

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

for(int i = limit; i>=0; i--)

{

mom1 = iCustom(NULL,0,"JMA",0,i); //normal JMA / MA output

// I get this out put, and it's ok, but the second output (buffer) is zero...

buffer = (

Mom(mom1,10,Bars,i); //no compiler error, but doesn't work - no value in indi window

// Mom(mom1,10,Bars,i); //error: parameter conversation not allowed

// mom1 // this works, but it's the value i want

);

}

return(0);

}

//normaly in mqh incl.

double Mom(const double& series[], int period, int totcount, int index)

{

if (totcount<1 || period<1) return (EMPTY_VALUE);

if (indextotcount-1) return (EMPTY_VALUE);

return (series-series);

}

);

Non ottengo il fallimento che ho fatto...

Grazie mille per il vostro aiuto!

Ciao, AT

 

Ciao Mladen!

Quando scrivo o cambio così...

ottengo anche l'errore di conversazione... qualche idea...?

Grazie mille!

Ciao, AT

#property indicator_separate_window

#property indicator_color3 Red

#property indicator_width1 3

#property indicator_buffers 3

#property indicator_color1 LawnGreen

#property indicator_color2 Red

//#include // here the mom() function is incl.

double buffer[];

double mom1[];

int init() { SetIndexBuffer(0,buffer); SetIndexBuffer(1,mom1);return(0); }

//normaly in mqh incl.

double Mom(const double& series[], int period, int totcount, int index)

{

if (totcount<1 || period<1) return (EMPTY_VALUE);

if (indextotcount-1) return (EMPTY_VALUE);

return (series-series);

}

int deinit() { return(0); }

int start()

{

int counted_bars=IndicatorCounted();

if(counted_bars<0) return(-1);

if(counted_bars>0) counted_bars--;

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

for(int i = limit; i>=0; i--)

{

mom1 = iMA(Symbol(),Period(),13,8,MODE_SMMA,PRICE_MEDIAN,i); //normal JMA / MA output

// I get this out put, and it's ok, but the second output (buffer) is zero...

buffer = (

// Mom(mom1,10,Bars,i) //no compiler error, but doesn't work - no value in indi window

Mom(mom1,10,Bars,i) //error: parameter conversation not allowed

// mom1 // this works, but it is NOT the value i want

);

}

return(0);

}

 
at120:
Ciao Mladen!

Quando lo scrivo o lo cambio così...

ottengo anche l'errore di conversazione... qualche idea...?

Grazie mille!

Ciao, AT

#property indicator_separate_window

#property indicator_color3 Red

#property indicator_width1 3

#property indicator_buffers 3

#property indicator_color1 LawnGreen

#property indicator_color2 Red

//#include // here the mom() function is incl.

double buffer[];

double mom1[];

int init() { SetIndexBuffer(0,buffer); SetIndexBuffer(1,mom1);return(0); }

//normaly in mqh incl.

double Mom(const double& series[], int period, int totcount, int index)

{

if (totcount<1 || period<1) return (EMPTY_VALUE);

if (indextotcount-1) return (EMPTY_VALUE);

return (series-series);

}

int deinit() { return(0); }

int start()

{

int counted_bars=IndicatorCounted();

if(counted_bars<0) return(-1);

if(counted_bars>0) counted_bars--;

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

for(int i = limit; i>=0; i--)

{

mom1 = iMA(Symbol(),Period(),13,8,MODE_SMMA,PRICE_MEDIAN,i); //normal JMA / MA output

// I get this out put, and it's ok, but the second output (buffer) is zero...

buffer = (

// Mom(mom1,10,Bars,i) //no compiler error, but doesn't work - no value in indi window

Mom(mom1,10,Bars,i) //error: parameter conversation not allowed

// mom1 // this works, but it is NOT the value i want

);

}

return(0);

}

a120

Non puoi usare un elemento che evolve in doppio quando il parametro previsto dovrebbe essere const double[]. Invece di usare "mom1" usa "mom1"

 

Ciao Mladen!

Grazie per la risposta, quindi la mia domanda ora è, come "convertire" il mio doppio nella mia serie const double[]

perché quando uso solo il mom1 ottengo uno "0" come output...

Quindi come posso fare in modo che il mom1 "assomigli", ad esempio, al Close. C'è qualche codice di esempio per questo?

Grazie mille e ciao, AT

 
at120:
Ciao Mladen!

Grazie per la risposta, quindi la mia domanda ora è, come "convertire" il mio doppio nella mia serie const double[]

perché quando uso solo il mom1 ottengo uno "0" come output...

Quindi come posso fare in modo che il mom1 "assomigli", ad esempio, al Close. C'è qualche codice di esempio per questo?

Grazie mille e ciao, AT

Non è necessario "convertire" nulla. Nel momento in cui la parte "" viene rimossa "diventa" un parametro corretto

Ecco come appare sul grafico:

Ed ecco il codice: _test_2.mq4

File:
_test_2.mq4  1 kb
test.gif  64 kb
 

Ciao Mladen!

Ora funziona per me, sembra che ho dimenticato l'IndicatorBuffers(2);

Ora sembra che ottengo il valore giusto!

Grazie mille per il tuo aiuto!

Ciao, AT

 

Quali array devono essere dichiarati come const nei parametri delle funzioni?