
3517 
// main cycle int i=prev_calculated1; if(i<Per) i=Per; while(i<rates_total) { for(int j=1;j<=Per;j++) { if(Price==PRICE_CLOSE) x[j]=Close[ij]; if(Price==PRICE_OPEN) x[j]=Open[ij]; if(Price==PRICE_HIGH) x[j]=High[ij]; if(Price==PRICE_LOW) x[j]=Low[ij]; if(Price==PRICE_MEDIAN) x[j]=(Low[ij]+High[ij])/2.; if(Price==PRICE_TYPICAL) x[j]=(Low[ij]+High[ij]+Close[ij])/3.; if(Price==PRICE_WEIGHTED) x[j]=(Low[ij]+High[ij]+Close[ij]+Open[ij])/4.; } lrs[i]=LinRegrSlope(Per); i++; } The indicator may work as expected for the first call, when prev_calculated is zero. But after that i will be either Bars1 or Bars2, so as new bars are opened, no value is calculated for them

3206 
There indicator is wrongly coded, it uses future price and doesn't have a value for the last "LRSPeriod" bars. Completely useless.


GumRai: The indicator may work as expected for the first call, when prev_calculated is zero. But after that i will be either Bars1 or Bars2, so as new bars are opened, no value is calculated for them
Keith, Thanks for your comment. The strange thing is that the indicator draws apparently normally, both attached to a chart and in the strategy tester!!! Try it. It has to be something else... 

3206 
fufutos: Alain, Thanks for your comment. But the indicator actually draws apparently normally. How can you explain that? What is normal for you ?
for(int j=1;j<=Per;j++) { ... // default setting is PRICE_MEDIAN if(Price==PRICE_MEDIAN) x[j]=(Low[ij]+High[ij])/2.; ... } lrs[i]=LinRegrSlope(Per); For candle i, it uses Low/High of candle i1 to i40, these are future values.

3517 
I concur, there is no way that this indicator draws normally. I am wondering if it is someone's attempt to convert an mq5 code to mq4? This is confusing, why the use of capital letters? 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[]) {

3206 
GumRai: I concur, there is no way that this indicator draws normally. I am wondering if it is someone's attempt to convert an mq5 code to mq4? This is confusing, why the use of capital letters?
Good catch. I came to the same conclusion but without finding a clue.

Hi all,
My name is Harry.
I am trying to use attached linear regression slope indicator in my EA, but I'm having trouble retrieving the values of the indicator in my EA.
It is returning always EMPTY_VALUE.
I have to use this indicator with MT4, so I have compiled the indicator in MT4 and seems to draw fine. (attached in a chart, as well as in the strategy tester)
The problem that I have is when I try to retrieve values to process in my EA, I get always EMPTY_VALUE.
That's how I 'm trying to retrieve:
double LRS1 = iCustom(NULL, RunningTF, "lrs", LRSPeriod, 0, 1); // linear regression slope
I need the previous bar value in my EA.
I do not have the same issue with other indicators I call similarly.
If anyone could help mde with this, I will be really obliged.
Greetings from Greece,
Harry
lrs.mq4 (3.44 KB)