How to extract value using iCustom

 

Good day,

Suppose my first indicator is as follows

//+------------------------------------------------------------------+
//|                                                         One.mq4 |
//|                        Copyright 2022, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2022, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict
#property indicator_chart_window
#property indicator_buffers 2
#property script_show_inputs

input int ii_MAPeriod = 17;
double iValue=0;

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
//---
   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[])
  {
//---
double MA1=iMA(_Symbol,PERIOD_CURRENT,ii_MAPeriod,0,MODE_SMA,PRICE_CLOSE,0);
double MA2=iMA(_Symbol,PERIOD_CURRENT,ii_MAPeriod,0,MODE_SMA,PRICE_CLOSE,1);
iValue = MA2-MA1;     
//--- return value of prev_calculated for next call
   return(rates_total);
  }
//+------------------------------------------------------------------+


I want to use the value of iValue in an EA to check whether it's below or above certain value. How to do that?

I have tried this on my EA but didn't work

double iValue=iCustom(_Symbol,PERIOD_CURRENT,"One",17,0,0);
if(iValue>0.001){//do it here}

Please advise

 
matrixyb: Please advise

iCustom reads buffers. Your posted code has none.

Reason: