draw histogram in seprated window

 

i want to show pivots in histogram in seperated window.i  want it shows only  recent 100 candles.but it doesnt show anythinh

#property indicator_separate_window
#property indicator_minimum 0.0
#property indicator_maximum 100.0
#property indicator_buffers 1
#property indicator_color1 Yellow

#property indicator_type1         DRAW_LINE

double  Line[2000];

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int init()
  {

   SetIndexBuffer(1,Line,INDICATOR_DATA);


//--- indexes draw begin settings

   return (0);
  }

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int deinit()
  {
   return (0);
  }

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const int begin,
                const double &price[])
  {

   for(int i =100; i >= 0; i--)
     {
      double mid= iHigh(NULL, Period(), i) + iLow(NULL, Period(), i) + iClose(NULL, Period(), i);


      Line[i] = mid;

     }
   return (0);
  }
//+------------------------------------------------------------------+
 
Your topic has been moved to the section: Technical Indicators
Please consider which section is most appropriate — https://www.mql5.com/en/forum/172166/page6#comment_49114893
 
Mostafa Kian:i want to show pivots in histogram in seperated window.i  want it shows only  recent 100 candles.but it doesnt show anythinh

You are mixing MQL4 and MQL5 code. "init()" and "deinit()" are an old MQL4 event handlers. Use "OnInit()" and "OnDeinit()" instead.

Also, on MQL5 the "OnCalculate()" parameters are treated as normal arrays and not as "series" arrays like in MQL4.

If you are going to use the OHLC values, then use the second version of the OnCalculate and access the data directly from the parameters.

int  OnCalculate(
   const int        rates_total,       // size of input time series
   const int        prev_calculated,   // number of handled bars at the previous call
   const datetime&  time{},            // Time array
   const double&    open[],            // Open array
   const double&    high[],            // High array
   const double&    low[],             // Low array
   const double&    close[],           // Close array
   const long&      tick_volume[],     // Tick Volume array
   const long&      volume[],          // Real Volume array
   const int&       spread[]           // Spread array
   );

Is this perhaps ChatGPT generated code? If it is then please, don't request help for ChatGPT (or other A.I.) generated code. It generates horrible code, mixing MQL4 and MQL5. Please use the Freelance section for such requests — https://www.mql5.com/en/job

Trading applications for MetaTrader 5 to order
Trading applications for MetaTrader 5 to order
  • 2023.10.20
  • www.mql5.com
The largest freelance service with MQL5 application developers
 
Fernando Carreiro #:

You are mixing MQL4 and MQL5 code. "init()" and "deinit()" are an old MQL4 event handlers. Use "OnInit()" and "OnDeinit()" instead.

Also, on MQL5 the "OnCalculate()" parameters are treated as normal arrays and not as "series" arrays like in MQL4.

If you are going to use the OHLC values, then use the second version of the OnCalculate and access the data directly from the parameters.

Is this perhaps ChatGPT generated code? If it is then please, don't request help for ChatGPT (or other A.I.) generated code. It generates horrible code, mixing MQL4 and MQL5. Please use the Freelance section for such requests — https://www.mql5.com/en/job

hi thanks no i dont use chatgpt i have this  in meta4 and i want to convert it to mql5. i did changes but it doesnt work again

#property indicator_separate_window
#property indicator_minimum 0.0
#property indicator_maximum 100.0
#property indicator_buffers 1
#property indicator_color1 Yellow


#property indicator_type1         DRAW_LINE




double  Line[2000];






//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int OnInit()
  {




   SetIndexBuffer(1,Line,INDICATOR_DATA);


//--- indexes draw begin settings

   return (0);
  }

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int OnDeinit()
  {
   return (0);
  }

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int OnCalculate(
   const int        rates_total,       // size of input time series
   const int        prev_calculated,   // number of handled bars at the previous call
   const datetime&  time[],            // Time array
   const double&    open[],            // Open array
   const double&    high[],            // High array
   const double&    low[],             // Low array
   const double&    close[],           // Close array
   const long&      tick_volume[],     // Tick Volume array
   const long&      volume[],          // Real Volume array
   const int&       spread[]           // Spread array
   )
  {

   for(int i =199; i >= 0; i--)
     {
      double mid= iHigh(NULL, Period(), i) + iLow(NULL, Period(), i) + iClose(NULL, Period(), i);


      Line[i] = mid;



     }
   return (0);
  }
//+------------------------------------------------------------------+
Reason: