Hallo!
ich möchte in meinem .mq4-Programm eine oft genutzte Funktion in eine externe Datei auslagern. Sagen wir mal beispielhaft (und dass es übersichtlich bleibt) die Berechnung einer EMA mit Timeframe 1 und Periode 20.
Nun schrieb ich eine .mqh-Datei mit Namen "EMAS" :
PHP-Code:
#property strict
double EMA1P20,EMA1P50;
//+------------------------------------------------------------------+
//| Die ausgelagerte .mqh-Datei "EMAS" |
//+------------------------------------------------------------------+
void EMAS()
{
EMA1P20=NormalizeDouble(iMA(NULL,1,20,0,1,0,0),5);
EMA1P50=NormalizeDouble(iMA(NULL,1,50,0,1,0,0),5);
}
Meine .mq4-Datei (Also das Hauptprogramm) sieht so aus:
PHP-Code:
#property strict
enum ENUM_En
{
EntryEMA1P20=20,EntryEMA1P50=50
};
input ENUM_En Entry=20;
double EMA1P20,EMA1P50;
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
#include <EMAS.mqh>
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
EMAS();
Comment(" EMA1P20= ",EMA1P20," EMA1P50= ",EMA1P50);
}
In der .mqh-Datei "EMAS" bekomme ich keine Fehlermeldung.
In der Hauptdatei jedoch umso mehr:
declaration of 'EMA1P20' hides global variable (Bezieht sich auf die .mqh-Datei)
declaration of 'EMA1P50' hides global variable (Bezieht sich auf die .mqh-Datei)
'EMAS' - function declarations are allowed on global, namespace or class scope only
variable 'EMA1P20' not used (Bezieht sich auf die .mqh-Datei)
variable 'EMA1P50' not used (Bezieht sich auf die .mqh-Datei)
Was mache ich denn hier falsch????