Wie programmiert man? - Seite 338

 
at120:
Hallo Malden!

Danke für deine Unterstützung! ;-)

Sogar, wenn ich den Code so schreibe, wie du mir gesagt hast:

(Ich denke schon...)

#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);

}

);

Also wenn ich die "Erste" Version verwende, bekomme ich keinen Wert...

Wenn ich die zweite Version verwende, bekomme ich den Fehler... hmmm.

Nur der Aufruf von mom1 funktioniert... aber das ist nicht der richtige Wert...

Vielen Dank für Ihre Hilfe!

Tschüss, AT

Ersetzen Sie den "benutzerdefinierten Namen" durch den Namen Ihres Indikators (bestehender Indikator), fügen Sie Parameter zum iCustom()-Aufruf hinzu, und es wird funktionieren. Der Name wurde dort nur als Beispiel eingefügt.

Außerdem haben Sie die Anzahl der Puffer nicht definiert (weder mit #property indicator_buffers noch mit der Funktion IndicatorBuffers()). Der Indikator "denkt", dass es 0 Puffer gibt und wird diese Puffer nie auf die tatsächliche Größe initialisieren. Definieren Sie die Anzahl der Puffer, die Sie verwenden wollen

_______________________

 

Hallo Mladen!

Danke für deine Info... Ich habe das schon gemacht... Der Code sieht so aus:

#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);

}

);

Fehler der Konversation ist immer noch da...

Vielen Dank für deine Hilfe!

Tschüss, AT

 
at120:
Hallo Mladen!

Danke für die Info... Ich habe das schon gemacht... Der Code sieht so aus:

#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);

}

);

Fehler der Konversation ist immer noch da...

Vielen Dank für Ihre Hilfe!

Tschüss, AT

Hier ist eine Version mit KEINEN Compiler-Fehlern : _test.mq4

Da ich keine Ahnung habe, was "myIndi" ist, konnte ich nicht testen, ob iCustom() Werte von Ihrem "myIndi"-Indikator zurückgibt

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

Hallo Mladen!

Mein Indi ist eine normale Ausgabe des JMA.mq4 / JMA Indi.

Es könnte auch ein MA-Ausgang oder etwas anderes sein. "myIndi" ist kein spezielles Indi.

Und der Aufruf der Indi funktioniert im normalen Indi-Fenster...

Mein Code sieht wie folgt aus:

#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);

}

);

Ich bekomme den Fehler nicht, den ich gemacht habe...

Vielen Dank für Ihre Hilfe!!

Tschüss, AT

 

Hallo Mladen!

Wenn ich es so schreibe oder ändere...

bekomme ich auch den Konversationsfehler... irgendeine Idee...?

Vielen Dank schon mal!

Tschüss, 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:
Hallo Mladen!

Wenn ich es so schreibe oder ändere...

bekomme ich auch den Konversationsfehler... irgendwelche Ideen?

Vielen Dank!

Tschüss, 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);

}

bei120

Sie können kein Element verwenden, das sich zu double entwickelt, wenn der erwartete Parameter const double[] sein soll. Anstatt "mom1" verwenden Sie "mom1"

 

Hallo Mladen!

Danke für die Antwort, also meine Frage ist jetzt, wie ich mein double in mein const double series[]

denn wenn ich nur mom1 verwende, bekomme ich eine "0" als Ausgabe...

Wie kann ich also mom1 so umwandeln, dass es z.B. wie der Close aussieht. Gibt es einen Beispielcode dafür?

Vielen Dank und auf Wiedersehen, AT

 
at120:
Hallo Mladen!

Vielen Dank für die Antwort, so meine Frage ist jetzt, wie zu "konvertieren" meine double zu meinem const double series[]

denn wenn ich nur mom1 verwende, bekomme ich eine "0" als Ausgabe...

Wie kann ich also mom1 so umwandeln, dass es z.B. wie der Close aussieht. Gibt es dafür einen Beispielcode?

Vielen Dank und auf Wiedersehen, AT

Sie brauchen nichts zu "konvertieren". In dem Moment, in dem der ""-Teil entfernt wird, wird er zum richtigen Parameter.

So sieht es im Chart aus:

Und hier ist der Code : _test_2.mq4

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

Hallo Mladen!

Jetzt funktioniert es für mich, scheint, dass ich die IndicatorBuffers(2) vergessen habe;

Jetzt scheint es, dass ich den richtigen Wert bekomme!

Vielen Dank für deine Hilfe!!

Tschüss, AT

 

Welche Arrays müssen in Funktionsparametern als const deklariert werden?

Grund der Beschwerde: