01.10.15
|
Neues Mitglied
|
|
Registriert seit: May 2015
Beiträge: 28
|
|
mql schrott oder mein pc schrott?
Hallo allerseits,
mein Problem die eingespeicherten Daten sind nicht korrekt, bei der Ausgabe durch einen anderen EA sind die Daten schlichtwig falsch.
Ich bin echt am rätseln warum das so ist.
Kann jmd den folgenden Code mal ausprobieren?
Falls noch ein Ausgabe EA benötigt wird, stelle ich einen bereit.
Im folgenden Code ein Beispiel einer Einspeicherung:
Code:
#property copyright "Copyright 2015"
#property link "https://www.mql5.com"
#property version "1.00"
//--- input parameters
input string InpFileName="save.bin";
input string InpDirectoryName="Saves";
#include <stdlib.mqh>
#include <WinUser32.mqh>
datetime BarTime1 = 0;
//+------------------------------------------------------------------+
//| Structure for storing price data |
//+------------------------------------------------------------------+
struct prices
{
double Preis1;
double Preis1_High;
double Preis1_Low;
};
//--- global variables
int count=0,count2=0,count3=0,ExpectedTime1=0,ccM1=0,ccM5=0;
int size=1,bidask;int zz;
double cc;
string path=InpDirectoryName+"//"+InpFileName; double Werte[99999];
prices arr[];
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//--- allocate memory for the array
ArrayResize(arr,size);
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
//--- write the remaining count strings if count<n
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
// M1_bidask++;
// M5_bidask++;
// M15_bidasl++;
// MarktWerte[bidask]=Bid+Ask/2
zz=zz+1;
Werte[zz]=(Bid+Ask)/2;
Save();
if(count==size)
{
WriteData(size);
count=0;
}
}
//+------------------------------------------------------------------+
//| Write n elements of the array to file |
//+------------------------------------------------------------------+
void WriteData(const int n)
{
//--- open the file
ResetLastError();
int handle=FileOpen(path,FILE_READ|FILE_WRITE|FILE_BIN);
if(handle!=INVALID_HANDLE)
{
//--- write array data to the end of the file
FileSeek(handle,0,SEEK_END);
FileWriteArray(handle,arr,0,n);
//--- close the file
FileClose(handle);
}
else
Print("Failed to open the file, error ",GetLastError());
}
void Save(){
// Eine Minute Vorbei
int datetime800 = TimeLocal();
if (ExpectedTime1 == 0 || datetime800 > ExpectedTime1 + 60)
{
ExpectedTime1 = datetime800 + 60 * 1; // reset paused time
}
if (datetime800 >= ExpectedTime1 && datetime800 < ExpectedTime1 + 60)
{
ExpectedTime1 = datetime800 + 60 * 1;
// bool qw=OrderSend(Symbol(),OP_BUY,0.01,Ask,20,0,0,"",0,0,Red);
// arr[count].Tag=Day;
arr[count].Preis1=(Bid+Ask)/2;
double H=High[0],L=Low[0];
arr[count].Preis1_Low=L;
arr[count].Preis1_High=Werte[ArrayMaximum(Werte,WHOLE_ARRAY,0)];
zz=0;
for (int i=0;i<500;i++){Werte[i]=0;}
arr[count].Preis1_Low=L;
ccM1=ccM1+1;
Comment(count);
count=count+1;
}
}
|