Copybuffer function parameters for the custom indicator currency strength index

 

hello programmers, i created an expert advisor that among other indicators uses the currency strength index indicator to evaluate the final bool buy or sell condition and it seemed to have worked perfectly even showed trades running in the strategy tester but when i took it live no trade was executed, upon doing some digging i found out that the copybuffer function for the currency strength index kept evaluating to "CSM failed, no data" and i can't seem to fix it. i suspect the root of the bug being that most currency strength indicators scales' ,for which i derived the copybuffer function,run from 0 to 100 but the currency strength index runs between -0.01 to 0.01 therefore their copybuffer parameters should differ but i just cant find out how. Here is the part of the error;

      if(CopyBuffer(g_handle, index, 0, 1, strength) != 1)
        {
         Print("CopyBuffer from CSI failed, no data");
        }


      if(MathAbs(strength[0] - EMPTY_VALUE) < 0.0001)
        {
         Print("Currency strength is not ready yet (downloading historical data..)");
        }

Below are the uploaded include file and expert advisor that execute trades and the currency strength index file.


Discover new MetaTrader 5 opportunities with MQL5 community and services
Discover new MetaTrader 5 opportunities with MQL5 community and services
  • 2022.02.05
  • www.mql5.com
MQL5: language of trade strategies built-in the MetaTrader 5 Trading Platform, allows writing your own trading robots, technical indicators, scripts and libraries of functions
 
  1. Please edit your (original) post and use the CODE button (Alt-S)! (For large amounts of code, attach it.)
              General rules and best pratices of the Forum. - General - MQL5 programming forum (2019)
              Messages Editor

  2. Your iCustom call's comments are nonsense.

    Currency_Strength
    My_expert
    
    
    //--- input variables
    input int ma_period_=20;
    input int ma_delta=1;
    input bool ShowEUR=true;
    input bool ShowGBP=false;
    input bool ShowAUD=false;
    input bool ShowNZD=false;
    input bool ShowUSD=false;
    input bool ShowCAD=false;
    input bool ShowCHF=false;
    input bool ShowJPY=true;
    
       g_handle = iCustom(
                     symbol,       // Symbol
                     period,  // Period
                     "CURRENCY_STRENGTH_INDEX",     // Indicat
    20,
    1,
    1, // Latency (Refresh delay in seconds) 0 means every tick
    1, // Log level (Trace = 0, Info = 1, Warning = 2, Error = 3, Critical = 4)
    1, // Candles for calculation
    1, // Candles shift from the beginning
    1, // Use Moving Average smoothing
    1, // Moving Average Period for smoothing
    1, // Moving Average Method for smoothing 
    1  // Auto detect symbols suffix ("Use suffix" should be disabled)
    );
  3.    if(MathAbs(strength[0] - EMPTY_VALUE) < 0.0001)
    Your indicator does not use EMPTY_VALUE, so your if will never be true.
 
Edwin Tempah:

the currency strength index kept evaluating to "CSM failed, no data"

To check: Is the indicator ex5 in a folder where the EA can find it? (this may sound trivial but it tends to happen)

 
Haruto Rat #:

To check: Is the indicator ex5 in a folder where the EA can find it? (this may sound trivial but it tends to happen)

Yeah, the path to the indicator is correct
 
William Roeder #:
  1. Please edit your (original) post and use the CODE button (Alt-S)! (For large amounts of code, attach it.)
              General rules and best pratices of the Forum. - General - MQL5 programming forum (2019)
              Messages Editor

  2. Your iCustom call's comments are nonsense.

    Currency_Strength
    My_expert
  3. Your indicator does not use EMPTY_VALUE, so your if will never be true.
i apologize for my messy work its my first time in this forum, i have checked on the if condition and omitted it and it seemed to work the 'csi has no data' stopped showing in the journal but still no trades are being executed in real time but it doesn't have the same problem in the strategy tester shows clear data, do you have any idea as to this.