icustom and copybuffer problem

 

Hi every one.

pls help me im tired of this.

this is a simple code that only use icustome and copybuffer to get value of rsi

the problem is:

when Chart Time frame is different from TF you set on icustom it returns -1;

i test it with many indicators its the same

i set PERIOD_D1 to icustom. CopyBuffer only return value if Chart time frame is D1. else it returns -1;

What does it means? how it possible?

PLEASE HELP ME.


#property version   "1.00"

#property indicator_chart_window

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

//| Custom indicator initialization function                         |

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

int OnInit()

  {

//--- indicator buffers mapping

   

//---

   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 rshndle = iCustom(Symbol(),PERIOD_D1,"RSI");

   double dd[];

   Print(CopyBuffer(rshndle,0,0,1,dd));

   Print(dd[0]);

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

   return(rates_total);

  }


 

Perhaps you should read the manual, especially the examples.
   How To Ask Questions The Smart Way. 2004
      How To Interpret Answers.
         RTFM and STFW: How To Tell You've Seriously Screwed Up.

They all (including iCustom) return a handle (an int). You get that in OnInit. In OnTick (after the indicator has updated its buffers,) you use the handle, shift and count to get the data.
          Technical Indicators - Reference on algorithmic/automated trading language for MetaTrader 5
          Timeseries and Indicators Access / CopyBuffer - Reference on algorithmic/automated trading language for MetaTrader 5
          How to start with MQL5 - General - MQL5 programming forum - Page 3 #22 2020.03.08
          How to start with MQL5 - MetaTrader 5 - General - MQL5 programming forum - Page 7 #61 2020.07.05
          How to call indicators in MQL5 - MQL5 Articles 12 March 2010
 
William Roeder:

Perhaps you should read the manual, especially the examples.
   How To Ask Questions The Smart Way. 2004
      How To Interpret Answers.
         RTFM and STFW: How To Tell You've Seriously Screwed Up.

They all (including iCustom) return a handle (an int). You get that in OnInit. In OnTick (after the indicator has updated its buffers,) you use the handle, shift and count to get the data.
          Technical Indicators - Reference on algorithmic/automated trading language for MetaTrader 5
          Timeseries and Indicators Access / CopyBuffer - Reference on algorithmic/automated trading language for MetaTrader 5
          How to start with MQL5 - General - MQL5 programming forum - Page 3 #22 2020.03.08
          How to start with MQL5 - MetaTrader 5 - General - MQL5 programming forum - Page 7 #61 2020.07.05
          How to call indicators in MQL5 - MQL5 Articles 12 March 2010

tnx for answer.

but how about offline chart after market close?

ontick dont work on closed market and i need to load data on specific TF while chart TF is different.

i.e im in H1 chart and i need RSI D1 value.

 

It is the same problem i have

I can't find one method (if exists) to get a buffer of one indicator into other indicator, if the first one is in different PERIOD.

In fact, in the second entry OnCalculate, when prev_calculated !=0, CopyBuffer returns the number of Bars copied in PERIOD_D1, but all data copied in Buffer are erroneus.

It'is not a problem using a EA, 

Somebody now how to do? or if its possible to copy in a indicator data of other indicator in different PERIOD?

Thanks

 
thWilliam Roeder #:

Perhaps you should read the manual, especially the examples.
   How To Ask Questions The Smart Way. 2004
      How To Interpret Answers.
         RTFM and STFW: How To Tell You've Seriously Screwed Up.

They all (including iCustom) return a handle (an int). You get that in OnInit. In OnTick (after the indicator has updated its buffers,) you use the handle, shift and count to get the data.
          Technical Indicators - Reference on algorithmic/automated trading language for MetaTrader 5
          Timeseries and Indicators Access / CopyBuffer - Reference on algorithmic/automated trading language for MetaTrader 5
          How to start with MQL5 - General - MQL5 programming forum - Page 3 #22 2020.03.08
          How to start with MQL5 - MetaTrader 5 - General - MQL5 programming forum - Page 7 #61 2020.07.05
          How to call indicators in MQL5 - MQL5 Articles 12 March 2010
thanks