Help with icustom()

 

i'm developing EA , i'm trying to get r1,r2... values from pivotlevels.mql indicator


from my ea i calling like

double r1=iCustom(Symbol(),0,"pivotlevels",0,0);
double r2=iCustom(Symbol(),0,"pivotlevels",1,0);
double r3=iCustom(Symbol(),0,"pivotlevels",2,0);
double s1=iCustom(Symbol(),0,"pivotlevels",3,0);
double s2=iCustom(Symbol(),0,"pivotlevels",4,0);

double s3=iCustom(Symbol(),0,"pivotlevels",5,0);

double p=iCustom(Symbol(),0,"pivotlevels",6,0);



but i getting only empty value , can anyone help me with that , i have attached indicator here

Files:
pivotlevels.mq4  24 kb
 

(1) you can't use that indicator withiCustom(). iCustom() is made for accessing buffer values calculated by an indicator. the indicator you posted uses chart objects for drawing pivot levels, not indicator buffers.

(2) indicator logic and language syntax contain so many errors i don't know where to start. the author doesn't have a clue of what he's doing.

if, like the code suggests, it's indeed created by "strategy builder" my advice is "RUN...". you might think this "piece of code" is useful as long as your account balance is above zero.

 

thanks you for reply


any other good indicator for r1,r2.... and pivot with good codes , to use with icustom()


help much appreciated

 

Unfortunately none I know of. You'll find a lot of Pivot indicators using chart objects but probably none using buffers. That's because you don't want to know what the Pivot was yesterday or 100 bars ago, you always need the current Pivot (bar 0 - if you want). There's no need for past Pivots, thus no need for buffers. I can imagine a situation where a Pivot with buffers would be helpful, even if it only delivers the Pivot points for bar 0: With buffers you indeed could make use of iCustom(). You would call it only in PERIOD_H1 or PERIOD_D1 and don't have to worry anymore about timeframe conversion, whatever timeframe the chart/code is you put it on.

As for good code: Pivots depend a lot on correct timezone handling. I don't know any robust timezone implementation/library for MQL in the public domain meaning all indicators you'll find are more or less flawed. Look at your indicator, it uses - among others - the local timezone for calculation, nothing could be more wrong. While looking for a robust timezone library in the public you will run against a wall. It exists but not in public domain/not for free.

Pivots might be useful for manual trading when placed on a chart. As long as you don't have robust timezone handling I would not recommend them for automated trading (this is what your use of iCustom() suggests).

Regards