One of the indicator lines is not visible

 

I am righting a new indicator, i have added 3 line and one color buffer, but one of the lines not showing

The code:

#property indicator_chart_window

#property indicator_buffers 4
#property indicator_plots   3

#property indicator_color1  clrBlue, clrCrimson

input int ma_period = 14;

int maHandle;

double trendData[];
double trendColor[];

double hightest[];
double lowest [];


int OnInit()
  {
  
  maHandle=iMA(_Symbol,_Period,ma_period,0,MODE_SMA,PRICE_CLOSE);
//--- indicator buffers mapping
   SetIndexBuffer(0,trendData,INDICATOR_CALCULATIONS);
   SetIndexBuffer(1,trendColor,INDICATOR_COLOR_INDEX);
   
   SetIndexBuffer(2,hightest,INDICATOR_CALCULATIONS);
   SetIndexBuffer(3,lowest,INDICATOR_CALCULATIONS);

   PlotIndexSetInteger(0,PLOT_DRAW_BEGIN,ma_period);
   PlotIndexSetInteger(0,PLOT_DRAW_TYPE,DRAW_COLOR_SECTION);
   PlotIndexSetString(0,PLOT_LABEL, "Trend");
   PlotIndexSetInteger(0,PLOT_LINE_STYLE,STYLE_SOLID);
   PlotIndexSetInteger(0,PLOT_LINE_WIDTH,1);
   
   PlotIndexSetInteger(2,PLOT_DRAW_BEGIN,ma_period);
   PlotIndexSetInteger(2,PLOT_DRAW_TYPE,DRAW_LINE);
   PlotIndexSetInteger(2,PLOT_LINE_STYLE,STYLE_SOLID);
   PlotIndexSetInteger(2,PLOT_LINE_WIDTH,1);
   PlotIndexSetString(2,PLOT_LABEL, "Highest");
   PlotIndexSetInteger(2, PLOT_LINE_COLOR, clrLimeGreen);
   
   PlotIndexSetInteger(3,PLOT_DRAW_BEGIN,ma_period);
   PlotIndexSetInteger(3,PLOT_DRAW_TYPE,DRAW_LINE);
   PlotIndexSetInteger(3,PLOT_LINE_STYLE,STYLE_SOLID);
   PlotIndexSetInteger(3,PLOT_LINE_WIDTH,1);
   PlotIndexSetString(3,PLOT_LABEL, "Lowest");
   PlotIndexSetInteger(3, PLOT_LINE_COLOR, clrWhite);
   
   return(INIT_SUCCEEDED);
  }

so as you see

index 0 is the colorful trend line

index 1 is the color of the trend line

index 2 is the highest limit (Not visible)

index 3 is the  lowest


what is wrong with this code? see the image: https://charts.mql5.com/36/836/us30-spot-h1-credit-financier-invest-2.png

Documentation on MQL5: Constants, Enumerations and Structures / Indicator Constants / Drawing Styles
Documentation on MQL5: Constants, Enumerations and Structures / Indicator Constants / Drawing Styles
  • www.mql5.com
Drawing Styles - Indicator Constants - Constants, Enumerations and Structures - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 
Mohamad Zbib:

I am righting a new indicator, i have added 3 line and one color buffer, but one of the lines not showing

The code:

so as you see

index 0 is the colorful trend line

index 1 is the color of the trend line

index 2 is the highest limit (Not visible)

index 3 is the  lowest


what is wrong with this code? see the image: https://charts.mql5.com/36/836/us30-spot-h1-credit-financier-invest-2.png

 The plots can go missing depending on how you copy data from the bars with copybuffer, so how are you using CopyBuffer in OnCalculate?

edit - I see you have three lines but only plot_line_color defined for line 2 and 3, I haven't done things this way before so I'm not sure if I can help

this should probably be type DRAW_LINE for starters if it should be a line:
PlotIndexSetInteger(0,PLOT_DRAW_TYPE,DRAW_COLOR_SECTION)
 
Mohamad Zbib:

I am righting a new indicator, i have added 3 line and one color buffer, but one of the lines not showing

The code:

so as you see

index 0 is the colorful trend line

index 1 is the color of the trend line

index 2 is the highest limit (Not visible)

index 3 is the  lowest


what is wrong with this code? see the image: https://charts.mql5.com/36/836/us30-spot-h1-credit-financier-invest-2.png

You are confusing buffers and plots. You have only 3 plots but you are using an index 3 (plot indexes are from 0 to 2).
Reason: