Einzelnen Beitrag anzeigen
  #1 (permalink)  
Alt 09.10.22
Nefastus Nefastus ist offline
Mitglied
 
Registriert seit: Jun 2017
Ort: Lyss und Berlin
Beiträge: 31
Nefastus befindet sich auf einem aufstrebenden Ast
Standard Suche Hilfe zur fertig Stellung für mein Indikator

Hallo Leute ich wende mich heute an euch da ich mit meinem begrenzen Wissen in der Programmierung nicht weiter komme^^
Der Indikator soll mir 4 Linien anzeigen Highhest/Lowest und dazwischen 2...
Zur Zeit klappt die anzeige nur im Gold Chart aber nicht bei Währungs Paaren...
Ich würde mich risig freuen wenn ihr mir ein paar Tips geben könnt worauf ich achten soll... anschauliche Beispiele helfen mir beim Lernen und verstehen
ich bedanke mich jetzt schon
Code:
//+----------------------------------------   Mein Linien Grid Indikator   -------------------------------+
//+-------------------------------------------------------------------------------------------------------+
#property strict
#property indicator_chart_window
#property indicator_minimum 0
#property indicator_maximum 100
#property indicator_buffers 4
//+---------------------------------------------------------------------------------   Chart Ausgabe   ---+
//+-------------------------------------------------------------------------------------------------------+
#property indicator_type1 DRAW_LINE
#property indicator_style1 STYLE_SOLID
#property indicator_width1 2
#property indicator_color1 clrOrange
#property indicator_label1 "Obere Linie"
//---
#property indicator_type2 DRAW_LINE
#property indicator_style2 STYLE_DASHDOT
#property indicator_width2 1
#property indicator_color2 clrCrimson
#property indicator_label2 "Oben - Abstand"
//---
#property indicator_type3 DRAW_LINE
#property indicator_style3 STYLE_DASHDOT
#property indicator_width3 1
#property indicator_color3 clrDodgerBlue
#property indicator_label3 "Unten + Abstand"
//---
#property indicator_type4 DRAW_LINE
#property indicator_style4 STYLE_SOLID
#property indicator_width4 2
#property indicator_color4 clrOrange
#property indicator_label4 "Untere Linie"
//+---------------------------------------------------------------------   Globale externe Variablen   ---+
//+-------------------------------------------------------------------------------------------------------+
input int      Perioden =    500;
input double   Prozent  =     30;
//+-----------------------------------------------------------------------------   Globale Variablen   ---+
//+-------------------------------------------------------------------------------------------------------+
double bufferGanzOben[];
double bufferGanzUnten[];
double bufferObenMinAbstand[];
double bufferUntenPlAbstand[];
//+-------------------------------------------------------------------------------   OnInit Funktion   ---+
//+-------------------------------------------------------------------------------------------------------+
int OnInit() {
//--- drawing settings
   SetIndexBuffer(0, bufferGanzOben);
   SetIndexBuffer(1, bufferObenMinAbstand);
   SetIndexBuffer(2, bufferUntenPlAbstand);
   SetIndexBuffer(3, bufferGanzUnten);
//---
   return(INIT_SUCCEEDED);
}
//+--------------------------------------------------------------------------   OnCalculate Funktion   ---+
//+-------------------------------------------------------------------------------------------------------+
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[]) {
//--- last counted bar will be recounted
   int _CandlesOnChart = rates_total - prev_calculated;
   if(prev_calculated > 0) {
      _CandlesOnChart++;
   }
   for(int i = 0; i < _CandlesOnChart; i++) {
//---
      _CandlesOnChart = WindowFirstVisibleBar();
//---
      int _HighestCandle = iHighest(Symbol(), PERIOD_CURRENT, MODE_HIGH, _CandlesOnChart, 0);
      bufferGanzOben[i] = High[_HighestCandle];
      int _LowestCandle = iLowest(Symbol(), PERIOD_CURRENT, MODE_LOW, _CandlesOnChart, 0);
      bufferGanzUnten[i] = Low[_LowestCandle];
//---
      double _Range = (_HighestCandle - _LowestCandle);
      double _EinProz = (_Range / 100);
      double _Prozent = (_EinProz * Prozent);
//---
      int _HighCandle = iHighest(Symbol(), PERIOD_CURRENT, MODE_HIGH, _CandlesOnChart, 0);
      bufferObenMinAbstand[i] = High[_HighCandle] + _Prozent;
      int _LowCandle = iLowest(Symbol(), PERIOD_CURRENT, MODE_LOW, _CandlesOnChart, 0);
      bufferUntenPlAbstand[i] = Low[_LowCandle] - _Prozent;
//---
      string _String = "Highest Value: " + DoubleToString(bufferGanzOben[i], Digits()) + " Lowest Valve:" + DoubleToString(bufferGanzUnten[i], Digits());
      if(ObjectCreate(0, "Display", OBJ_LABEL, 0, 0, 0)) {
         Print("Object NOT Created");
      }
      ObjectSetInteger(0, "Display", OBJPROP_FONTSIZE, 10);
      ObjectSetInteger(0, "Display", OBJPROP_WIDTH, 5);
      ObjectSetInteger(0, "Display", OBJPROP_COLOR, clrOrange);
      ObjectSetInteger(0, "Display", OBJPROP_XDISTANCE, 10);
      ObjectSetInteger(0, "Display", OBJPROP_YDISTANCE, 10);
      ObjectSetString(0, "Display", OBJPROP_TEXT, _String);
   }
   return(rates_total);
}