Einzelnen Beitrag anzeigen
  #1 (permalink)  
Alt 28.11.18
FatSpiderman FatSpiderman ist offline
Neues Mitglied
 
Registriert seit: Dec 2016
Beiträge: 16
FatSpiderman befindet sich auf einem aufstrebenden Ast
Standard Indikator Ein- und Ausblenden

Hallo zusammen,

ich hoffe jemand kann mir helfen.
Ich suche eine Möglichkeit, wie ich meinen Indikator bzw. die Linien ein- und ausblenden kann, ohne ihn neu zu initialisieren.

Code:
//+------------------------------------------------------------------+
//|                                                    ATR Bands.mq4 |
//|                                                     FatSpiderman |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "FatSpiderman"
#property link      "https://www.mql5.com"
#property version   "1.00"
#property description "Indicator plots ATR-Bands on the Chart-Window"
#property strict
#property indicator_chart_window
#property indicator_buffers 10
#property indicator_label1 "ATR Band 1 - upper"
#property indicator_label2 "ATR Band 1 - lower"
#property indicator_label3 "ATR Band 2 - upper"
#property indicator_label4 "ATR Band 2 - lower"
#property indicator_label5 "ATR Band 3 - upper"
#property indicator_label6 "ATR Band 3 - lower"
#property indicator_label7 "ATR Band 4 - upper"
#property indicator_label8 "ATR Band 4 - lower"
#property indicator_label9 "ATR Band 5 - upper"
#property indicator_label10 "ATR Band 5 - lower"

//---- buffers

double ATR_upper_1[];
double ATR_lower_1[];
double ATR_upper_2[];
double ATR_lower_2[];
double ATR_upper_3[];
double ATR_lower_3[];
double ATR_upper_4[];
double ATR_lower_4[];
double ATR_upper_5[];
double ATR_lower_5[];

enum ENUM_LINE_WIDTH {thin = 1,         //1
                      mediumthin = 2,   //2
                      medium = 3,       //3
                      mediumthick = 4,  //4
                      thick =5          //5
                      };

//---- Input Variables

input    string place0 = "-------------------------";             //-------------------------
input    bool ATR_1 = true;                                       //ATR 1
input    int ATR_period_1 = 20;                                   //Period
input    double ATR_multiplier_1 = 1.5;                           //Multiplier
input    int ATR_shift_1 = 0;                                     //Shift
input    ENUM_LINE_STYLE ATR_1_style = 0;                         //Style
input    ENUM_LINE_WIDTH ATR_1_width = 1;                         //Width
input    color ATR_1_COLOR = Blue;                                //Color
input    ENUM_APPLIED_PRICE ATR_price_upper_1 = PRICE_CLOSE;      //Price Upper Band
input    ENUM_APPLIED_PRICE ATR_price_lower_1 = PRICE_CLOSE;      //Price Lower Band
input    ENUM_TIMEFRAMES timeframe_1 = PERIOD_CURRENT;            //Timeframe
input    string place1 = "-------------------------";             //-------------------------
input    bool ATR_2 = false;                                      //ATR 2
input    int ATR_period_2 = 20;                                   //Period
input    double ATR_multiplier_2 = 1.5;                           //Multiplier
input    int ATR_shift_2 = 0;                                     //Shift
input    ENUM_LINE_STYLE ATR_2_style = 0;                         //Style
input    ENUM_LINE_WIDTH ATR_2_width = 1;                         //Width
input    color ATR_2_COLOR = Red;                                 //Color
input    ENUM_APPLIED_PRICE ATR_price_upper_2 = PRICE_HIGH;       //Price Upper Band
input    ENUM_APPLIED_PRICE ATR_price_lower_2 = PRICE_LOW;        //Price Lower Band
input    ENUM_TIMEFRAMES timeframe_2 = PERIOD_CURRENT;            //Timeframe
input    string place2 = "-------------------------";             //-------------------------
input    bool ATR_3 = false;                                      //ATR 3
input    int ATR_period_3 = 20;                                   //Period
input    double ATR_multiplier_3 = 2;                             //Multiplier
input    int ATR_shift_3 = 0;                                     //Shift
input    ENUM_LINE_STYLE ATR_3_style = 0;                         //Style
input    ENUM_LINE_WIDTH ATR_3_width = 1;                         //Width
input    color ATR_3_COLOR = Green;                               //Color
input    ENUM_APPLIED_PRICE ATR_price_upper_3 = PRICE_HIGH;       //Price Upper Band
input    ENUM_APPLIED_PRICE ATR_price_lower_3 = PRICE_LOW;        //Price Lower Band
input    ENUM_TIMEFRAMES timeframe_3 = PERIOD_CURRENT;            //Timeframe
input    string place3 = "-------------------------";             //-------------------------
input    bool ATR_4 = false;                                      //ATR 4
input    int ATR_period_4 = 20;                                   //Period
input    double ATR_multiplier_4 = 2.5;                           //Multiplier
input    int ATR_shift_4 = 0;                                     //Shift
input    ENUM_LINE_STYLE ATR_4_style = 0;                         //Style
input    ENUM_LINE_WIDTH ATR_4_width = 1;                         //Width
input    color ATR_4_COLOR = Yellow;                              //Color
input    ENUM_APPLIED_PRICE ATR_price_upper_4 = PRICE_HIGH;       //Price Upper Band
input    ENUM_APPLIED_PRICE ATR_price_lower_4 = PRICE_LOW;         //Price Lower Band
input    ENUM_TIMEFRAMES timeframe_4 = PERIOD_CURRENT;            //Timeframe
input    string place4 = "-------------------------";             //-------------------------
input    bool ATR_5 = false;                                      //ATR 5
input    int ATR_period_5 = 20;                                   //Period
input    double ATR_multiplier_5 = 3;                             //Multiplier
input    int ATR_shift_5 = 0;                                     //Shift
input    ENUM_LINE_STYLE ATR_5_style = 0;                         //Style
input    ENUM_LINE_WIDTH ATR_5_width = 1;                         //Width
input    color ATR_5_COLOR = Aqua;                                //Color
input    ENUM_APPLIED_PRICE ATR_price_upper_5 = PRICE_HIGH;       //Price Upper Band
input    ENUM_APPLIED_PRICE ATR_price_lower_5 = PRICE_LOW;        //Price Lower Band
input    ENUM_TIMEFRAMES timeframe_5 = PERIOD_CURRENT;            //Timeframe

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- indicator buffers mapping
   SetIndexStyle(0,DRAW_LINE,ATR_1_style,ATR_1_width,ATR_1_COLOR);
   SetIndexBuffer(0,ATR_upper_1);
   SetIndexShift(0, ATR_shift_1);
   SetIndexStyle(1,DRAW_LINE,ATR_1_style,ATR_1_width,ATR_1_COLOR);
   SetIndexBuffer(1,ATR_lower_1);
   SetIndexShift(1, ATR_shift_1);
   SetIndexStyle(2,DRAW_LINE,ATR_2_style,ATR_2_width,ATR_2_COLOR);
   SetIndexBuffer(2,ATR_upper_2);
   SetIndexShift(2, ATR_shift_2);
   SetIndexStyle(3,DRAW_LINE,ATR_2_style,ATR_2_width,ATR_2_COLOR);
   SetIndexBuffer(3,ATR_lower_2);
   SetIndexShift(3, ATR_shift_2);
   SetIndexStyle(4,DRAW_LINE,ATR_3_style,ATR_3_width,ATR_3_COLOR);
   SetIndexBuffer(4,ATR_upper_3);
   SetIndexShift(4, ATR_shift_3);
   SetIndexStyle(5,DRAW_LINE,ATR_3_style,ATR_3_width,ATR_3_COLOR);
   SetIndexBuffer(5,ATR_lower_3);
   SetIndexShift(5, ATR_shift_3);
   SetIndexStyle(6,DRAW_LINE,ATR_4_style,ATR_4_width,ATR_4_COLOR);
   SetIndexBuffer(6,ATR_upper_4);
   SetIndexShift(6, ATR_shift_4);
   SetIndexStyle(7,DRAW_LINE,ATR_4_style,ATR_4_width,ATR_4_COLOR);
   SetIndexBuffer(7,ATR_lower_4);
   SetIndexShift(7, ATR_shift_4);
   SetIndexStyle(8,DRAW_LINE,ATR_5_style,ATR_5_width,ATR_5_COLOR);
   SetIndexBuffer(8,ATR_upper_5);
   SetIndexShift(8, ATR_shift_5);
   SetIndexStyle(9,DRAW_LINE,ATR_5_style,ATR_5_width,ATR_5_COLOR);
   SetIndexBuffer(9,ATR_lower_5);
   SetIndexShift(9, ATR_shift_5);
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
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[])
  {   
            
      if (ATR_1)
      {
      CalculatePriceBuffer(timeframe_1, ATR_period_1, ATR_multiplier_1, ATR_price_upper_1, ATR_price_lower_1, rates_total, prev_calculated, ATR_upper_1, ATR_lower_1);    
      }
      
      if (ATR_2)
      {     
      CalculatePriceBuffer(timeframe_2, ATR_period_2, ATR_multiplier_2, ATR_price_upper_2, ATR_price_lower_2, rates_total, prev_calculated, ATR_upper_2, ATR_lower_2);
      }
      
      if (ATR_3)
      {
      CalculatePriceBuffer(timeframe_3, ATR_period_3, ATR_multiplier_3, ATR_price_upper_3, ATR_price_lower_3, rates_total, prev_calculated, ATR_upper_3, ATR_lower_3);
      }
      
      if (ATR_4)
      {
      CalculatePriceBuffer(timeframe_4, ATR_period_4, ATR_multiplier_4, ATR_price_upper_4, ATR_price_lower_4, rates_total, prev_calculated, ATR_upper_4, ATR_lower_4);
      }
      
      if (ATR_5)
      {
      CalculatePriceBuffer(timeframe_5, ATR_period_5, ATR_multiplier_5, ATR_price_upper_5, ATR_price_lower_5, rates_total, prev_calculated, ATR_upper_5, ATR_lower_5);
      }
   
   return(rates_total);
  }
//+------------------------------------------------------------------+

//+------------------------------------------------------------------+
//| Calculates applied price to PriceBuffer[]                        |
//+------------------------------------------------------------------+

int CalculatePriceBuffer(int p_timeframe,
                         int p_ATR_period,
                         double p_ATR_multiplier,
                         const int p_applied_price_upper,            // price type
                         const int p_applied_price_lower,
                         const int rates_total,                      // rates total
                         const int prev_calculated,                  // bars, calculated at previous call
                         double &Price_upper[],                      // target array
                         double &Price_lower[]
                        )
  {
   
//---
   if (rates_total < p_ATR_period)
      return (0);
      
   int bars = rates_total - p_ATR_period;
         
   if (prev_calculated > 0)
      bars = rates_total - prev_calculated - 1;
      
   double atr_tmp = 0;   
      
//---
   for(int i = bars; i >= 0; i--)
      {
      atr_tmp = iATR(Symbol(),p_timeframe,p_ATR_period, i) * p_ATR_multiplier;
      
      //printf("atr_tmp = %f", atr_tmp);
      //printf("i = %d", i);
      
      switch(p_applied_price_upper)
        {
         case PRICE_CLOSE:    Price_upper[i]=Close[i] + atr_tmp; break;
         case PRICE_OPEN:     Price_upper[i]=Open[i] + atr_tmp;  break;
         case PRICE_HIGH:     Price_upper[i]=High[i] + atr_tmp;  break;
         case PRICE_LOW:      Price_upper[i]=Low[i] + atr_tmp;   break;
         case PRICE_MEDIAN:   Price_upper[i]=(High[i]+Low[i])/2.0 + atr_tmp; break;
         case PRICE_TYPICAL:  Price_upper[i]=(High[i]+Low[i]+Close[i])/3.0 + atr_tmp; break;
         case PRICE_WEIGHTED: Price_upper[i]=(High[i]+Low[i]+Close[i]+Close[i])/4.0 + atr_tmp; break;
         default:             Price_upper[i]=0.0; break;
        }
      switch(p_applied_price_lower)
        {
         case PRICE_CLOSE:    Price_lower[i]=Close[i] - atr_tmp; break;
         case PRICE_OPEN:     Price_lower[i]=Open[i] - atr_tmp;  break;
         case PRICE_HIGH:     Price_lower[i]=High[i] - atr_tmp;  break;
         case PRICE_LOW:      Price_lower[i]=Low[i] - atr_tmp;   break;
         case PRICE_MEDIAN:   Price_lower[i]=(High[i]+Low[i])/2.0 - atr_tmp; break;
         case PRICE_TYPICAL:  Price_lower[i]=(High[i]+Low[i]+Close[i])/3.0 - atr_tmp; break;
         case PRICE_WEIGHTED: Price_lower[i]=(High[i]+Low[i]+Close[i]+Close[i])/4.0 - atr_tmp; break;
         default:             Price_lower[i]=0.0; break;
        }  
        
        
      }
//---
    return(rates_total);
  }



Wenn die Einstellung auf "true" gestellt ist, werden die Indikatorlinien gezeichnet. Wird allerdings auf "false" umgestellt, bleiben die Linie erhalten, bis der Indikator neu initialisiert wird.

Ich habe versucht das ganze abzuändern und versucht die Linien mit "PLOT_DRAW_TYPE" auszublenden. Irgendwie hänge ich jetzt aber gerade und komme nicht weiter.


Code:
//+------------------------------------------------------------------+
//|                                                    ATR Bands.mq4 |
//|                                                     Fatspiderman |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "FatSpiderman"
#property link      "https://www.mql5.com"
#property version   "1.00"
#property description "Indicator plots ATR-Bands on the Chart-Window"
#property strict
#property indicator_chart_window
#property indicator_buffers 10
#property indicator_label1 "ATR Band 1 - upper"
#property indicator_label2 "ATR Band 1 - lower"
#property indicator_label3 "ATR Band 2 - upper"
#property indicator_label4 "ATR Band 2 - lower"
#property indicator_label5 "ATR Band 3 - upper"
#property indicator_label6 "ATR Band 3 - lower"
#property indicator_label7 "ATR Band 4 - upper"
#property indicator_label8 "ATR Band 4 - lower"
#property indicator_label9 "ATR Band 5 - upper"
#property indicator_label10 "ATR Band 5 - lower"

//---- buffers

double ATR_upper_1[];
double ATR_lower_1[];
double ATR_upper_2[];
double ATR_lower_2[];
double ATR_upper_3[];
double ATR_lower_3[];
double ATR_upper_4[];
double ATR_lower_4[];
double ATR_upper_5[];
double ATR_lower_5[];

enum ENUM_LINE_WIDTH {thin = 1,         //1
                      mediumthin = 2,   //2
                      medium = 3,       //3
                      mediumthick = 4,  //4
                      thick =5          //5
                      };

//---- Input Variables

input    string place0 = "-------------------------";             //-------------------------
input    bool ATR_1 = false;                                       //ATR 1
input    int ATR_period_1 = 20;                                   //Period
input    double ATR_multiplier_1 = 1.5;                           //Multiplier
input    int ATR_shift_1 = 0;                                     //Shift
input    ENUM_LINE_STYLE ATR_1_style = 0;                         //Style
input    ENUM_LINE_WIDTH ATR_1_width = 1;                         //Width
input    color ATR_1_COLOR = Blue;                                //Color
input    ENUM_APPLIED_PRICE ATR_price_upper_1 = PRICE_CLOSE;      //Price Upper Band
input    ENUM_APPLIED_PRICE ATR_price_lower_1 = PRICE_CLOSE;      //Price Lower Band
input    ENUM_TIMEFRAMES timeframe_1 = PERIOD_CURRENT;            //Timeframe
input    string place1 = "-------------------------";             //-------------------------
input    bool ATR_2 = false;                                       //ATR 2
input    int ATR_period_2 = 20;                                   //Period
input    double ATR_multiplier_2 = 1.5;                           //Multiplier
input    int ATR_shift_2 = 0;                                     //Shift
input    ENUM_LINE_STYLE ATR_2_style = 0;                         //Style
input    ENUM_LINE_WIDTH ATR_2_width = 1;                         //Width
input    color ATR_2_COLOR = Red;                                 //Color
input    ENUM_APPLIED_PRICE ATR_price_upper_2 = PRICE_HIGH;       //Price Upper Band
input    ENUM_APPLIED_PRICE ATR_price_lower_2 = PRICE_LOW;        //Price Lower Band
input    ENUM_TIMEFRAMES timeframe_2 = PERIOD_CURRENT;            //Timeframe
input    string place2 = "-------------------------";             //-------------------------
input    bool ATR_3 = false;                                      //ATR 3
input    int ATR_period_3 = 20;                                   //Period
input    double ATR_multiplier_3 = 2;                             //Multiplier
input    int ATR_shift_3 = 0;                                     //Shift
input    ENUM_LINE_STYLE ATR_3_style = 0;                         //Style
input    ENUM_LINE_WIDTH ATR_3_width = 1;                         //Width
input    color ATR_3_COLOR = Green;                               //Color
input    ENUM_APPLIED_PRICE ATR_price_upper_3 = PRICE_HIGH;       //Price Upper Band
input    ENUM_APPLIED_PRICE ATR_price_lower_3 = PRICE_LOW;        //Price Lower Band
input    ENUM_TIMEFRAMES timeframe_3 = PERIOD_CURRENT;            //Timeframe
input    string place3 = "-------------------------";             //-------------------------
input    bool ATR_4 = false;                                      //ATR 4
input    int ATR_period_4 = 20;                                   //Period
input    double ATR_multiplier_4 = 2.5;                           //Multiplier
input    int ATR_shift_4 = 0;                                     //Shift
input    ENUM_LINE_STYLE ATR_4_style = 0;                         //Style
input    ENUM_LINE_WIDTH ATR_4_width = 1;                         //Width
input    color ATR_4_COLOR = Yellow;                              //Color
input    ENUM_APPLIED_PRICE ATR_price_upper_4 = PRICE_HIGH;       //Price Upper Band
input    ENUM_APPLIED_PRICE ATR_price_lower_4 = PRICE_LOW;         //Price Lower Band
input    ENUM_TIMEFRAMES timeframe_4 = PERIOD_CURRENT;            //Timeframe
input    string place4 = "-------------------------";             //-------------------------
input    bool ATR_5 = false;                                      //ATR 5
input    int ATR_period_5 = 20;                                   //Period
input    double ATR_multiplier_5 = 3;                             //Multiplier
input    int ATR_shift_5 = 0;                                     //Shift
input    ENUM_LINE_STYLE ATR_5_style = 0;                         //Style
input    ENUM_LINE_WIDTH ATR_5_width = 1;                         //Width
input    color ATR_5_COLOR = Aqua;                                //Color
input    ENUM_APPLIED_PRICE ATR_price_upper_5 = PRICE_HIGH;       //Price Upper Band
input    ENUM_APPLIED_PRICE ATR_price_lower_5 = PRICE_LOW;        //Price Lower Band
input    ENUM_TIMEFRAMES timeframe_5 = PERIOD_CURRENT;            //Timeframe

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- indicator buffers mapping
   /*
   SetIndexStyle(0,DRAW_LINE,ATR_1_style,ATR_1_width,ATR_1_COLOR);
   SetIndexBuffer(0,ATR_upper_1);
   SetIndexShift(0, ATR_shift_1);
   SetIndexStyle(1,DRAW_LINE,ATR_1_style,ATR_1_width,ATR_1_COLOR);
   SetIndexBuffer(1,ATR_lower_1);
   SetIndexShift(1, ATR_shift_1);
   SetIndexStyle(2,DRAW_LINE,ATR_2_style,ATR_2_width,ATR_2_COLOR);
   SetIndexBuffer(2,ATR_upper_2);
   SetIndexShift(2, ATR_shift_2);
   SetIndexStyle(3,DRAW_LINE,ATR_2_style,ATR_2_width,ATR_2_COLOR);
   SetIndexBuffer(3,ATR_lower_2);
   SetIndexShift(3, ATR_shift_2);
   SetIndexStyle(4,DRAW_LINE,ATR_3_style,ATR_3_width,ATR_3_COLOR);
   SetIndexBuffer(4,ATR_upper_3);
   SetIndexShift(4, ATR_shift_3);
   SetIndexStyle(5,DRAW_LINE,ATR_3_style,ATR_3_width,ATR_3_COLOR);
   SetIndexBuffer(5,ATR_lower_3);
   SetIndexShift(5, ATR_shift_3);
   SetIndexStyle(6,DRAW_LINE,ATR_4_style,ATR_4_width,ATR_4_COLOR);
   SetIndexBuffer(6,ATR_upper_4);
   SetIndexShift(6, ATR_shift_4);
   SetIndexStyle(7,DRAW_LINE,ATR_4_style,ATR_4_width,ATR_4_COLOR);
   SetIndexBuffer(7,ATR_lower_4);
   SetIndexShift(7, ATR_shift_4);
   SetIndexStyle(8,DRAW_LINE,ATR_5_style,ATR_5_width,ATR_5_COLOR);
   SetIndexBuffer(8,ATR_upper_5);
   SetIndexShift(8, ATR_shift_5);
   SetIndexStyle(9,DRAW_LINE,ATR_5_style,ATR_5_width,ATR_5_COLOR);
   SetIndexBuffer(9,ATR_lower_5);
   SetIndexShift(9, ATR_shift_5);
   */
   SetIndexBuffer(0, ATR_upper_1, INDICATOR_DATA);
   SetIndexBuffer(1, ATR_lower_1, INDICATOR_DATA);
   SetIndexBuffer(2, ATR_upper_2, INDICATOR_DATA);
   SetIndexBuffer(3, ATR_lower_2, INDICATOR_DATA);
   SetIndexBuffer(4, ATR_upper_3, INDICATOR_DATA);
   SetIndexBuffer(5, ATR_lower_3, INDICATOR_DATA);
   SetIndexBuffer(6, ATR_upper_4, INDICATOR_DATA);
   SetIndexBuffer(7, ATR_lower_4, INDICATOR_DATA);
   SetIndexBuffer(8, ATR_upper_5, INDICATOR_DATA);
   SetIndexBuffer(9, ATR_lower_5, INDICATOR_DATA);
   
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
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[])
  {   
            
   // if (ATR_1)
   // {
      CalculatePriceBuffer(timeframe_1, ATR_period_1, ATR_multiplier_1, ATR_price_upper_1, ATR_price_lower_1, rates_total, prev_calculated, ATR_upper_1, ATR_lower_1);    
   // }
      
   // if (ATR_2)
   // {     
      CalculatePriceBuffer(timeframe_2, ATR_period_2, ATR_multiplier_2, ATR_price_upper_2, ATR_price_lower_2, rates_total, prev_calculated, ATR_upper_2, ATR_lower_2);
   // }
      
   // if (ATR_3)
   // {
      CalculatePriceBuffer(timeframe_3, ATR_period_3, ATR_multiplier_3, ATR_price_upper_3, ATR_price_lower_3, rates_total, prev_calculated, ATR_upper_3, ATR_lower_3);
   // }
      
   // if (ATR_4)
   // {
      CalculatePriceBuffer(timeframe_4, ATR_period_4, ATR_multiplier_4, ATR_price_upper_4, ATR_price_lower_4, rates_total, prev_calculated, ATR_upper_4, ATR_lower_4);
   // }
      
   // if (ATR_5)
   // {
      CalculatePriceBuffer(timeframe_5, ATR_period_5, ATR_multiplier_5, ATR_price_upper_5, ATR_price_lower_5, rates_total, prev_calculated, ATR_upper_5, ATR_lower_5);
   // }
      
      if (ATR_1 == true)
      {
         PlotIndexSetInteger(0,PLOT_DRAW_TYPE,DRAW_LINE);
         PlotIndexSetInteger(1,PLOT_DRAW_TYPE,DRAW_LINE);
      }
      else
      {
         PlotIndexSetInteger(0,PLOT_DRAW_TYPE,DRAW_NONE);
         PlotIndexSetInteger(1,PLOT_DRAW_TYPE,DRAW_NONE);
      }
      
      if (ATR_2 == true)
      {
         PlotIndexSetInteger(2,PLOT_DRAW_TYPE,DRAW_LINE);
         PlotIndexSetInteger(3,PLOT_DRAW_TYPE,DRAW_LINE);
      }
      else
      {
         PlotIndexSetInteger(2,PLOT_DRAW_TYPE,DRAW_NONE);
         PlotIndexSetInteger(3,PLOT_DRAW_TYPE,DRAW_NONE);
      }
      if (ATR_3 == true)
      {
         PlotIndexSetInteger(4,PLOT_DRAW_TYPE,DRAW_LINE);
         PlotIndexSetInteger(5,PLOT_DRAW_TYPE,DRAW_LINE);
      }
      else
      {
         PlotIndexSetInteger(4,PLOT_DRAW_TYPE,DRAW_NONE);
         PlotIndexSetInteger(5,PLOT_DRAW_TYPE,DRAW_NONE);
      }
      if (ATR_4 == true)
      {
         PlotIndexSetInteger(6,PLOT_DRAW_TYPE,DRAW_LINE);
         PlotIndexSetInteger(7,PLOT_DRAW_TYPE,DRAW_LINE);
      }
      else
      {
         PlotIndexSetInteger(6,PLOT_DRAW_TYPE,DRAW_NONE);
         PlotIndexSetInteger(7,PLOT_DRAW_TYPE,DRAW_NONE);
      }
      if (ATR_5 == true)
      {
         PlotIndexSetInteger(8,PLOT_DRAW_TYPE,DRAW_LINE);
         PlotIndexSetInteger(9,PLOT_DRAW_TYPE,DRAW_LINE);
      }
      else
      {
         PlotIndexSetInteger(8,PLOT_DRAW_TYPE,DRAW_NONE);
         PlotIndexSetInteger(9,PLOT_DRAW_TYPE,DRAW_NONE);
      }
      
   
   return(rates_total);
  }
//+------------------------------------------------------------------+

//+------------------------------------------------------------------+
//| Calculates applied price to PriceBuffer[]                        |
//+------------------------------------------------------------------+

int CalculatePriceBuffer(
                         int p_timeframe,
                         int p_ATR_period,
                         double p_ATR_multiplier,
                         const int p_applied_price_upper,            // price type
                         const int p_applied_price_lower,
                         const int rates_total,                      // rates total
                         const int prev_calculated,                  // bars, calculated at previous call
                         double &Price_upper[],                      // target array
                         double &Price_lower[]
                        )
  {
   
//---
   if (rates_total < p_ATR_period)
      return (0);
      
   int bars = rates_total - p_ATR_period;
         
   if (prev_calculated > 0)
      bars = rates_total - prev_calculated - 1;
      
   double atr_tmp = 0;   
      
//---
   for(int i = bars; i >= 0; i--)
      {
      atr_tmp = iATR(Symbol(),p_timeframe,p_ATR_period, i) * p_ATR_multiplier;
      
      //printf("atr_tmp = %f", atr_tmp);
      //printf("i = %d", i);
      
      switch(p_applied_price_upper)
        {
         case PRICE_CLOSE:    Price_upper[i]=Close[i] + atr_tmp; break;
         case PRICE_OPEN:     Price_upper[i]=Open[i] + atr_tmp;  break;
         case PRICE_HIGH:     Price_upper[i]=High[i] + atr_tmp;  break;
         case PRICE_LOW:      Price_upper[i]=Low[i] + atr_tmp;   break;
         case PRICE_MEDIAN:   Price_upper[i]=(High[i]+Low[i])/2.0 + atr_tmp; break;
         case PRICE_TYPICAL:  Price_upper[i]=(High[i]+Low[i]+Close[i])/3.0 + atr_tmp; break;
         case PRICE_WEIGHTED: Price_upper[i]=(High[i]+Low[i]+Close[i]+Close[i])/4.0 + atr_tmp; break;
         default:             Price_upper[i]=0.0; break;
        }
      switch(p_applied_price_lower)
        {
         case PRICE_CLOSE:    Price_lower[i]=Close[i] - atr_tmp; break;
         case PRICE_OPEN:     Price_lower[i]=Open[i] - atr_tmp;  break;
         case PRICE_HIGH:     Price_lower[i]=High[i] - atr_tmp;  break;
         case PRICE_LOW:      Price_lower[i]=Low[i] - atr_tmp;   break;
         case PRICE_MEDIAN:   Price_lower[i]=(High[i]+Low[i])/2.0 - atr_tmp; break;
         case PRICE_TYPICAL:  Price_lower[i]=(High[i]+Low[i]+Close[i])/3.0 - atr_tmp; break;
         case PRICE_WEIGHTED: Price_lower[i]=(High[i]+Low[i]+Close[i]+Close[i])/4.0 - atr_tmp; break;
         default:             Price_lower[i]=0.0; break;
        }  
      }
     
      
      
//---
    return(rates_total);
  }

Für jegliche Hilfestellung wäre ich sehr dankbar.
Angehängte Grafiken
Dateityp: png 28-11-_2018_19-11-01.png (122,6 KB, 134x aufgerufen)