I downloaded and installed _linreg.mq4 and compiled it, restarted MQ4, and have tried calling it in my EA code and all it says is...
'_linreg' - function is not defined.
I also tried just linreg without the _, and it still says 'linreg' - function is not defined.
What's the proper way to get the value from an EA?
I got it from https://www.mql5.com/en/code/8139
You will be needing iCustom(). You can then index any bar you like.
https://book.mql4.com/samples/shared
hth
V
Thanks for the help...
I added this line to my EA...
Print("iCustom(this is me): " + iCustom(NULL, 0, "_linreg", 0, 0));
And this is what I see in the journal... (when backtesting)
2010.07.24 16:39:01 2010.07.23 22:00 MyStrategy EURUSD,H1: iCustom(this is me): 2147483647.00000000
2010.07.24 16:39:01 2010.07.23 21:00 MyStrategy EURUSD,H1: iCustom(this is me): 2147483647.00000000
2010.07.24 16:39:01 2010.07.23 20:00 MyStrategy EURUSD,H1: iCustom(this is me): 2147483647.00000000
It's always the same value of 2147483647.00000000, as far back as I can scroll in the journal, for the whole backtest...
Anyone know why?
I got _linreg from https://www.mql5.com/en/code/8139 and it looks like a normal linear regression line when I add it to a chart...
Anyone know what's the matter with my code?
Misuse of iCustom()
try
Print("iCustom(this is me): " + iCustom(NULL, 0, "_linreg", 13, 0, 0));
Nope.
Print("iCustom(this is me): " + iCustom(NULL, 0, "linreg", 13, 0, 0));
Print("iCustom(this is me): " + iCustom(NULL, 0, "linreg", 13, 0, 1));
Print("iCustom(this is me): " + iCustom(NULL, 0, "linreg", 13, 0, 2));
Print("iCustom(this is me): " + iCustom(NULL, 0, "linreg", 13, 0, 3));
Print("iCustom(this is me): " + iCustom(NULL, 0, "linreg", 13, 0, 4));
2010.07.24 19:34:11 linreg-query GBPUSDm,H1: iCustom(this is me): 1.54356890
2010.07.24 19:34:11 linreg-query GBPUSDm,H1: iCustom(this is me): 1.54340440
2010.07.24 19:34:11 linreg-query GBPUSDm,H1: iCustom(this is me): 1.54330791
2010.07.24 19:34:11 linreg-query GBPUSDm,H1: iCustom(this is me): 1.54282176
2010.07.24 19:34:11 linreg-query GBPUSDm,H1: iCustom(this is me): 1.54228670

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
[Update on 07/24/2010 - Please see my newest reply]
I only need this for use in an EA...
I need to be able to get the value of the linear regression line for a period of 8, but I need to know the value for both the current bar, and a previous bar...
Aka.. I'd like to do something like...
if (LinReg(8)[0] < LinReg(8)[1])
{
}
Anyone got a linear regression indicator that can do something like this? :)