Indikatoren: ATR Probability Levels

 

ATR Probability Levels:

Wahrscheinlichkeitsebenen auf Basis des ATR. Die "Wahrscheinlichkeit" wird auf der Grundlage der projizierten Average True Range und des vorherigen Schlusskurses berechnet.


Autor: Mladen Rakic

 

Toller Indikator! Ich habe dasselbe mit Puffern erstellt, irgendeine Idee, wie man Unterstützungs- und Widerstandsniveaus für jeden Tag darstellen kann, anstatt nur den aktuellen Tag zu haben?


Hier ist meine bisherige Version. Aber ich kann keinen Weg finden, um 10 Tage Tagesbalken für jeden"aktuellen Zeitrahmen" Bar zu bekommen.

//+------------------------------------------------------------------+
//|B_ATR_Levels.mq5 |
//+------------------------------------------------------------------+
#property copyright "Skullnick"
#property link      "https://www.mql5.com"
#property version   "1.00"

//--- Einstellungen für Indikatorplots
#property indicator_chart_window
#property indicator_buffers 6
#property indicator_plots   6

#property indicator_type1   DRAW_LINE 
#property indicator_color1  clrDeepSkyBlue
#property indicator_width1  1
#property indicator_label1  "Resistance 1"
#property indicator_style1  STYLE_DASH

#property indicator_type2   DRAW_LINE
#property indicator_color2  clrDeepSkyBlue
#property indicator_width2  1
#property indicator_label2  "Resistance 2"
#property indicator_style2  STYLE_DASH

#property indicator_type3   DRAW_LINE
#property indicator_color3  clrDeepSkyBlue
#property indicator_width3  1
#property indicator_label3  "Resistance 3"
#property indicator_style3  STYLE_DASH

#property indicator_type4   DRAW_LINE
#property indicator_color4  clrOrangeRed
#property indicator_width4  1
#property indicator_label4  "Support 1"
#property indicator_style4  STYLE_DASH

#property indicator_type5   DRAW_LINE
#property indicator_color5  clrOrangeRed
#property indicator_width5  1
#property indicator_label5  "Support 2"
#property indicator_style5  STYLE_DASH

#property indicator_type6   DRAW_LINE
#property indicator_color6  clrOrangeRed
#property indicator_width6  1
#property indicator_label6  "Support 3"
#property indicator_style6  STYLE_DASH

//--- Eingaben
input int             inpAtrPeriod   = 21;             // ATR-Zeitraum

//--- Indikatorpuffer
double ExtR1Buffer[];
double ExtR2Buffer[];
double ExtR3Buffer[];
double ExtS1Buffer[];
double ExtS2Buffer[];
double ExtS3Buffer[];

// Gewichte für den durchschnittlichen wahren Bereich
double dWeights[];

// Globale Variable
double dATR           = 0;
double dPreviousClose = 0;
  
//+------------------------------------------------------------------+
//| Benutzerdefinierte Initialisierungsfunktion für Indikatoren |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- Zuordnung von Indikatorpuffern
   SetIndexBuffer(0,ExtR1Buffer,   INDICATOR_DATA);         // Widerstand Stufe 1
   SetIndexBuffer(1,ExtR2Buffer,   INDICATOR_DATA);         // Widerstand Stufe 2
   SetIndexBuffer(2,ExtR3Buffer,   INDICATOR_DATA);         // Widerstand Stufe 3
   SetIndexBuffer(3,ExtS1Buffer,   INDICATOR_DATA);         // Unterstützung Stufe 1
   SetIndexBuffer(4,ExtS2Buffer,   INDICATOR_DATA);         // Unterstützung Stufe 2
   SetIndexBuffer(5,ExtS3Buffer,   INDICATOR_DATA);         // Unterstützung Stufe 3
   
   ArraySetAsSeries(ExtR1Buffer,    true);
   ArraySetAsSeries(ExtR2Buffer,    true);
   ArraySetAsSeries(ExtR3Buffer,    true);
   ArraySetAsSeries(ExtS1Buffer,    true);
   ArraySetAsSeries(ExtS2Buffer,    true);
   ArraySetAsSeries(ExtS3Buffer,    true);
   
   // Größe der Gewichte ändern
   ArrayResize(dWeights, inpAtrPeriod);
 
   // Glättung einstellen
   double dSmoothing = 2.0 / (ArraySize(dWeights) + 1);
   
   // Berechnung der Gewichte
   for(int i = 0; i < ArraySize(dWeights); i++)  
      dWeights[i] = dSmoothing * MathPow(1 - dSmoothing, i);   
   
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Benutzerdefinierte Indikator-Iterationsfunktion|
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
  {
//---
    
   // Tägliche Daten abrufen und prüfen, ob die Daten ausreichen
   MqlRates oDailyRates[];
   ArraySetAsSeries(oDailyRates, true);
     
   int iLast = 0;
   
   if(prev_calculated == 0)  
      iLast  = rates_total - 1;  
   else 
      iLast  = rates_total - prev_calculated;
   
   //--- Levels berechnen
   for(int i = iLast; i >= 0 && !IsStopped();i--)
   {
      
      int iNumDaysCopied = CopyRates(_Symbol, PERIOD_D1, 1, inpAtrPeriod + 1, oDailyRates);
      if(iNumDaysCopied >= (inpAtrPeriod+1) && bIsNewDay() == true)
      {
        // Berechnung der ATR für den Tag
          dATR            = dCalculateATR(oDailyRates);
          dPreviousClose  = oDailyRates[0].close;        
      }
      
      ExtR1Buffer[i] = dPreviousClose + 0.5  * dATR;
      ExtR2Buffer[i] = dPreviousClose + 0.75 * dATR;
      ExtR3Buffer[i] = dPreviousClose + 1.0  * dATR;
      ExtS1Buffer[i] = dPreviousClose - 0.5  * dATR;
      ExtS2Buffer[i] = dPreviousClose - 0.75 * dATR;
      ExtS3Buffer[i] = dPreviousClose - 1.0  * dATR;
   }

//--- Rückgabewert von prev_calculated für den nächsten Aufruf
   return(rates_total);
  }
//+------------------------------------------------------------------+


//+------------------------------------------------------------------+
//| ATR berechnen|
//+------------------------------------------------------------------+
double dCalculateATR(const MqlRates &oRates[])
{
    double dValue = 0;
    int iIndex    = 0;
    
    for (int i = 0; i < ArraySize(dWeights); i++)
    {
       double dHL   = oRates[i].high - oRates[i].low;
       double dHCp  = MathAbs(oRates[i].high - oRates[i+1].close);
       double dLCp  = MathAbs(oRates[i].low - oRates[i+1].close);
       double dTR   = MathMax(MathMax(dHL, dHCp),dLCp);
       
       dValue +=  dTR * dWeights[iIndex];      
       iIndex++;
    }   
    return dValue;
}

//-----------------------------
// -- Check New Day
//-----------------------------
bool bIsNewDay(void)
{
   bool bNewDay  = false;
   
   static datetime oDateOld;  
   datetime        oDateNew[1];
   
   MqlDateTime oStructDateOld;
   MqlDateTime oStructDateNew;

   // Array der aktuellen Zeit nach New_Time kopieren
   int iCopyHandle = CopyTime(_Symbol, PERIOD_D1, 0, 1, oDateNew);
   
   TimeToStruct(oDateNew[0] , oStructDateNew);
   TimeToStruct(oDateOld    , oStructDateOld);
   
   // Bei erfolgreicher Kopie
   if(iCopyHandle>0)
   {
      // Wenn der neue Tag
      if(oStructDateNew.day != oStructDateOld.day)
      {
         bNewDay  =  true;   
         oDateOld =  oDateNew[0];        
      }
   }      
   return bNewDay;     
}
 
Ich hätte gerne eine mt4-Version davon.
 
So ändern Sie die horizontale Linie des Indikators in eine kurze horizontale Linie, die nur die rechte Seite zeigt.
 
xy618z horizontale Linie des Indikators in eine kurze horizontale Linie ändern, die nur die rechte Seite anzeigt?

Hallo

Sie können versuchen, eine horizontale Linie zu erstellen, indem Sie

   ObjectCreate(0,_name,OBJ_HLINE,0,0,0);

und Startzeit + 'n' Perioden als Stoppzeit.

 
Anil Varma #:

Hallo

Sie können versuchen, eine horizontale Linie zu erstellen, indem Sie

und Startzeit + 'n' Perioden als Stoppzeit.

Die horizontale Linie erstreckt sich immer über das gesamte Diagramm - Sie können sie nicht durch einen Zeitparameter begrenzen: https: //www.mql5.com/en/docs/constants/objectconstants/enum_object/obj_hline

Documentation on MQL5: Constants, Enumerations and Structures / Objects Constants / Object Types / OBJ_HLINE
Documentation on MQL5: Constants, Enumerations and Structures / Objects Constants / Object Types / OBJ_HLINE
  • www.mql5.com
OBJ_HLINE - Object Types - Objects Constants - Constants, Enumerations and Structures - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 
Ich danke Ihnen.
 
Cannot compile hat 4 Fehler
 
merky16 # Cannot compile hat 4 Fehler
Veröffentlicht im Jahr 2018, der Code hat sich seitdem weiterentwickelt. Der Autor kann ihn aktualisieren oder auch nicht, wer weiß.

Haftungsausschluss: Ich nehme an, wie Sie sagten, dass er Fehler enthält; ich habe ihn nicht selbst kompiliert.
 
merky16 #:
Cannot compile hat 4 Fehler

Es gibt keine Kompilierungsfehler