English

## Linear Regression Forecast formula or any Indicator?

 157 cashcube 2016.02.23 09:33 #   I tried to simplify the code with this following, but it shows zero divide error. I know its because of the i = 0. But there is no other option too. I need Close[0] for current close price on the chart while calculating right. So without using zero on "i" how can I do it?```int start() {         int limit;      int counted_bars=IndicatorCounted();   //---- check for possible errors      if(counted_bars<0) return(-1);   //---- the last counted bar will be recounted      if(counted_bars>0) counted_bars--;      limit=Bars-counted_bars;   //---- main loop      for(int i=0; i
 12983 WHRoeder 2016.02.23 13:03 #   You're not summing anything when you zero them inside the loop. You're not computing a slope/Intercept when you have only one point (inside the loop.)Compare that to your original functions
 157 cashcube 2016.02.24 08:18 #   WHRoeder: You're not summing anything when you zero them inside the loop. You're not computing a slope/Intercept when you have only one point (inside the loop.)Compare that to your original functionsOk, then getting back to my original functions. I corrected it as you recommended earlier. But why graphs are like that.  There is a huge variation from each data. I understand it must be something to do with the theory itself.Well in the example below, For recent close price, x = 1 not zero, like I declared at first double sumx = 0; I tried declaring sumx = 1; but that's not helping. This is the Excel calculation on EURUSD data, but on excel graphs are showing right.
 157 cashcube 2016.02.26 14:20 #   I figure out what was the problem, i was calling function inside a function while calculating Intercept. But I solve the issue. Now its plotting right. But its plotting same way like the indicator I posted at the the first. With Ctrader Linear Regression Forecast indicator its still have such difference. :X