Creating a custom indicator from the value of another indicator, chart points out that something is wrong.
Use "SRC" button to paste programs.
Nobody can confirm the behavior, because there is no "IL_GRIGIO_EFFICIENCY_V4" file.
- When you post code please use the SRC button! Please edit your post.
General rules and best pratices of the Forum. - General - MQL5 programming forum - They are the same. What you see is the difference in scaling. Look at the values in the data window.
Nicola Peluchetti:
The values are the same but not the scale.
I want to use the value of another indicator in my own indicator, but from the indicator window I see that the two lines do not coincide.
...
What am I doing wrong?
Hmm, I wonder why it happen.
#property copyright "Nicola Peluchetti" #property link "https://www.mql5.com" #property version "1.00" #property strict #property indicator_separate_window #property indicator_minimum -101 #property indicator_maximum 101 #property indicator_buffers 2 #property indicator_color1 Blue // Color of the 1st line #property indicator_color2 Red // Color of the 2nd line #property indicator_plots 1 //--- plot Label1 #property indicator_level1 23.6 #property indicator_level2 -23.6 //--- indicator buffers double ER[]; double ERM[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int OnInit() { IndicatorShortName("EFFICIENCY RATIO for Remora"); //--- indicator buffers mapping SetIndexBuffer(0,ER); SetIndexStyle(0, DRAW_LINE,STYLE_SOLID,2); SetIndexLabel(0, "Eff. Ratio Remora"); IndicatorDigits(2); //--- 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[]) { //--- int i, // Bar index Counted_bars; // Number of counted bars //-------------------------------------------------------------------- Counted_bars=IndicatorCounted(); // Number of counted bars i=Bars-Counted_bars-1; // Index of the first uncounted while(i>=0) // Loop for uncounted bars { ER[i]=iCustom(NULL,PERIOD_M1,"IL_GRIGIO_EFFICIENCY_V4",2000,"", 21, 21, 2.0, 0,i);; // Value of 0 buffer on i bar i--; // Calculating index of the next bar } //---------- return(rates_total); }
GrumpyDuckMan:
Because in the original there are no fixed minimum and maximum
Hmm, I wonder why it happen.
It has nothing to do with your code. It's because each is being scaled independently.
Ok cool, thanks everyobody!

You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
I want to use the value of another indicator in my own indicator, but from the indicator window I see that the two lines do not coincide.
As you can see from the image above, the dark blue and light blue lines are similar, but not identical. This is my code:
#property copyright "Nicola Peluchetti"
#property link "https://www.mql5.com"
#property version "1.00"
#property strict
#property indicator_separate_window
#property indicator_minimum -101
#property indicator_maximum 101
#property indicator_buffers 2
#property indicator_color1 Blue // Color of the 1st line
#property indicator_color2 Red // Color of the 2nd line
#property indicator_plots 1
//--- plot Label1
#property indicator_level1 23.6
#property indicator_level2 -23.6
//--- indicator buffers
double ER[];
double ERM[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
IndicatorShortName("EFFICIENCY RATIO for Remora");
//--- indicator buffers mapping
SetIndexBuffer(0,ER);
SetIndexStyle(0, DRAW_LINE,STYLE_SOLID,2);
SetIndexLabel(0, "Eff. Ratio Remora");
IndicatorDigits(2);
//---
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[])
{
//---
int i, // Bar index
Counted_bars; // Number of counted bars
//--------------------------------------------------------------------
Counted_bars=IndicatorCounted(); // Number of counted bars
i=Bars-Counted_bars-1; // Index of the first uncounted
while(i>=0) // Loop for uncounted bars
{
ER[i]=iCustom(NULL,PERIOD_M1,"IL_GRIGIO_EFFICIENCY_V4",2000,"", 21, 21, 2.0, 0,i);; // Value of 0 buffer on i bar
i--; // Calculating index of the next bar
}
//----------
return(rates_total);
}
What am I doing wrong?