iCustom problem

 

Hello,

i have been trying for some time to transfer the buffers of one iCustom Indicator to another. The problem is that the arrows then appear with every candlestick, which is wrong. It seems to be related to the iCustom function, so I think it is a bug on the part of MetaQuotes, but I am not sure. Is there a way to fix the problem?

#property indicator_chart_window
#property indicator_buffers 2
#property indicator_plots 1

#property indicator_label1 "Arrow - Up"
#property indicator_type1 DRAW_ARROW
#property indicator_color1 clrYellow

double UpBuffer[];

double CustomBuffer[];

int Test2;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
{
   SetIndexBuffer(0,UpBuffer,INDICATOR_DATA);
   PlotIndexSetInteger(0,PLOT_ARROW,233);
   SetIndexBuffer(1,CustomBuffer,INDICATOR_CALCULATIONS);
   
   Test2=iCustom(_Symbol,_Period,"Test2");
   if(Test2==INVALID_HANDLE)
   {
      Print("The iCustom object was not created: Error ",GetLastError());
      return INIT_FAILED;
   }
   
   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[])
{
   ArraySetAsSeries(UpBuffer,true);
   ArraySetAsSeries(CustomBuffer,true);
   ArraySetAsSeries(open,true);
   ArraySetAsSeries(close,true);
   ArraySetAsSeries(high,true);
   ArraySetAsSeries(low,true);
   
   int copied=CopyBuffer(Test2,0,0,rates_total,CustomBuffer);
   
   for(int i=0;i<rates_total;i++)
   {
      UpBuffer[i]=EMPTY_VALUE;
      
      if(CustomBuffer[i]>0)
      {
         UpBuffer[i]=low[i];
      }
   }
   
   return(rates_total);
}
//+------------------------------------------------------------------+
 
Pay attention to the correct copy (see examples Technical Indicators) - function bool FillArraysFromBuffers
Documentation on MQL5: Technical Indicators
Documentation on MQL5: Technical Indicators
  • www.mql5.com
All functions like iMA, iAC, iMACD, iIchimoku etc. create a copy of the corresponding technical indicator in the global cache of the client terminal. If a copy of the indicator with such parameters already exists, the new copy is not created, and the counter of references to the existing copy increases. These functions return the handle of the...
 
Hello Arthur,

It seems the condition is always true.
EMPTY_VALUE is not equals to 0.
Also check the indicator buffer's value when it do not have arrow/value it can be 0 or EMPTY_VALUE.
 
Mehdi Donyadideh Ahrab:
Hello Arthur,

It seems the condition is always true.
EMPTY_VALUE is not equals to 0.
Also check the indicator buffer's value when it do not have arrow/value it can be 0 or EMPTY_VALUE.

Thanks, my friend. Once again, you have helped me a lot. I changed EMPTY_VALUE at the iCustom indicator to 0 and it worked. But could it be that there was a change, I always did it with EMPTY_VALUE and it always worked like this. That's why I didn't come up with the idea to change it to 0 this time.

 
How do I activate my profile. Since I got my password straight through Facebook and it is regenerating

Code profiling - Developing programs - MetaEditor Help
Code profiling - Developing programs - MetaEditor Help
  • www.metatrader5.com
Profiling means collecting program parameters during its execution. During a profiling, the execution time and the number of calls of individual functions and program code lines are measured. With this tool, the programmer is able to find and optimize the slowest code sections. Profiling can be performed on the normal chart of the trading...
 
Dejan Dimic:
How do I activate my profile. Since I got my password straight through Facebook and it is regenerating

You can use the following methods -
how to get password
how to get password
how to get password
  • 2020.02.19
  • www.mql5.com
how to get password to change profil after i change something...
Reason: