iCustom find only one value.

 

Hi guys,

I need your help for an indicator I try to develop.

It is based on the TDI indicator and I try to extract the values of the Upper Band and the Down Band.

THe problem is that it only find one band. If I set the two, it won't work, also for the first Band.

It complies without errors but there is no alert displayed.

If I set only one, I see the alert.

In thz case below it doen't work:

#property copyright "Copyright 2020, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict
#property indicator_chart_window


  double VB_High[];
;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- indicator buffers mapping
SetIndexBuffer(0,VB_High);
SetIndexLabel(0, "VB_High");
SetIndexBuffer(1,VB_Low);
SetIndexLabel(1, "VB_Low");

//---
   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[])
  {
//---
   
   VB_High[1]=iCustom("CADJPY", 15, "TDI_RT","RSI_Period","RSI_Price,Volatility_Band","RSI_Price_Line","RSI_Price_Type","Trade_Signal_Line","Trade_Signal_Type",1,1);
   Alert("The value Up", VB_High[1]);
   
   VB_Low[1]=iCustom("CADJPY", 15, "TDI_RT","RSI_Period","RSI_Price,Volatility_Band","RSI_Price_Line","RSI_Price_Type","Trade_Signal_Line","Trade_Signal_Type",0,1);
   Alert("The value Up", VB_Low[1]); 
   
//--- return value of prev_calculated for next call
   return(rates_total);

The case below works when I disable the lines for the Buffer 1 :


//+------------------------------------------------------------------+
//|                                                        ESSAI.mq4 |
//|                        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 strict
#property indicator_chart_window


  double VB_High[];
;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- indicator buffers mapping
SetIndexBuffer(0,VB_High);
SetIndexLabel(0, "VB_High");
SetIndexBuffer(1,VB_Low);
SetIndexLabel(1, "VB_Low");

//---
   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[])
  {
//---
   
   VB_High[1]=iCustom("CADJPY", 15, "TDI_RT","RSI_Period","RSI_Price,Volatility_Band","RSI_Price_Line","RSI_Price_Type","Trade_Signal_Line","Trade_Signal_Type",1,1);
   Alert("The value Up", VB_High[1]);
   
//   VB_Low[1]=iCustom("CADJPY", 15, "TDI_RT","RSI_Period","RSI_Price,Volatility_Band","RSI_Price_Line","RSI_Price_Type","Trade_Signal_Line","Trade_Signal_Type",0,1);
//   Alert("The value Up", VB_Low[1]); 
   
//--- return value of prev_calculated for next call
   return(rates_total);
  }

Any Idea ?

Thank you

 

The code you've posted is incomplete, so it will make it difficult to debug.

For example, you are using VB_Low[] several times in your code, but it is not declared anywhere.


Don't know why alert is not calling when you are using VB_Low (again, your code is incomplete),

But one wrong thing I can already see is your call to iCustom,

You are passing string literals as inputs, instead of the actual variables.

Besides the symbol name and the custom indicator name, the parenthesis is unnecessary and should be removed from all other inputs.

   VB_High[1]=iCustom("CADJPY", 15, "TDI_RT","RSI_Period","RSI_Price,Volatility_Band","RSI_Price_Line","RSI_Price_Type","Trade_Signal_Line","Trade_Signal_Type",1,1);

should become

   VB_High[1]=iCustom("CADJPY", 15, "TDI_RT",RSI_Period,RSI_Price,Volatility_Band,RSI_Price_Line,RSI_Price_Type,Trade_Signal_Line,Trade_Signal_Type,1,1);
 
AMI289 #:

The code you've posted is incomplete, so it will make it difficult to debug.

For example, you are using VB_Low[] several times in your code, but it is not declared anywhere.


Don't know why alert is not calling when you are using VB_Low (again, your code is incomplete),

But one wrong thing I can already see is your call to iCustom,

You are passing string literals as inputs, instead of the actual variables.

Besides the symbol name and the custom indicator name, the parenthesis is unnecessary and should be removed from all other inputs.

should become

Hello,
Thank you for your Reply.
For VB_Low, it is a mistake when I copied the code.
For the arguments in iCustom, I will replace the strings by the values.

I'll do it tomorrow because I'm working.

Thank you for your Time.
I will update tomorrow.
 

Hello,

The issue was due to the buffers.

I removed them all and it works fine now.

Thank you very much for your help.