Wie ich meinen Berater durch Versuch und Irrtum zusammenstelle - Seite 19

 

Skript zum Löschen eines Indikators nach INDICATOR_SHORTNAME

//+------------------------------------------------------------------+
//|                                               Indicators Del.mq5 |
//|                                                      Dina Paches |
//|                           https://login.mql5.com/ru/users/dipach |
//|                                  Copyright 2019, Klapatyuk Corp. |
//|                             https://www.mql5.com/ru/users/klaxse |
//+------------------------------------------------------------------+
#property copyright   "Copyright 2019, Klapatyuk Corp."
#property link        "https://www.mql5.com/ru/users/klaxse"
#property description "2017, Dina Paches"
#property description "https://login.mql5.com/ru/users/dipach"
#property version     "1.00"
#property script_show_inputs
//---
input string short_name  = "FiboPivot_V2";   // INDICATOR_SHORTNAME
input string short_name0 = "MorningFlat_V3"; // INDICATOR_SHORTNAME
input bool   Inpres      = false;            // Delete All Indicators
//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart()
  {
//--- сконструируем короткое имя индикатора на основе входных параметров
     {ActionsOnTheChart(0);}
//----
   ChartRedraw();
//---
  }
//+------------------------------------------------------------------+
bool ActionsOnTheChart(const long chart_id)
  {
   int sub_windows_total =-1;
   int indicators_total  =0;
//---
   if(!ChartWindowsTotal(chart_id,sub_windows_total))
     {
      return(false);
     }
//---
   for(int i=sub_windows_total-1; i>=0; i--)
     {
      indicators_total=ChartIndicatorsTotal(chart_id,i);
      //---
      if(indicators_total>0)
        {
         ChIndicatorsDelete(chart_id,i,indicators_total);
        }
     }
//---
   return(true);
  }
//+------------------------------------------------------------------+
bool ChartWindowsTotal(const long chart_ID,int &sub_windows_total)
  {
   long value=-1;
//---
   if(!ChartGetInteger(chart_ID,CHART_WINDOWS_TOTAL,0,value))
     {Print(__FUNCTION__," Error = ",GetLastError()); return(false);}
//---
   sub_windows_total=(int)value;
//---
   return(true);
  }
//+------------------------------------------------------------------+
void ChIndicatorsDelete(const long  chart_id,
                        const int   sub_window,
                        const int   indicators_total)
  {
   for(int i=indicators_total-1; i>=0; i--)
     {
      string indicator_name=ChartIndicatorName(chart_id,sub_window,i);
      //---
      ChIndicatorDelete(indicator_name,chart_id,sub_window);
     }
//---
   return;
  }
//+------------------------------------------------------------------+
//| обработчик события Deinit                                        |
//+------------------------------------------------------------------+
void ChIndicatorDelete(const string shortname,
                       const long   chartid=0,
                       const int    subwindow=0)
  {
   bool res=ChartIndicatorDelete(chartid,subwindow,short_name);
   bool res2=ChartIndicatorDelete(chartid,subwindow,short_name0);
   if(Inpres)
      bool res0=ChartIndicatorDelete(chartid,subwindow,shortname);
//--- проанализируем результат вызова ChartIndicatorDelete()
   if(!res)
     {
      PrintFormat("%s",shortname,subwindow,GetLastError());
     }
  }
//+------------------------------------------------------------------+

den Namen des Indikators richtig zu schreiben - Kopie wie im Begriff

Bild 2

Dateien:
 

Ich habe ihn aufgesetzt - einen manuellen Handelsassistenten.

Ich habe es mit einem echten Konto getestet - alles, was davon abhängt, funktioniert.

//---
input datetime HoursFrom            = D'1970.01.01';  // Время старта Эксперта
input datetime HoursTo              = D'2030.12.31';  // Время закрытия всех позиций
input double   TargetProfit         = 200000.00;      // Целевая прибыль
sinput string  t1="------ Как работать Эксперту---";  //
input double   InpLots              = 0.01;           // Lots
input bool     inpbuysell           = false;          // Реверс (buy/sell)
input bool     InpPanel             = true;           // Скрыть кнопки\\по времени Buy\Sell
input bool     InpOnlyLimit         = false;          // Выставить отложенный ордер
input bool     InpOnlystart         = true;           // Вкл. Buy\Sell
input bool     InpCloseOpposite     = false;          // Вкл.Trailing Stop по индикатору\Close opposite
input bool     InpReverse           = false;          // Reverse Indicators - переворот торгового сигнала
input string   t2="------ Trailing parameters ------";//
input double   InStopLoss           = 250.0;          // Stop Loss
input double   InTakeProfit         = 460.0;          // Take Profit
input ushort   InpTrailingStop      = 25;             // Trailing Stop (min distance from price to Stop Loss, in pips
input ushort   InpTrailingStep      = 5;              // Trailing Step, in pips (1.00045-1.00055=1 pips)
sinput string  t3="------ Варианты ордеров ------";   //
input uint     maxLimits            = 1;              // Кол-во отложенных.ордеров в сетке в одну сторону
input int      InpPenStep           = 25;             // Шаг сетки, пунктов
input string   t4="------ Trailing ордеров ------";   //
input bool     InpStopTrailing      = true;           // ВКЛ.Trailing отлож.ордеров(ВЫКЛ.если больше 1 в сетке)
input ushort   InpTrailingPenStop   = 25;             // Trailing Stop of a Orders. "0" --> off and Trailing Step is not important
input ushort   InpTrailingPenStep   = 5;              // Trailing Step of a Orders
input string   t5="------ в ту же сторону ------";    //
input bool     ReverseOne           = false;          // BUYLIMIT SELLLIMIT
input bool     ReverseOny           = true;           // BUYSTOP SELLSTOP
input string   t6="------ на оборот ------";          //
input bool     ReverseOne1          = false;          // SELLLIMIT BUYLIMIT
input bool     ReverseOny1          = false;          // SELLSTOP BUYSTOP
input string   t7="------ ТРЕНД ЛИНИЯ ------";        //
input bool     InpReverse0          = false;          // Reverse Open - переворот торгового сигнала
input string   BuyStop_TrendName    = "buy";          // Trend Line Name "buy";
input string   SellStop_TrendName   = "sell";         // Trend Line Name "sell";
input string   BuyClose_TrendName   = "closesell";    // Trend Line Name "closesell";
input string   SellClose_TrendName  = "closebuy";     // Trend Line Name "closebuy";
input bool     InpReverse1          = false;          // Reverse Close - переворот торгового сигнала
input string   t8="------ ЛИНИЯ Open ------";         //
input string   InpHLineBUY          = "S2_Line";      // HLine Name buy
input string   InpHLineSELL         = "R2_Line";      // HLine Name sell
input bool     InpReverse01         = false;          // Reverse Open - переворот торгового сигнала
input bool     UseDelete            = true;           // УДАЛЕНИЕ ИНДИКАТОРА Open
input string   short_name           = "FiboPivot_V2"; // INDICATOR_SHORTNAME
input string   t9="------ ЛИНИЯ Close ------";        //
input string   InpHLineCloseBUY     = "S3_Line";      // HLine Name Close buy
input string   InpHLineCloseSELL    = "R3_Line";      // HLine Name Close sell
input bool     InpReverse10         = false;          // Reverse Close - переворот торгового сигнала
input bool     UseDelete1           = false;          // УДАЛЕНИЕ ИНДИКАТОРА Close
input string   short_name0          = "FiboPivot_V2"; // INDICATOR_SHORTNAME
input bool     Inpres               = false;          // Delete All Indicators
//---
Dateien:
 
Aleksandr Klapatyuk:

Skript zum Löschen eines Indikators nach INDICATOR_SHORTNAME

um den Namen eines Indikators richtig zu schreiben - kopieren Sie ihn wie in der Thermik


Der Indikator löschteine nach der anderen aus allen Diagrammen, die gewünschten können durch Drücken von "Abbrechen" übersprungen werden.

 
Vitaly Muzichenko:

Der Indikator löscht eine nach der anderen aus allen Diagrammen, Sie können die gewünschten Diagramme überspringen, indem Sie auf "Abbrechen" drücken.

Ich habe auch versucht, Ihr Skript zu verwenden - es funktioniert, wie es sollte.

Ich brauche ihn nur für andere Zwecke und habe ihn an meinen Expert Advisor angehängt.

Ich habe Indikatoren mit horizontalen Linien - wenn der EA durch eine horizontale Linie ausgelöst wird, möchte ich, dass er den Indikator löscht, der in den Einstellungen vorgegeben ist.

und haben die anderen Indikatoren nicht entfernt.

input string   t8="------ ЛИНИЯ Open ------";         //
input string   InpHLineBUY          = "S2_Line";      // HLine Name buy
input string   InpHLineSELL         = "R2_Line";      // HLine Name sell
input bool     InpReverse01         = false;          // Reverse Open - переворот торгового сигнала
input bool     UseDelete            = true;           // УДАЛЕНИЕ ИНДИКАТОРА Open
input string   short_name           = "FiboPivot_V2"; // INDICATOR_SHORTNAME
input string   t9="------ ЛИНИЯ Close ------";        //
input string   InpHLineCloseBUY     = "S3_Line";      // HLine Name Close buy
input string   InpHLineCloseSELL    = "R3_Line";      // HLine Name Close sell
input bool     InpReverse10         = false;          // Reverse Close - переворот торгового сигнала
input bool     UseDelete1           = false;          // УДАЛЕНИЕ ИНДИКАТОРА Close
input string   short_name0          = "FiboPivot_V2"; // INDICATOR_SHORTNAME
input bool     Inpres               = false;          // Delete All Indicators
//---
 
Aleksandr Klapatyuk:

Ich habe ihn aufgesetzt - einen manuellen Handelsassistenten.

Ich habe es mit einem echten Konto überprüft - alles, was davon abhängt, funktioniert.

Die Funktion, die ich hinzugefügt habe.

input string   t8="------ ЛИНИЯ Open ------";         //
input string   InpHLineBUY          = "S2_Line";      // HLine Name buy
input string   InpHLineSELL         = "R2_Line";      // HLine Name sell
input bool     InpReverse01         = false;          // Reverse Open - переворот торгового сигнала
input bool     UseDelete            = true;           // УДАЛЕНИЕ ИНДИКАТОРА Open
input string   short_name           = "FiboPivot_V2"; // INDICATOR_SHORTNAME
input string   t9="------ ЛИНИЯ Close ------";        //
input string   InpHLineCloseBUY     = "S3_Line";      // HLine Name Close buy
input string   InpHLineCloseSELL    = "R3_Line";      // HLine Name Close sell
input bool     InpReverse10         = false;          // Reverse Close - переворот торгового сигнала
input bool     UseDelete1           = false;          // УДАЛЕНИЕ ИНДИКАТОРА Close
input string   short_name0          = "FiboPivot_V2"; // INDICATOR_SHORTNAME
input bool     Inpres               = false;          // Delete All Indicators

Ich dachte, es funktioniert nur mit der horizontalen Linie.

Ich weiß nicht, ob es nur vom Objektnamen abhängt.

Foto von

Karte vom Tester

-----------------------------------------------------------------------

so dumm. Es zeigte ein Ergebnis mit 0,01

Schnappschuss1

 

Ich habe es hier ein wenig korrigiert.

- Die Zeile wurde vorher gelöscht - und die Position wiederholt geschlossen. Sie schließt sich, dann wieder nicht.

//+------------------------------------------------------------------+
//| Check for long position closing                                  |
//+------------------------------------------------------------------+
bool CSampleExpert::LongClosedHLine(void)
  {
   bool res=false;
//--- should it be closed?
//--- check for long position (BUY) possibility
   double priceCloseAsk=ObjectGetDouble(0,InpHLineCloseBUY,OBJPROP_PRICE);
   if(priceCloseAsk==0.0)
      return(true);
   if(priceCloseAsk>m_symbol.Bid())
     {
      if(UseDelete1)
         IndicatorDelete();
      ObjectDelete(0,InpHLineCloseBUY);
      if(UseSound)
         PlaySound("ok.wav");
      if((!InpReverse10 && CheckForCloseSELL()) || (InpReverse10 && CheckForCloseBUY()))
        {
         ExtNeedDeleteAll=true;
         return(true);
        }
      res=true;
     }
//--- result
   return(res);
  }
//+------------------------------------------------------------------+

Aber jetzt - mit dieser Korrektur - ist sie geschlossen.

//+------------------------------------------------------------------+
//| Check for long position closing                                  |
//+------------------------------------------------------------------+
bool CSampleExpert::LongClosedHLine(void)
  {
   bool res=false;
//--- should it be closed?
//--- check for long position (BUY) possibility
   double priceCloseAsk=ObjectGetDouble(0,InpHLineCloseBUY,OBJPROP_PRICE);
   if(priceCloseAsk==0.0)
      return(true);
   if(priceCloseAsk>m_symbol.Bid())
     {
      if((!InpReverse10 && CheckForCloseSELL()) || (InpReverse10 && CheckForCloseBUY()))
        {
         if(UseDelete1)
            IndicatorDelete();
         ObjectDelete(0,InpHLineCloseBUY);
         if(UseSound)
            PlaySound("ok.wav");
         ExtNeedDeleteAll=true;
         return(true);
        }
      res=true;
     }
//--- result
   return(res);
  }
//+------------------------------------------------------------------+

Und ja - diese Funktion wird durch den Namen ausgelöst. entweder durch eine Trendlinie, durch eine horizontale Linie oder durch den Namen eines Objekts im Allgemeinen.

Совершение сделок - Торговые операции - MetaTrader 5
Совершение сделок - Торговые операции - MetaTrader 5
  • www.metatrader5.com
Торговая деятельность в платформе связана с формированием и отсылкой рыночных и отложенных ордеров для исполнения брокером, а также с управлением текущими позициями путем их модификации или закрытия. Платформа позволяет удобно просматривать торговую историю на счете, настраивать оповещения о событиях на рынке и многое другое. Открытие позиций...
Dateien:
 

Außerdem - um Verwirrung zu vermeiden -


input string   InpHLineBUY          = "open buy";     // ВНИЗУ Name buy
input string   InpHLineSELL         = "open sell";    // ВВЕРХУ Name sell
input bool     InpReverse01         = false;          // Reverse Open - переворот торгового сигнала

was auch immer Sie schreiben"offener Kauf" es sollte immer am unteren Ende des aktuellen Preises sein.

einfach den Rückwärtsgang einlegen - dann öffnet sich der Verkauf

Dateien:
 
Aleksandr Klapatyuk:

Ich habe es hier ein wenig korrigiert.

- Die Zeile wurde vorher gelöscht - und die Position wiederholt geschlossen. Sie schließt sich, dann wieder nicht.

Aber jetzt - mit dieser Korrektur - ist sie geschlossen.

Und ja - diese Funktion wird durch den Namen ausgelöst. entweder durch eine Trendlinie, durch eine horizontale Linie oder durch den Namen des Objekts im Allgemeinen.

Es gibt immer noch einen Fehler.

Ich habe es so korrigiert, es funktioniert wie es soll.

//+------------------------------------------------------------------+
//| Check for long position closing                                  |
//+------------------------------------------------------------------+
bool CSampleExpert::LongClosedHLine(void)
  {
   bool res=false;
//--- should it be closed?
//--- check for long position (BUY) possibility
   double priceCloseAsk=ObjectGetDouble(0,InpHLineCloseBUY,OBJPROP_PRICE);
   if(priceCloseAsk==0.0)
      return(true);
   if(priceCloseAsk>m_symbol.Bid())
     {
      if(!InpReverse10)
         if(CheckForCloseSELL())
           {
            if(UseDelete1)
               IndicatorDelete();
            ObjectDelete(0,InpHLineCloseBUY);
            if(UseSound)
               PlaySound("ok.wav");
            ExtNeedDeleteAll=true;
            return(true);
           }
      if(InpReverse10)
         if(CheckForCloseBUY())
           {
            if(UseDelete1)
               IndicatorDelete();
            ObjectDelete(0,InpHLineCloseBUY);
            if(UseSound)
               PlaySound("ok.wav");
            ExtNeedDeleteAll=true;
            return(true);
           }
      res=true;
     }
//--- result
   return(res);
  }
//+------------------------------------------------------------------+
Dateien:
 

Ich habe sie auch ein wenig verändert.

als ich zehn Positionen in einer Richtung eröffnete - die Schließungslinie wurde ausgelöst, neun wurden geschlossen, eine blieb übrig

------------

Es war so.

//+------------------------------------------------------------------+
//| Check for long position closing                                  |
//+------------------------------------------------------------------+
bool CSampleExpert::CheckForCloseBUY(void)
  {
   bool res=false;
   for(int i=PositionsTotal()-1; i>=0; i--) // returns the number of current positions
      if(m_position.SelectByIndex(i)) // selects the position by index for further access to its properties
         if(m_position.Symbol()==m_symbol.Name() && m_position.Magic()==MACD_MAGIC)
            if(m_position.PositionType()==(long)POSITION_TYPE_SELL) // gets the position type
               m_trade.PositionClose(m_position.Ticket()); // close a position by the specified symbol
//---
   res=true;
//--- result
   return(res);
  }
//+------------------------------------------------------------------+

Jetzt sieht es so aus

//+------------------------------------------------------------------+
//| Check for long position closing                                  |
//+------------------------------------------------------------------+
bool CSampleExpert::CheckForCloseBUY(void)
  {
   bool res=false;
   for(int i=PositionsTotal()-1; i>=0; i--) // returns the number of current positions
      if(m_position.SelectByIndex(i)) // selects the position by index for further access to its properties
         if(m_position.Symbol()==m_symbol.Name() && m_position.Magic()==MACD_MAGIC)
            if(m_position.PositionType()==(long)POSITION_TYPE_SELL) // gets the position type
               m_trade.PositionClose(m_position.Ticket()); // close a position by the specified symbol
   Sleep(SLEEPTIME*1000);
   for(int i=PositionsTotal()-1; i>=0; i--) // returns the number of current positions
      if(m_position.SelectByIndex(i)) // selects the position by index for further access to its properties
         if(m_position.Symbol()==m_symbol.Name() && m_position.Magic()==MACD_MAGIC)
            if(m_position.PositionType()==(long)POSITION_TYPE_SELL) // gets the position type
               m_trade.PositionClose(m_position.Ticket()); // close a position by the specified symbol
//---
   res=true;
//--- result
   return(res);
  }
//+------------------------------------------------------------------+
Dateien:
 

mit dieser Funktion.

Oh, Mann - ich habe es herausgefunden.

input string   t8="------ NAME Open ------";          //
input string   InpHLineBUY          = "(- ВНИЗУ -)";  // Name open buy (- ВНИЗУ -)
input string   InpHLineSELL         = "(- ВВЕРХУ -)"; // Name open sell (- ВВЕРХУ -)
input bool     InpReverse01         = false;          // Reverse Open - переворот торгового сигнала
input string   short_name           = "INDICATOR";    // INDICATOR_SHORTNAME Delete
input string   t9="------ NAME Close ------";         //
input string   InpHLineCloseBUY     = "(- ВНИЗУ -)";  // Name Close buy (- ВНИЗУ -)
input string   InpHLineCloseSELL    = "(- ВВЕРХУ -)"; // Name Close sell (- ВВЕРХУ -)
input bool     InpReverse10         = false;          // Reverse Close - переворот торгового сигнала
input string   short_name0          = "INDICATOR";    // INDICATOR_SHORTNAME Delete
input bool     Inpres               = false;          // Delete All Indicators
//+------------------------------------------------------------------+

Ich habe eine Trendlinie auf die Schräge gezeichnet - sie funktioniert nicht und das war's.

es stellt sich heraus, bis die gesamte Linie von Anfang bis Ende - der aktuelle Preis ist nicht überschritten. - funktioniert nicht

wird der aktuelle Preis die Grenze überschreitenund es wird nicht funktionieren.

EURUSDM1

Grund der Beschwerde: