Fragen von Neueinsteigern zu MQL4 und MQL5, Hilfe und Diskussion über Algorithmen und Codes - Seite 385

 
Alexandr Ivanov:

Nun, ich habe es auch nicht gefunden...

Traurigkeit. Sie müssen also schätzen, wie viele Ticks in einem Balken enthalten sind, und daraus schließen, ob es sich um Eröffnungskurse oder alle Ticks handelt.

Einen MT4 EA plattformübergreifend zu erstellen, dauert mit den richtigen Fähigkeiten nur fünf Minuten (einmal!). Dann testen Sie (viele Male) im MT5 mit echten oder benutzerdefinierten Ticks und handeln im MT4.

 

Hallo zusammen. Ein Skript haben, das die TF auf allen offenen Charts nach Belieben ändert

Es muss eine genehmigte Version erstellt werden, die die Muster ändert.

Aber dafür müssen Sie mir wenigstens zeigen, was ein Muster in Bezug auf den Code ist

 

Hallo. Es gibt einen vorgefertigten SMI-Indikator. Aber es funktioniert nicht. Wenn ich es zum ersten Mal ausführe, tut es das, und dann muss ich bei jedem neuen Balken auf Aktualisieren drücken oder zu einem anderen Zeitrahmen wechseln. Und warum? Vielleicht wurde dieses Thema hier schon angesprochen, kann ich den Link bekommen? Ich danke Ihnen im Voraus.

Dateien:
SMI.mq4  8 kb
 

Bitte erklären Sie, warum die Bestellung nicht geöffnet wurde.

Hier sind die Zeilen aus dem Protokoll:

2017.11.24 20:00:00.061 '5390918': requote 1,19357 / 1,19368 für offenen Verkauf 0,01 EURUSD bei 1,19361 sl: 1,19848 tp: 1,18402

2017.11.24 19:59:59.515 '5390918': Sofortiger Verkaufsauftrag für 0,01 EURUSD zu 1,19361 sl: 1,19848 tp: 1,18402

Die Slippage beträgt 11 Pips. Die Slippage wurde im EA auf 27 Pips festgelegt. Die Überprüfung der geöffneten Bestellung ergab den Fehler 138 (neue Preise).

Bitte erklären Sie, warum die Bestellung nicht geöffnet wurde?

 
RichLux:

Bitte erklären Sie, warum die Bestellung nicht geöffnet wurde.

Hier sind die Zeilen aus dem Protokoll:

2017.11.24 20:00:00.061 '5390918': requote 1,19357 / 1,19368 für offenen Verkauf 0,01 EURUSD bei 1,19361 sl: 1,19848 tp: 1,18402

2017.11.24 19:59:59.515 '5390918': Sofortiger Verkaufsauftrag für 0,01 EURUSD zu 1,19361 sl: 1,19848 tp: 1,18402

Die Slippage beträgt 11 Pips. Die Slippage wurde im EA auf 27 Pips festgelegt. Die Überprüfung der geöffneten Bestellung ergab den Fehler 138 (neue Preise).

Bitte erklären Sie, warum die Bestellung nicht geöffnet wurde?

Ändern Sie den Handel oder die Kontoart, um diese Probleme zu vermeiden. Sie sollten sich ein Konto mit Marktausführung zulegen - vergessen Sie die sofortige Ausführung.

 

Bitte sagen Sie mir, wie ich einen Code schreiben kann, um eine Position nicht auf das Gegenteil des Indikatorsignals zu schließen, sondern auf einen Take-Profit, und der Advisor würde sich nicht sofort nach dem Schließen öffnen

zum Beispiel ein Signal, um die Kreuzung der gleitenden Durchschnitte mit verschiedenen Perioden, Take-Profit 50 Pips. wenn möglich in mql5

Ich habe einen Code, der, sobald er die Gewinnmitnahme erreicht und das Geschäft schließt, sofort ein neues eröffnet, auch wenn es kein neues Signal/keine neue Grenze gibt.

 
Guten Tag. Bitte schauen Sie sich den Code an. Der Roboter entfernt keine horizontalen Linien, wenn neue erscheinen
 //+------------------------------------------------------------------+
//|                                                          2.0.mq4 |
//|                                       Copyright 2017,UriyGlushko |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2017,UriyGlushko"
#property link        "https://www.mql5.com"
#property version    "1.00"
#property strict

extern string Rodot           = "Параметры робота" ;
extern double Lots            = 0.1 ;
extern int     StopLoss        = 20 ;
extern int     TakeProfit      = 80 ;
extern int     Magic           = 568422685 ;
extern int     Slippage        = 3 ; // Проскальзывание
extern int     Shag            = 40 ; // Шаг для трейлингстопа
extern int     Tral_dist       = 40 ; // Дистанция трейлингстопа
extern bool    Use_traling     = true ; // Использование трейлингстопа true - Включено, false - Выключено
extern bool    Use_shag        = false ; // Использование шага. true - Включено, false - Выключено
extern bool    Use_bezubitok   = true ; // Использование безубытка. true - Включено, false - Выключено



//      Параметры индикатора moving_averages
extern string   MA             = "Параметры Скользащей средней" ;
extern int      MA_Period      = 3 ; // Период
extern int      MA_Shift       = 0 ; // Сдвиг
extern int      MA_Method      = 0 ; // 0-простая, 1-экспонециальная, 2-сглаженная, 3-линейно-взвешенная

//      Параметры разворотных свечей
extern string Comment2 = "Параметры разворотных свечей" ;
extern bool _Doji           = false ;
extern ENUM_TIMEFRAMES      TimeFrame       = PERIOD_M5 ; // Период разворотной свечи
extern ENUM_TIMEFRAMES      LittleTimeFrame = PERIOD_M1 ; // Период точки входа
extern int                  ATR_period      = 14 ;         // Период индикатора волотильности

//      Параметры уровней области разворота
extern string Comment3 = "Параметры уровней области разворота" ;
extern int UpLineSell = 4 ;     // Верхняя линия ОР для продаж (пункт от High)
extern int DownLineSell = 4 ;   // Нижняя линия ОР для продаж (пункт от High)
extern int UpLineBuy = 4 ;     // Верхняя линия ОР для покупок (пункт от Low)
extern int DownLineBuy = 4 ;   // Нижняя линия ОР для покупок (пункт от Low)

double sl, tp, dist, shag, ma1, ma2;
int ticket;



int DojiCandle = 0 ;               //Счетчик баров "Дожи"
int DojiCandleBuy = 0 ;             //Счетчик входных баров на разворотном баре "Дожи" Buy
int DojiCandleSell = 0 ;           //Счетчик входных баров на разворотном баре "Дожи" Sell
int lineDojiCandle = 0 ;           //Счетчик уровней области разворота по паттерну "Дожи"


// Переменные функции "Новый бар"
bool New_Bar = false ;



// Переменные функции паттерна "Дожи"
bool BuyDoji = false ;
bool SellDoji = false ;
bool TradeUpDoji = false ;
bool TradeDownDoji = false ;
double UpLine_Doji;
double DownLine_Doji;


//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit ()
  {
   if ( Digits == 3 || Digits == 5 )
  {
   TakeProfit *= 10 ;
   StopLoss   *= 10 ;
   Slippage   *= 10 ;
   UpLineSell *= 10 ;
   DownLineSell *= 10 ;
   UpLineBuy *= 10 ;
   DownLineBuy *= 10 ;
  }

   return ( INIT_SUCCEEDED );
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit ( const int reason)
  {

   
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick ()
  {
   int magic = Magic;
   int shag_ = Shag;
   
   double Open1 = NormalizeDouble ( iOpen ( Symbol (), TimeFrame, 1 ), Digits );
   double Close1 = NormalizeDouble ( iClose ( Symbol (), TimeFrame, 1 ), Digits );
   double High1 = NormalizeDouble ( iHigh ( Symbol (), TimeFrame, 1 ), Digits );
   double Low1 = NormalizeDouble ( iLow ( Symbol (), TimeFrame, 1 ), Digits );
   
   Fun_New_Bar();
   Doji();

     ma1 = iCustom ( NULL , 0 , "moving_averages" ,MA_Period, MA_Shift, MA_Method, 0 , 1 );
     ma2 = iCustom ( NULL , 0 , "moving_averages" ,MA_Period, MA_Shift, MA_Method, 0 , 2 );
     

   if (_Doji == true )
     {
     if (SellDoji == true )
       {
           if (! ObjectCreate ( ChartID (), "Arrow_Down_Doji" + IntegerToString (DojiCandle), OBJ_ARROW_DOWN , 0 , TimeCurrent (), High [ 1 ] + 70 * Point ))
             {
             Print ( "Не удалось создать метку вниз" );
             }
             ObjectSetInteger ( ChartID (), "Arrow_Down_Doji" + IntegerToString (DojiCandle), OBJPROP_COLOR , clrChocolate ); //--- установка цвета
             ObjectSetInteger ( ChartID (), "Arrow_Down_Doji" + IntegerToString (DojiCandle), OBJPROP_STYLE , STYLE_SOLID ); //--- установка стиля линии
             ObjectSetInteger ( ChartID (), "Arrow_Down_Doji" + IntegerToString (DojiCandle), OBJPROP_WIDTH , 1 ); //--- установка толщины линии
             ObjectSetInteger ( ChartID (), "Arrow_Down_Doji" + IntegerToString (DojiCandle), OBJPROP_BACK , false ); //--- отображение на переднем (false) или заднем (true) плане
             DojiCandle ++;
             
           if (! ObjectCreate ( ChartID (), "UpLine_Doji" + IntegerToString (lineDojiCandle), OBJ_HLINE , 0 , TimeCurrent (),UpLine_Doji))
             {
             Print ( "Не удалось создать верхнюю линию" );
             }
             ObjectSetInteger ( ChartID (), "UpLine_Doji" + IntegerToString (lineDojiCandle), OBJPROP_COLOR , clrChocolate ); //--- установим цвет прямоугольника 
             ObjectSetInteger ( ChartID (), "UpLine_Doji" + IntegerToString (lineDojiCandle), OBJPROP_STYLE , STYLE_SOLID ); //--- установим стиль линий прямоугольника 
             ObjectSetInteger ( ChartID (), "UpLine_Doji" + IntegerToString (lineDojiCandle), OBJPROP_WIDTH , 1 ); //--- установим толщину линий прямоугольника 
             ObjectSetInteger ( ChartID (), "UpLine_Doji" + IntegerToString (lineDojiCandle), OBJPROP_BACK , false ); //--- отобразим на переднем (false) или заднем (true) плане 
             
           if (! ObjectCreate ( ChartID (), "DownLine_Doji" + IntegerToString (lineDojiCandle), OBJ_HLINE , 0 , TimeCurrent (),DownLine_Doji))
             {
             Print ( "Не удалось создать нижнюю линию" );
             }
             ObjectSetInteger ( ChartID (), "DownLine_Doji" + IntegerToString (lineDojiCandle), OBJPROP_COLOR , clrBrown ); //--- установим цвет прямоугольника 
             ObjectSetInteger ( ChartID (), "DownLine_Doji" + IntegerToString (lineDojiCandle), OBJPROP_STYLE , STYLE_SOLID ); //--- установим стиль линий прямоугольника 
             ObjectSetInteger ( ChartID (), "DownLine_Doji" + IntegerToString (lineDojiCandle), OBJPROP_WIDTH , 1 ); //--- установим толщину линий прямоугольника 
             ObjectSetInteger ( ChartID (), "DownLine_Doji" + IntegerToString (lineDojiCandle), OBJPROP_BACK , false ); //--- отобразим на переднем (false) или заднем (true) плане 
             lineDojiCandle ++;
           
         if (Open1 == Close1)
           {
             if (! ObjectCreate ( ChartID (), "Arrow_Down_Doji" + IntegerToString (DojiCandle), OBJ_ARROW_DOWN , 0 , TimeCurrent (), High [ 1 ] + 70 * Point ))
               {
               Print ( "Не удалось создать метку вниз" );
               }
               ObjectSetInteger ( ChartID (), "Arrow_Down_Doji" + IntegerToString (DojiCandle), OBJPROP_COLOR , clrChocolate ); //--- установка цвета
               ObjectSetInteger ( ChartID (), "Arrow_Down_Doji" + IntegerToString (DojiCandle), OBJPROP_STYLE , STYLE_SOLID ); //--- установка стиля линии
               ObjectSetInteger ( ChartID (), "Arrow_Down_Doji" + IntegerToString (DojiCandle), OBJPROP_WIDTH , 1 ); //--- установка толщины линии
               ObjectSetInteger ( ChartID (), "Arrow_Down_Doji" + IntegerToString (DojiCandle), OBJPROP_BACK , false ); //--- отображение на переднем (false) или заднем (true) плане
               DojiCandle ++;
               Print ( "Дожи крест Down" );
            
             if (! ObjectCreate ( ChartID (), "UpLine_Doji" + IntegerToString (lineDojiCandle), OBJ_HLINE , 0 , TimeCurrent (),UpLine_Doji))
               {
               Print ( "Не удалось создать верхнюю линию" );
               }
               ObjectSetInteger ( ChartID (), "UpLine_Doji" + IntegerToString (lineDojiCandle), OBJPROP_COLOR , clrOrangeRed ); //--- установим цвет прямоугольника 
               ObjectSetInteger ( ChartID (), "UpLine_Doji" + IntegerToString (lineDojiCandle), OBJPROP_STYLE , STYLE_SOLID ); //--- установим стиль линий прямоугольника 
               ObjectSetInteger ( ChartID (), "UpLine_Doji" + IntegerToString (lineDojiCandle), OBJPROP_WIDTH , 1 ); //--- установим толщину линий прямоугольника 
               ObjectSetInteger ( ChartID (), "UpLine_Doji" + IntegerToString (lineDojiCandle), OBJPROP_BACK , false ); //--- отобразим на переднем (false) или заднем (true) плане 
                  
             if (! ObjectCreate ( ChartID (), "DownLine_Doji" + IntegerToString (lineDojiCandle), OBJ_HLINE , 0 , TimeCurrent (),DownLine_Doji))
               {
               Print ( "Не удалось создать нижнюю линию" );
               }
               ObjectSetInteger ( ChartID (), "DownLine_Doji" + IntegerToString (lineDojiCandle), OBJPROP_COLOR , clrBrown ); //--- установим цвет прямоугольника 
               ObjectSetInteger ( ChartID (), "DownLine_Doji" + IntegerToString (lineDojiCandle), OBJPROP_STYLE , STYLE_SOLID ); //--- установим стиль линий прямоугольника 
               ObjectSetInteger ( ChartID (), "DownLine_Doji" + IntegerToString (lineDojiCandle), OBJPROP_WIDTH , 1 ); //--- установим толщину линий прямоугольника 
               ObjectSetInteger ( ChartID (), "DownLine_Doji" + IntegerToString (lineDojiCandle), OBJPROP_BACK , false ); //--- отобразим на переднем (false) или заднем (true) плане 
               lineDojiCandle ++; 
            }
        }
         
       static int switch12 = 0 ;
       static int switch22 = 0 ;
       static int switch32 = 0 ;
      
       if (ma2 > UpLine_Doji && ma2 > DownLine_Doji && ma1 > UpLine_Doji && ma1 > DownLine_Doji)
        {
        UpLine_Doji = 0 ;
        DownLine_Doji = 0 ;
        }
      
       if (ma2 > DownLine_Doji)
        {
         if (ma1 < DownLine_Doji)
          {
          switch12 = 1 ;
           Print ( "пересечение дожи 1" );
          }
        }
         
       if (ma2 < DownLine_Doji)
        {
         if (ma1 > DownLine_Doji)
          {
           if (switch12 == 1 )
            {
            switch22 = 1 ;
             Print ( "пересечение дожи 2" );
            }
          }
        }
         
       if (ma2 > DownLine_Doji)
         {
         if ( Close [ 1 ] < DownLine_Doji)
           {
           if (switch12 == 1 )
             {
             if (switch22 == 1 )
               {
               switch32 = 1 ;
               Print ( "пересечение дожи 3" );
               }
             }
           }
         }
         
       if (switch12 == 1 )
         {
         if (switch22 == 1 )
           {
           if (switch32 == 1 )
             {
             if (! ObjectCreate ( ChartID (), "Arrow_Sell_Doji" + IntegerToString (DojiCandleSell), OBJ_ARROW_SELL , 0 , TimeCurrent (), Low [ 1 ] + 50 * Point ))
               {
               Print ( "Не удалось создать метку вниз" );
               }
               ObjectSetInteger ( ChartID (), "Arrow_Sell_Doji" + IntegerToString (DojiCandleSell), OBJPROP_COLOR , clrChocolate ); //--- установка цвета
               ObjectSetInteger ( ChartID (), "Arrow_Sell_Doji" + IntegerToString (DojiCandleSell), OBJPROP_STYLE , STYLE_SOLID ); //--- установка стиля линии
               ObjectSetInteger ( ChartID (), "Arrow_Sell_Doji" + IntegerToString (DojiCandleSell), OBJPROP_WIDTH , 1 ); //--- установка толщины линии
               ObjectSetInteger ( ChartID (), "Arrow_Sell_Doji" + IntegerToString (DojiCandleSell), OBJPROP_BACK , false ); //--- отображение на переднем (false) или заднем (true) плане
               DojiCandleSell ++;
               Print ( "Точка входа SELL по разворотной свече 'Дожи'" );
               UpLine_Doji = 0 ;
               DownLine_Doji = 0 ;
               
             if ( ObjectFind ( ChartID (), "Arrow_Sell_Doji" + IntegerToString (DojiCandleSell)))
               {
               switch12 = 0 ;
               switch22 = 0 ;
               switch32 = 0 ;
               }
                         
             if ( ObjectFind ( ChartID (), "UpLine_Doji" + IntegerToString (lineDojiCandle)) && ObjectFind ( ChartID (), "DownLine_Doji" + IntegerToString (lineDojiCandle)))
               {
               ObjectDelete ( "UpLine_Doji" + IntegerToString (lineDojiCandle));
               ObjectDelete ( "DownLine_Doji" + IntegerToString (lineDojiCandle));
               Print ( "Линии удалены" );
               }
               Print ( "Не удалось удалить верхнюю и нижнюю линии" ); 
             }
           }
         }
     
     }
   

      
   
 }
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//
//+------------------------------------------------------------------+
//    Функция определения нового бара                                |
//+------------------------------------------------------------------+
void Fun_New_Bar()
{ 
   datetime TimeBar0 = iTime ( Symbol (),TimeFrame, 0 );
   static datetime New_Time= 0 ;                     // Время текущего бара
   New_Bar= false ;                                 // Нового бара нет 
   if (New_Time != TimeBar0)                       // Сравниваем время 
   { 
      New_Time = TimeBar0;                         // Теперь время такое 
      New_Bar = true ;                             // Поймался новый бар 
   } 
}

//+------------------------------------------------------------------+
//    Функция паттерна Дожи для бычьего и медвежьего рынка          |
//+------------------------------------------------------------------+
void Doji()
{
//Параметры Дожи
   double Open1 = NormalizeDouble ( iOpen ( Symbol (), TimeFrame, 1 ), Digits );
   double Close1 = NormalizeDouble ( iClose ( Symbol (), TimeFrame, 1 ), Digits );
   double High1 = NormalizeDouble ( iHigh ( Symbol (), TimeFrame, 1 ), Digits );
   double Low1 = NormalizeDouble ( iLow ( Symbol (), TimeFrame, 1 ), Digits );
   double Open2 = NormalizeDouble ( iOpen ( Symbol (), TimeFrame, 2 ), Digits );
   double Close2 = NormalizeDouble ( iClose ( Symbol (), TimeFrame, 2 ), Digits );
   double High2 = NormalizeDouble ( iHigh ( Symbol (), TimeFrame, 2 ), Digits );
   double Low2 = NormalizeDouble ( iLow ( Symbol (), TimeFrame, 2 ), Digits );
   
//Параметры индикатора волотильности ATR для нахожденя относительно большой свечи перед Доджи
   double ATR = iATR ( Symbol (),TimeFrame,ATR_period, 1 );
   
   BuyDoji = false ;
   SellDoji = false ;
   
//Математическое описание патерна Дожи
   if (Close1 < High1 - NormalizeDouble ( 0.3 *(High1-Low1), Digits )&& 
      Open1 < High1 - NormalizeDouble ( 0.3 *(High1-Low1), Digits )&& 
      Close1 > High1 - NormalizeDouble ( 0.7 *(High1-Low1), Digits )&& 
      Open1 > High1 - NormalizeDouble ( 0.7 *(High1-Low1), Digits )&& 
       MathAbs (Close1-Open1) <= NormalizeDouble ( 0.4 *(High1-Low1), Digits )&&
       MathAbs (Close2-Open2) > 0.8 *ATR && MathAbs (High1-Low1) > 0.6 *ATR)
      {
         if ((Close2 - Open2) > 0 && New_Bar)
         { 
            UpLine_Doji = High1 + UpLineSell* Point ();
            DownLine_Doji = High1 - DownLineSell* Point ();
            SellDoji = true ;
             Print ( "Down Doji" ); // Условие разворота в медвежий тренд
         }
         if ((Close2 - Open2) < 0 )
         {
            UpLine_Doji = High1 + UpLineBuy* Point ();
            DownLine_Doji = High1 - DownLineBuy* Point ();
            BuyDoji = true ;
             Print ( "Up Doji" ); // Условие разворота в бычий тренд
         }
      }
      
}

Verwenden von Variablen

       static int switch12 = 0 ;
       static int switch22 = 0 ;
       static int switch32 = 0 ;

die Eintrittspunktbedingung wird geschrieben

 
voron_026:
Guten Tag. Bitte sehen Sie sich den Code an. Der Roboter entfernt keine horizontalen Linien, wenn neue Linien erscheinen

Verwendung der Variablen

um die Bedingung des Einstiegspunktes zu schreiben

Der Grund dafür ist, dass dem Zeilennamen ein Zähler hinzugefügt wird, der den Wert um eins erhöht, bevor er gelöscht wird.

 
Ich verstehe, was Sie meinen. Wie kann man dann die Entfernung von Leitungen durchführen? Ich möchte, dass die Zeilen gelöscht werden, sobald ein neues Muster mit eigenen Zeilen erscheint
 
voron_026:
Ich verstehe, was Sie meinen. Wie kann man dann die Entfernung von Leitungen durchführen? Ich möchte, dass die Linien gelöscht werden, sobald ein neues Muster mit eigenen Linien erscheint

Haben Sie eigene Vorschläge?

Vielleicht erst löschen und dann erstellen? Oder nicht löschen und nur die Koordinaten ändern? Welchen Sinn hat es, sie zu löschen und neue zu erstellen?

Grund der Beschwerde: