iCustom indicator call strange behavior in value result

 

Hello guys, i am going crazy with a strange issue using iCustom call to have value result from this mq4 indicator https://www.mql5.com/en/code/7376

Code is really simple and it works fine if, for example, in backtest i execute code with a different symbol from where i call iCustom.


I give you an example:

   double mom_eurusd = iCustom("EURUSD", 0, "TSI", 0, 1);
   printf(mom_eurusd);
   double mom_eurgbp = iCustom("EURGBP", 0, "TSI", 0, 1);


If i run this code in backtest from any Symbol, value is right and the same of the chart indicator;   but if i run this code in backtest using EURUSD (so the same pair where i ask value) symbol value is totally wrong (printf give for example 99.99999994458949).



Issue happen with others symbols too.

If i try to get value from symbol that is not running in backtest is all fine but if i want the same value of Symbol of backtest it does not work.


Can sameone help me?

Thanks in advance.

TSI
TSI
  • www.mql5.com
True Strength Index (TSI) is a double-smoothed Momentum. TSI follows the bars with little or hardly noticeable delay in the main and intermediate trend reversal points.
 
Your topic has been moved to the section: MQL4 and MetaTrader 4
Please consider which section is most appropriate — https://www.mql5.com/en/forum/172166/page6#comment_49114893
 
Mirco #:

Hello, thank you to move it in the right place.


Anyone find a solution to my issue?

Thanks in advance!

The calling structure for iCustom is: 

double iCustom(

    string symbol, // symbol

    int timeframe, // timeframe

    string name, // path/name of the custom indicator compiled program

    ... // custom indicator input parameters (if necessary)

    int mode, // line index

    int shift // shift

    );

The indicator you call has two inputs

extern int First_R=5;
extern int Second_S=8;


I would try to include them in the iCustom call. I'm not saying I'm going to fix the problem, but it's definitely something I would try.

Also I would use _Symbol instead of "EURUSD"

By the way, you just need to use Print instead of Printf

 
Enrique Enguix #:
_Symbol

Hello friend, thanks for reply.

I have change "EURUSD" with _Symbol plus added two input paramters, no way, still with this issue.

Plus i have removed from indicator extern, so they are basically inside parameters without call it in iCustom, still way.


Wait eventually others helps.


Thanks in advance.

 
I tried others way but still in trouble, i am going to be crazy for this issue
 
Mirco #:
I tried others way but still in trouble, i am going to be crazy for this issue

I hope this works so that you do not " go crazy" my friend. he he :D

//+------------------------------------------------------------------+
//|                                                 getvalue_TSI.mq4 |
//|                                  Copyright 2023, MetaQuotes Ltd. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2023, MetaQuotes Ltd."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
extern int       First_R = 5;
extern int       Second_S = 8;
int OnInit()
  {
//---
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
   double p_tsi, c_tsi;
   c_tsi = iCustom(_Symbol, PERIOD_CURRENT, "TSI", First_R, Second_S, 0, 0);
   p_tsi = iCustom(_Symbol, PERIOD_CURRENT, "TSI", First_R, Second_S, 0, 1);
   Print("This is the previous value : ", p_tsi, " This is the current value : ", c_tsi);
  }
//+------------------------------------------------------------------+
 
Chioma Obunadike #:

I hope this works so that you do not " go crazy" my friend. he he :D

Hello friend, thanks for help but basically was the same code that i try for myself, basically it works like a charm on backtest when i try to get values that is not about current Symbol in backtest, when i put _Symbol or directly string of current pair in backtest i got a totally wrong value.