[ARCHIV!] Alle Fragen von Anfängern, um das Forum nicht zu überladen. Fachleute, gehen Sie nicht vorbei. Ohne dich kann ich nirgendwo hingehen - 4. - Seite 449

 
sss2019:

Ich verstehe, dass ich nicht spekulieren möchte, aber können Sie mir wenigstens einen Hinweis geben, wenn das Problem für Sie klar ist?

Gib mir den ganzen Code
 
ilunga:

Nein, es bedeutet nur, dass die Daten mit einem Teil der Geschichte übereinstimmen.

Sie könnten sie zum Beispiel manuell eingeben. Oder aus einer Textdatei geschrieben. Oder Sie könnten sie aus einer Berechnung erhalten haben.


Denn selbst bei der Eingabe einiger bedingter Daten "1,25 1,16 1,73 1,35" können wir die Geschichte für eine Währung vor vielen Jahren erhalten. Das bedeutet aber nicht, dass wir eine Zeitreihe eingerichtet haben

Das ursprüngliche Skript wurde ein wenig überarbeitet:

1. Ich habe nur die 5 letzten Eröffnungspreise in das benutzerdefinierte Array kopiert.

2. Berechnet das erhaltene benutzerdefinierte Array durch alle 5 kopierten Eröffnungspreise.

/+------------------------------------------------------------------------------------------+
//|                                                                ArrayGetAsSeries_плюс.mq4 |
//+------------------------------------------------------------------------------------------+
//|                         script program start function                                    |
//+------------------------------------------------------------------------------------------+
//------------------------------------ НАЧАЛО START -------------------------------------- 1 -
int start()                                           //функция start
  {                                                   //начало start
   double Timestart=GetTickCount();                   //переменная, с помощью которой вычисляется время (в милисекундах) начала выполнения эксперта 
   double array1[];                                   //объявляем массив-приемник (массив, куда будут скопированы данные)
   int element=ArrayCopy(array1,Open,0,0,5);          //копируем данные по максимальным ценам в пользовательский массив (начиная с 1-о бара, а не с нулевого)
   int size=ArraySize(array1);                        //устанавливаем количество элементов массива array1
//----------------------------------------------------------------------------------------- 2 -
   Comment("\nФункция ArrayCopy(array1[],Open,0,0,WHOLE_ARRAY) вернула: ",element,
           "\nФункция ArraySize(array1) вернула: ",size,
           "\nЗначение цены открытия бара №0 равно ",array1[0],"; Время цены открытия бара №0: ",TimeToStr(iTime(NULL,0,0),TIME_DATE|TIME_MINUTES),
           "\nЗначение цены открытия бара №1 равно ",array1[1],"; Время цены открытия бара №1: ",TimeToStr(iTime(NULL,0,1),TIME_DATE|TIME_MINUTES),
           "\nЗначение цены открытия бара №2 равно ",array1[2],"; Время цены открытия бара №2: ",TimeToStr(iTime(NULL,0,2),TIME_DATE|TIME_MINUTES),
           "\nЗначение цены открытия бара №3 равно ",array1[3],"; Время цены открытия бара №3: ",TimeToStr(iTime(NULL,0,3),TIME_DATE|TIME_MINUTES),
           "\nЗначение цены открытия бара №4 равно ",array1[4],"; Время цены открытия бара №4: ",TimeToStr(iTime(NULL,0,4),TIME_DATE|TIME_MINUTES),
           "\nФункция ArrayGetAsSeries(array1) вернула: ",ArrayGetAsSeries(array1),
           "\nСкрипт выполнялся всего ",GetTickCount()-Timestart," миллисекунд, из них: ",MathFloor((GetTickCount()-Timestart)/1000),
           " секунд ",((GetTickCount()-Timestart)/1000-MathFloor((GetTickCount()-Timestart)/1000))*1000," миллисекунд");//печать 
           //сообщения на экран
//----------------------------------------------------------------------------------------- 3 -
   return(0);                                                             //выход из start
  }                                                                       //конец start
//-------------------------------------- КОНЕЦ START -------------------------------------- 4 -

Hier ist, was ich bekommen habe:


Wie Sie aus der Abbildung ersehen können, sind die Eröffnungskurse in umgekehrter Reihenfolge indiziert (wie aus der ANZAHL der Eröffnungskurse (in aufsteigender Reihenfolge) und der ZEIT der Eröffnungskurse (in absteigender Reihenfolge) hervorgeht), d.h. das Array ist als Array-Zeitreihe organisiert.

Aber die Funktion ArrayGetAsSeries gibt trotzdem 0 (false) zurück, was bedeutet, dass das Benutzer-Array NICHT als Array-Zeitreihe organisiert ist.

Ich bitte um Klarheit

Frage: Wie lässt sich dies erklären?

P.S. Danke für die Beantwortung meiner Fragen

 
7777877:

Das ursprüngliche Skript wurde ein wenig überarbeitet:

1. Ich habe nur die letzten 5 Eröffnungspreise in ein benutzerdefiniertes Array kopiert.

2. Ras verarbeitete das resultierende benutzerdefinierte Array nach allen 5 kopierten Eröffnungspreisen.

Hier ist, was ich bekommen habe:

Wie Sie aus der Abbildung ersehen können, sind die Eröffnungskurse in umgekehrter Reihenfolge indiziert (wie aus der ANZAHL der Eröffnungskurse (in aufsteigender Reihenfolge) und der ZEIT der Eröffnungskurse (in absteigender Reihenfolge) hervorgeht), d.h. das Array ist als Array-Zeitreihe organisiert.

Aber die Funktion ArrayGetAsSeries gibt trotzdem 0 (false) zurück, was bedeutet, dass das Benutzer-Array NICHT als Array-Zeitreihe organisiert ist.

Bitte klären

Frage: Wie ist das zu erklären?

P.S. Ich danke Ihnen für die Beantwortung meiner Fragen.

Haben Sie versucht, die Funktionen

boolArraySetAsSeries(void array[], bool set)
Legt die Indizierungsrichtung eines Arrays fest. Eingesetzter TRUE setzt die Indizierungsrichtung in umgekehrter Reihenfolge, d.h. das letzte Element hat den Index Null. Ein Wert von FALSE legt die normale Indizierungsrichtung fest. Die Funktion gibt den vorherigen Zustand zurück.
Parameter:
array[]-Numerisches Array zum Einstellen.
einstellen.-Die Richtung, in der das Array indiziert wird.
 
Vinin:

Haben Sie die folgenden Funktionen ausprobiert

boolArraySetAsSeries(void array[], bool set)
Legt die Indizierungsrichtung des Arrays fest. EinWert vonset TRUE setzt die Indizierungsrichtung in umgekehrter Reihenfolge, d.h. das letzte Element hat einen Nullindex. Ein Wert von FALSE legt die normale Indizierungsrichtung fest. Die Funktion gibt den vorherigen Zustand zurück.
Parameter:
array[]-Numerisches Array zum Einstellen.
einstellen.-Die Richtung, in der das Array indiziert wird.

Mein Ziel in diesem Stadium ist es, zu verstehen, wie eine bestimmte Funktion funktioniert, und in diesem speziellen Fall, wie die Funktion ArrayGetAsSeries funktioniert. Ich verstehe, dass ich ArraySetAsSeries Funktion mit Parameter set=true, die zwangsweise setzt Indizierung, wie in Array-Zeitreihen verwenden können. Aber ich möchte verstehen, warum in meinem Fall Funktion ArrayGetAsSeries 0 zurückgegeben, trotz Array sieht aus wie Zeitreihen (d.h. indiziert wie Zeitreihen)
 
Sepulca:


i_maTF == Zeitraum() ??????

i_maPeriod nimmt einen vernünftigen Wert an???

Vielleicht ist etwas mit i_maShiftByPrice nicht in Ordnung?

Es ist schwer, das genauer zu sagen.

Die von ihm ausgegebenen Informationen sind nicht korrekt. Hier ist der vollständige Code:

#property copyright "hoz"
#property link      ""
#include <stderror.mqh>
#include <stdlib.mqh>

extern string  h1 = "основные параметры машки";
extern int     i_maTF = 0;
extern int     i_maPeriod = 50;
extern int     i_maShiftByPrice = 0;
extern int     i_maMethod = 0;
extern int     i_maPrice = 0;
extern int     i_shiftBarsBack1 = 1;                        // Первое значение shift
extern int     i_shiftBarsBack2 = 49;                       // Второе значение shift
extern string  h2 = "===============================";

string         h3 = "Значения цены и времени в точках А и В гипотенузы";
double         price1,                                      // Цена в точке А
               price2,                                      // Цена в точке В
               time1,                                       // Время в точке А
               time2,                                       // Время в точке В
string         h4 = "Переменые массивов цены и времени в точках А и В гипотенузы";
double         varsPrice1[100],                             // Буфер для цены в точке А
               varsPrice2[100],                             // Буфер для цены в точке В
               varsTime1[100],                              // Буфер для времени в точке А
               varsTime2[100],                              // Буфер для времени в точке В

#property indicator_separate_window
#property indicator_buffers 5
#property indicator_color1 Red
//+------------------------------------------------------------------+
//|               Функция инициализации индикатора                   |
//+------------------------------------------------------------------+
int init()
  {
   IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS));
   SetIndexBuffer(0,varsAngle);                          // Связываем массив значений угла с буфером
   SetIndexStyle(0,DRAW_HISTOGRAM); 
   
// -------------- блок инициализации закончен ----------------------
   return(0);
  }
//+------------------------------------------------------------------+
//|              Функция деинициализации индикатора                  |
//+------------------------------------------------------------------+
int deinit()
  {

// -------------- блок деинициализации закончен ----------------------
   return(0);
  }
//+------------------------------------------------------------------+
//|                  Функция итерации эксперта                       |
//+------------------------------------------------------------------+
int start()
  {
   int i, countedBars = IndicatorCounted();
   int limit = Bars - countedBars;
   if (limit > 100) limit = 100;
        
   for(i = limit - 1;i > 0;i--)
    {
      price1 = iMA(Symbol(),i_maTF,i_maPeriod,i_maShiftByPrice,i_maMethod,i_maPrice,i_shiftBarsBack1+i);       // Цена в точке А
      price2 = iMA(Symbol(),i_maTF,i_maPeriod,i_maShiftByPrice,i_maMethod,i_maPrice,i_shiftBarsBack2+i);       // Цена в точке В
      time1 = iTime(Symbol(),Period(),i_shiftBarsBack1 + i - 1);                                               // Время в точке А
      time2 = iTime(Symbol(),Period(),i_shiftBarsBack2 + i - 1);                                               // Время в точке В
    
      Print("i = ", i," i_maTF = ", i_maTF, " i_maPeriod = ", i_maPeriod," i_maShiftByPrice ", i_maShiftByPrice, " i_maMethod = ", i_maMethod," i_maPrice = ", i_maPrice, " i_shiftBarsBack1 = ", i_shiftBarsBack1);
      string error = GetMyLastError2();
      
  //    Print("vars", DoubleToStr(price1,5));
    //  Print("vars", DoubleToStr(varsPrice1[i],5));
      
      varsPrice1[i] = price1;                                                                        // Массив цен в точке А
      varsPrice2[i] = price2;                                                                        // Массив цен в точке В
      varsTime1[i] = time1;                                                                          // Массив времени в точке А
      varsTime2[i] = time2;                                                                          // Массив времени в точке В
    
   
  //    Print("vars", DoubleToStr(varsPrice1[i],5));

            
      double d = (MathAbs(varsTime1[i] - varsTime2[i]))*1.0;
      double h = (MathAbs(varsPrice1[i] - varsPrice2[i]));
      
  //    Print("d = ", d, " h = ", h);
      
      double angle = h/d;
      varsAngle[i] = angle;
    }
   return(0);
  }
  
string GetMyLastError2()
  {
    int err = GetLastError();
    string serr = ErrorDescription(err);
    return(serr);
  }

/* //+------------------------------------------------------------------+
//|                  Функция рассчёта тангенса угла                  |
//+------------------------------------------------------------------+
double TanA(double d, double h)
 {
   double angle = h/d;
   
  return(0);
 }
// -------------- блок деинициализации закончен ---------------------- */

Das Protokoll des Expert Advisors zeigt dies an:







14:50:36 2010.08.11 12:30  AngleByTg GBPUSD,M15: i = 25 i_maTF = 50 i_maPeriod = 0 i_maShiftByPrice 0 i_maMethod = 0 i_maPrice = 2 i_shiftBarsBack1 = 7
14:50:36 2010.08.11 12:30  AngleByTg GBPUSD,M15: i = 24 i_maTF = 50 i_maPeriod = 0 i_maShiftByPrice 0 i_maMethod = 0 i_maPrice = 2 i_shiftBarsBack1 = 7
14:50:36 2010.08.11 12:30  AngleByTg GBPUSD,M15: i = 23 i_maTF = 50 i_maPeriod = 0 i_maShiftByPrice 0 i_maMethod = 0 i_maPrice = 2 i_shiftBarsBack1 = 7
14:50:36 2010.08.11 12:30  AngleByTg GBPUSD,M15: i = 22 i_maTF = 50 i_maPeriod = 0 i_maShiftByPrice 0 i_maMethod = 0 i_maPrice = 2 i_shiftBarsBack1 = 7
14:50:36 2010.08.11 12:30  AngleByTg GBPUSD,M15: i = 21 i_maTF = 50 i_maPeriod = 0 i_maShiftByPrice 0 i_maMethod = 0 i_maPrice = 2 i_shiftBarsBack1 = 7
14:50:36 2010.08.11 12:30  AngleByTg GBPUSD,M15: i = 20 i_maTF = 50 i_maPeriod = 0 i_maShiftByPrice 0 i_maMethod = 0 i_maPrice = 2 i_shiftBarsBack1 = 7
14:50:36 2010.08.11 12:30  AngleByTg GBPUSD,M15: i = 19 i_maTF = 50 i_maPeriod = 0 i_maShiftByPrice 0 i_maMethod = 0 i_maPrice = 2 i_shiftBarsBack1 = 7
14:50:36 2010.08.11 12:30  AngleByTg GBPUSD,M15: i = 18 i_maTF = 50 i_maPeriod = 0 i_maShiftByPrice 0 i_maMethod = 0 i_maPrice = 2 i_shiftBarsBack1 = 7
14:50:36 2010.08.11 12:30  AngleByTg GBPUSD,M15: i = 17 i_maTF = 50 i_maPeriod = 0 i_maShiftByPrice 0 i_maMethod = 0 i_maPrice = 2 i_shiftBarsBack1 = 7
14:50:36 2010.08.11 12:30  AngleByTg GBPUSD,M15: i = 16 i_maTF = 50 i_maPeriod = 0 i_maShiftByPrice 0 i_maMethod = 0 i_maPrice = 2 i_shiftBarsBack1 = 7
14:50:36 2010.08.11 12:30  AngleByTg GBPUSD,M15: i = 15 i_maTF = 50 i_maPeriod = 0 i_maShiftByPrice 0 i_maMethod = 0 i_maPrice = 2 i_shiftBarsBack1 = 7
14:50:36 2010.08.11 12:30  AngleByTg GBPUSD,M15: i = 14 i_maTF = 50 i_maPeriod = 0 i_maShiftByPrice 0 i_maMethod = 0 i_maPrice = 2 i_shiftBarsBack1 = 7
14:50:36 2010.08.11 12:30  AngleByTg GBPUSD,M15: i = 13 i_maTF = 50 i_maPeriod = 0 i_maShiftByPrice 0 i_maMethod = 0 i_maPrice = 2 i_shiftBarsBack1 = 7
14:50:36 2010.08.11 12:30  AngleByTg GBPUSD,M15: i = 12 i_maTF = 50 i_maPeriod = 0 i_maShiftByPrice 0 i_maMethod = 0 i_maPrice = 2 i_shiftBarsBack1 = 7
14:50:36 2010.08.11 12:30  AngleByTg GBPUSD,M15: i = 11 i_maTF = 50 i_maPeriod = 0 i_maShiftByPrice 0 i_maMethod = 0 i_maPrice = 2 i_shiftBarsBack1 = 7
14:50:36 2010.08.11 12:30  AngleByTg GBPUSD,M15: i = 10 i_maTF = 50 i_maPeriod = 0 i_maShiftByPrice 0 i_maMethod = 0 i_maPrice = 2 i_shiftBarsBack1 = 7
14:50:36 2010.08.11 12:30  AngleByTg GBPUSD,M15: i = 9 i_maTF = 50 i_maPeriod = 0 i_maShiftByPrice 0 i_maMethod = 0 i_maPrice = 2 i_shiftBarsBack1 = 7
14:50:36 2010.08.11 12:30  AngleByTg GBPUSD,M15: i = 8 i_maTF = 50 i_maPeriod = 0 i_maShiftByPrice 0 i_maMethod = 0 i_maPrice = 2 i_shiftBarsBack1 = 7
14:50:36 2010.08.11 12:30  AngleByTg GBPUSD,M15: i = 7 i_maTF = 50 i_maPeriod = 0 i_maShiftByPrice 0 i_maMethod = 0 i_maPrice = 2 i_shiftBarsBack1 = 7
14:50:36 2010.08.11 12:30  AngleByTg GBPUSD,M15: i = 6 i_maTF = 50 i_maPeriod = 0 i_maShiftByPrice 0 i_maMethod = 0 i_maPrice = 2 i_shiftBarsBack1 = 7
14:50:36 2010.08.11 12:30  AngleByTg GBPUSD,M15: i = 5 i_maTF = 50 i_maPeriod = 0 i_maShiftByPrice 0 i_maMethod = 0 i_maPrice = 2 i_shiftBarsBack1 = 7
14:50:36 2010.08.11 12:30  AngleByTg GBPUSD,M15: i = 4 i_maTF = 50 i_maPeriod = 0 i_maShiftByPrice 0 i_maMethod = 0 i_maPrice = 2 i_shiftBarsBack1 = 7
14:50:36 2010.08.11 12:30  AngleByTg GBPUSD,M15: i = 3 i_maTF = 50 i_maPeriod = 0 i_maShiftByPrice 0 i_maMethod = 0 i_maPrice = 2 i_shiftBarsBack1 = 7
14:50:36 2010.08.11 12:30  AngleByTg GBPUSD,M15: i = 2 i_maTF = 50 i_maPeriod = 0 i_maShiftByPrice 0 i_maMethod = 0 i_maPrice = 2 i_shiftBarsBack1 = 7
14:50:36 2010.08.11 12:30  AngleByTg GBPUSD,M15: i = 1 i_maTF = 50 i_maPeriod = 0 i_maShiftByPrice 0 i_maMethod = 0 i_maPrice = 2 i_shiftBarsBack1 = 7

Wie Sie sehen können, sind die Variablen i_maTF, i_maPeriod und i_maPrice nicht das, was ich initialisiert habe. Was ist los?

 
hoz:

Gibt die falschen Informationen aus. Hier ist der vollständige Code:

Das Expertenprotokoll zeigt dies:

Wie Sie sehen können, sind die Variablen i_maTF, i_maPeriod und i_maPrice nicht dieselben, die ich initialisiert habe. Was ist los?

Ich frage mich, wie Sie es geschafft haben, etwas in das Protokoll zu bekommen, wenn der Code, den Sie eingereicht haben, nicht kompiliert werden kann?

Ah, wenn Sie es kompilieren, wird es keine Probleme geben.

Dateien:
hoz_1.mq4  4 kb
 
TarasBY:

Ich frage mich, wie Sie es geschafft haben, irgendetwas in das Protokoll zu bekommen, wenn der von Ihnen präsentierte Code nicht kompiliert werden kann?

Ah, wenn Sie es kompilieren, werden Sie keine Merkwürdigkeiten bekommen.

Ich kompiliere immer normal.

Ich habe den Code um zusätzliche Drucker und Variablen bereinigt, um niemanden zu verwirren. Aber ich habe sie unten nicht entfernt, so dass es nicht kompiliert werden konnte. Hier ist der vollständige Code, der sich kompilieren lässt:

//+------------------------------------------------------------------+
//|                                                    AngleByTg.mq4 |
//|                                                              hoz |
//|                                                                  |
//+------------------------------------------------------------------+
#property copyright "hoz"
#property link      ""
#include <stderror.mqh>
#include <stdlib.mqh>

extern string  h1 = "основные параметры машки";
extern int     i_maTF = 0;
extern int     i_maPeriod = 50;
extern int     i_maShiftByPrice = 0;
extern int     i_maMethod = 0;
extern int     i_maPrice = 0;
extern int     i_shiftBarsBack1 = 1;                        // Первое значение shift
extern int     i_shiftBarsBack2 = 49;                       // Второе значение shift
extern string  h2 = "===============================";

string         h3 = "Значения цены и времени в точках А и В гипотенузы";
double         price1,                                      // Цена в точке А
               price2,                                      // Цена в точке В
               time1,                                       // Время в точке А
               time2,                                       // Время в точке В
               angle;                                       // Значение возвращаемой тангенсом
string         h4 = "Переменые массивов цены и времени в точках А и В гипотенузы";
double         varsPrice1[100],                             // Буфер для цены в точке А
               varsPrice2[100],                             // Буфер для цены в точке В
               varsTime1[100],                              // Буфер для времени в точке А
               varsTime2[100],                              // Буфер для времени в точке В
               varsAngle[100];                              // Буфер для хранения значение угла

#property indicator_separate_window
#property indicator_buffers 5
#property indicator_color1 Red
//#property indicator_minimum -90
//#property indicator_maximum 90
//+------------------------------------------------------------------+
//|               Функция инициализации индикатора                   |
//+------------------------------------------------------------------+
int init()
  {
   IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS));
   SetIndexBuffer(0,varsAngle);                          // Связываем массив значений угла с буфером
   SetIndexStyle(0,DRAW_HISTOGRAM); 
   
// -------------- блок инициализации закончен ----------------------
   return(0);
  }
//+------------------------------------------------------------------+
//|              Функция деинициализации индикатора                  |
//+------------------------------------------------------------------+
int deinit()
  {

// -------------- блок деинициализации закончен ----------------------
   return(0);
  }
//+------------------------------------------------------------------+
//|                  Функция итерации эксперта                       |
//+------------------------------------------------------------------+
int start()
  {
 //   if (!isNewBar())
 //   return(0);
    
   int i, countedBars = IndicatorCounted();
   int limit = Bars - countedBars;
   if (limit > 100) limit = 100;
        
   for(i = limit - 1;i > 0;i--)
    {
      price1 = iMA(Symbol(),i_maTF,i_maPeriod,i_maShiftByPrice,i_maMethod,i_maPrice,i_shiftBarsBack1+i);       // Цена в точке А
      price2 = iMA(Symbol(),i_maTF,i_maPeriod,i_maShiftByPrice,i_maMethod,i_maPrice,i_shiftBarsBack2+i);       // Цена в точке В
      time1 = iTime(Symbol(),Period(),i_shiftBarsBack1 + i - 1);                                               // Время в точке А
      time2 = iTime(Symbol(),Period(),i_shiftBarsBack2 + i - 1);                                               // Время в точке В
    
      Print("i = ", i," i_maTF = ", i_maTF, " i_maPeriod = ", i_maPeriod," i_maShiftByPrice ", i_maShiftByPrice, " i_maMethod = ", i_maMethod," i_maPrice = ", i_maPrice, " i_shiftBarsBack1 = ", i_shiftBarsBack1);
      string error = GetMyLastError2();
      
      
//      Print("i = ", i," time1 = ", time1, " price1 = ", price1);
  //    Print("vars", DoubleToStr(price1,5));
    //  Print("vars", DoubleToStr(varsPrice1[i],5));
      
      varsPrice1[i] = price1;                                                                        // Массив цен в точке А
      varsPrice2[i] = price2;                                                                        // Массив цен в точке В
      varsTime1[i] = time1;                                                                          // Массив времени в точке А
      varsTime2[i] = time2;                                                                          // Массив времени в точке В
    
   
  //    Print("vars", DoubleToStr(varsPrice1[i],5));
    
      //Print("i = ", i," time1 = ", time1, " price1 = ", price1);
    //  Print("i = ", i," time2 = ", time2, " price2 = ", price2);
  //    Print("i = ", i," varsTime1[i] = ", varsTime1[i], " varsPrice1[i] = ", varsPrice1[i]);
     // Print("i = ", i," varsTime2[i] = ", varsTime2[i], " varsPrice2[i] = ", varsPrice2[i]);
            
      double d = (MathAbs(varsTime1[i] - varsTime2[i]))*1.0;
      double h = (MathAbs(varsPrice1[i] - varsPrice2[i]));
      
  //    Print("d = ", d, " h = ", h);
      
      double angle = h/d;
      varsAngle[i] = angle;
      
 //     Print("i = ", i," varsAngle[i] = ", varsAngle[i]);
    }
   return(0);
  }
  
string GetMyLastError2()
  {
    int err = GetLastError();
    string serr = ErrorDescription(err);
    return(serr);
  }

/* //+------------------------------------------------------------------+
//|                  Функция рассчёта тангенса угла                  |
//+------------------------------------------------------------------+
double TanA(double d, double h)
 {
   double angle = h/d;
   
  return(0);
 }
// -------------- блок деинициализации закончен ---------------------- */
Dateien:
anglebytg.mq4  6 kb
 

Bitte um Hilfe! Wie kann man einen EA dazu bringen, eine alte Bestellung zu schließen, wenn man eine neue eröffnet? In der Strategie-Tester es funktioniert gut, aber auf dem realen Konto aus irgendeinem Grund, wenn ich eine neue öffnen, die alte verlässt???????? Ich bin eine totale Null im Programmieren(((

//---- input parameters
//ooooooooooooooooooooooooooooooooooooooooooooooooo
extern bool In_BUY=true;
extern int SL_buy=62; //---входные параметры по лонгам
extern int Risk_buy=0;
//ooooooooooooooooooooooooooooooooooooooooooooooooo
extern bool In_SELL=true;
extern int SL_sell=62; //---входные параметры по шортам
extern int Risk_sell=0;
//ooooooooooooooooooooooooooooooooooooooooooooooooo

//---- other parameters
static int prevtime=0;
int ticket=0;
int x=1;
//----------------------------------------------
int Magic_BUY =123;
int Magic_SELL =321;


//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
int init()
{
//----
if(Digits == 5) x=10;
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----

//----
return(0);
}
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start()
{
//oooooooooooooooooooooooooooooooooooooooooooooooooooo
if (Time[0] == prevtime) return(0);
prevtime = Time[0];
if (!IsTradeAllowed()) {
prevtime=Time[1]; MathSrand(TimeCurrent());Sleep(30000 + MathRand()); //--- формировка бара---
}
//ooooooooooooooooooooooooooooooooooooooooooooooooooooOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO


Trade( Magic_BUY, In_BUY,Ask,0,2, SL_buy, Risk_buy); //---торговля по лонгам


Trade(Magic_SELL,In_SELL,Bid,2,0, SL_sell,Risk_sell); //---торговля по шортам


//ooooooooooooooooooooooooooooooooooooooooooooooooooooOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO
return(0);//-----------выход из стартовой функции------------
}
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
void Trade(int mn,bool flag,double price,int period_1,int period_2,int sl,int Risk) {

int total=OrdersTotal();

for (int i = 0; i < total; i++) { OrderSelect(i, SELECT_BY_POS, MODE_TRADES);//---проход по ордерам--


if (OrderSymbol() == Symbol() && OrderMagicNumber() == mn) {

if(Open[period_2]>Open[period_1]) { //----условие закрытия ордера---------

OrderClose(OrderTicket(),OrderLots(),price,5*x); RefreshRates();

}

return(0);
}
}

//ooooooooooooooooooooooooooooooooooooooooooooooooooo
ticket = -1;



if ( flag &&

Open[period_1]>Open[period_2] && //----вход в рынок по условию---


OrdersTotal()<2 && //-----ограничения чемпионата------

AccountEquity()>200 &&

IsTradeAllowed()) {

if (mn<200) {

ticket= OrderSend(Symbol(), OP_BUY,lot(Risk_buy),Ask,5,Bid-x*sl*Point,0,DoubleToStr(mn,0),mn,0,Blue);


}


else {

ticket= OrderSend(Symbol(),OP_SELL,lot(Risk_sell),Bid,5,Ask+x*sl*Point,0,DoubleToStr(mn,0),mn,0, Red);

}


RefreshRates();

if ( ticket < 0) { Sleep(30000); prevtime = Time[1]; }

} //-- Exit ---

return(0); }


//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
double lot(int R) { if (R<0)R=0; if (R>80)R=80; //------корректность ввода -------
double minlot = MarketInfo(Symbol(), MODE_MINLOT);
int o = MathAbs(MathLog(minlot) *0.4343) + 0.5;
double lot = minlot;
//ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
lot = NormalizeDouble(AccountFreeMargin() * 0.00001*R, o);//---
if (AccountFreeMargin() < lot * MarketInfo(Symbol(), MODE_MARGINREQUIRED)) {
lot = NormalizeDouble(AccountFreeMargin() / MarketInfo(Symbol(), MODE_MARGINREQUIRED), o);
}
//ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
if(lot < minlot) lot = minlot;
double maxlot =MarketInfo(Symbol(), MODE_MAXLOT);
if(lot > maxlot) lot = maxlot;
return(lot); }
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx_end_film_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Oder vielleicht schreiben Sie eine andere EA, die auf dem Prinzip der 1 hat geöffnet, 2 hat geöffnet-1 hat geschlossen, 3Opened-2 hat geschlossen, usw. arbeiten würde. Wir brauchen dringend Hilfe!!!
 
al7bar:

Bitte um Hilfe! Wie kann man einen EA dazu bringen, eine alte Bestellung zu schließen, wenn man eine neue eröffnet? In der Strategie-Tester es funktioniert gut, aber auf dem realen Konto aus irgendeinem Grund, wenn ich eine neue öffnen, die alte verlässt???????? Ich habe überhaupt keine Ahnung vom Programmieren((!

//---- input parameters
//ooooooooooooooooooooooooooooooooooooooooooooooooo
extern bool In_BUY=true;
extern int SL_buy=62; //---входные параметры по лонгам
extern int Risk_buy=0;

Ersetzen Sie

if(Open[period_2]>Open[period_1]) { //----условие закрытия ордера---------

 OrderClose(OrderTicket(),OrderLots(),price,5*x); RefreshRates(); 

 }

zu

if(Open[period_2]>Open[period_1]) { //----условие закрытия ордера---------

 OrderClose(OrderTicket(),OrderLots(),OrderClosePrice(),5*x); RefreshRates(); 

 }
 
7777877:
Mein Ziel in diesem Stadium ist es, zu verstehen, wie diese oder jene Funktion funktioniert, und in diesem speziellen Fall, wie die Funktion ArrayGetAsSeries funktioniert. Ich verstehe, dass Sie die Funktion ArraySetAsSeries mit dem Parameter set=true verwenden können , der die Indizierung zwangsweise festlegt, wie in array-timeseries. Aber ich möchte verstehen, warum in meinem Fall Funktion ArrayGetAsSeries 0 zurückgegeben, trotz Array sieht aus wie Zeitreihen (d.h. indiziert wie Zeitreihen)

Eben weil sie nur als Zeitreihe ERKLÄRT.

Dies ist nur Ihre persönliche Meinung. Und wenn man dort die Zahlen 1, 2, 1.2, 2.1 einträgt, erhält man eine Zeitreihe für Schweinefleisch von 1927 (die Zahlen sind bedingt). Dies macht das Array jedoch nicht zu einer Zeitreihe - Sie müssen es explizit mit der Funktion

Grund der Beschwerde: