Input Variables = Zero

 

Hi!
I'm really new to MQL5, so sorry for the question. I'm writing the code below, just to get started, but the indicators are returning zero (when they should return 10 and 25). What am I doingo wrong, please?

//+------------------------------------------------------------------+

//|                                                          BHM.mq5 |

//|                        Copyright 2020, MetaQuotes Software Corp. |

//|                                             https://www.mql5.com |

//+------------------------------------------------------------------+

#property copyright "Copyright 2020, MetaQuotes Software Corp."

#property link      "https://www.mql5.com"

#property version   "1.00"

#property indicator_separate_window

#property indicator_buffers 2

#property indicator_plots   2

//--- plot MaxV

#property indicator_label1  "MaxV"

#property indicator_type1   DRAW_LINE

#property indicator_color1  clrRed

#property indicator_style1  STYLE_SOLID

#property indicator_width1  1

//--- plot AvgMaxV

#property indicator_label2  "AvgMaxV"

#property indicator_type2   DRAW_LINE

#property indicator_color2  clrBlue

#property indicator_style2  STYLE_SOLID

#property indicator_width2  1

//--- input parameters

input int   nMaxV=10;

input int   nAvgMaxV=25;

//--- indicator buffers

double         MaxVBuffer[];

double         AvgMaxVBuffer[];

//+------------------------------------------------------------------+

//| Custom indicator initialization function                         |

//+------------------------------------------------------------------+

int OnInit()

  {

//--- indicator buffers mapping

   SetIndexBuffer(0,MaxVBuffer,INDICATOR_DATA);

   SetIndexBuffer(1,AvgMaxVBuffer,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[])

  {

//---


      MaxVBuffer[i]=nMaxV;

      AvgMaxVBuffer[i]=nAvgMaxV;


//--- return value of prev_calculated for next call

   return(rates_total);

  }

Discover new MetaTrader 5 opportunities with MQL5 community and services
Discover new MetaTrader 5 opportunities with MQL5 community and services
  • www.mql5.com
Dozens of new automated trading applications appear in the MQL5 Market every day. Choose the right app among 10,000 products and forget about unnecessary routine operations of manual trading. Sell your algorithmic trading programs through the largest store of trading applications! One Click Close The script allows users to easily close...
 
Please edit your post and
use the code button (Alt+S) when pasting code
 
Bhm Options: , but the indicators are returning zero (
  1. Use SRC
  2. Post code that compiles. You have no variable i.