[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [amibroker] Help with Kirshenbaum indicator



PureBytes Links

Trading Reference Links

I think that the use of LinearReg is not the same. Not like the discription of the Kirshenbaum bands dictates:
 
 
LinearReg calculates enpoints of a + b * x and from what I understand of the Kirshenbaum band needs more then just the endpoints (see discription). So the code I gave is correct I believe.
 
The piece of code below shows that the code does not look into the future.
 
For instance we have a function with 100 points and LPeriod = 10.
 
The last bar = 99, BarCount = 100
 
going through the i and j loop:
 
i = 99
 
j = 0;   i - LPeriod + j + 1 = 90
j = 1;   i - LPeriod + j + 1 = 91
j = 2;   i - LPeriod + j + 1 = 92
j = 3;   i - LPeriod + j + 1 = 93
j = 4;   i - LPeriod + j + 1 = 94
j = 5;   i - LPeriod + j + 1 = 95
j = 6;   i - LPeriod + j + 1 = 96
j = 7;   i - LPeriod + j + 1 = 97
j = 8;   i - LPeriod + j + 1 = 98
j = 9;   i - LPeriod + j + 1 = 99
 
So the last bar that is filled is bar 99.
 
In the code I use a Cum(1) function so that you can see that the calculated least square fit exactly matches the function. 
 
 
 
 
SetBarsRequired(10000,10000);
LPeriod =
10
;

C = Cum(1
);

saveLine =
Null
;

aaa =
LinRegIntercept(C
, LPeriod);
bbb =
LinRegSlope(C
, LPeriod);

for (i = BarCount - 1; i < BarCount
; i++) {
      
printf( "********* i %g\n"
, i );

   AE =
0
;
   
for (j = 0
; j < LPeriod; j++) {
   
      
// calculate point on regression line

      RegPoint = aaa[ i ] + bbb[ i ] * j;
      
printf( "********* i - LPeriod + j + 1:   %g\n", i - LPeriod + j + 1
);

      
// calculate the standard error using the distance from line

      AE = AE + (
C[ (i - LPeriod) + j + 1 ] - RegPoint) ^ 2
;
      
printf( "********* AE %g\n"
, AE );

      saveLine[ i - LPeriod + j +
1
] = RegPoint;
   
   }
   
}

SetChartOptions(0, chartShowDates
);
GraphXSpace = 5
;
Plot(saveLine,"",colorRed,1
);
Plot(saveLine,"",colorYellow,9
);
Plot(C,"",colorWhite,1
);
Plot(saveLine,"",colorRed,1);
 
 
 
----- Original Message -----
From: emp62
Sent: Sunday, March 05, 2006 9:36 AM
Subject: Re: [amibroker] Help with Kirshenbaum indicator

ok yes.  I was struggling to get the Lin reg. on the proper bar, I'll have a look. But I think the other guys use LinReg function. Maybe that is easier and faster.
 
rgds, Ed
 
 
----- Original Message -----
From: Wayne
Sent: Sunday, March 05, 2006 12:04 AM
Subject: Re: [amibroker] Help with Kirshenbaum indicator

Using Tools/Check:  "It seems that the formula references FUTURE quotes....." 
 
Just a heads up.....
 
Wayne
 
 
 
 
 
 
---- Original Message -----
From: emp62
Sent: Saturday, March 04, 2006 1:23 PM
Subject: Re: [amibroker] Help with Kirshenbaum indicator

hi,
 
I changed 1 line in the code. I think it is good now. See chart below which resembles your original chart very good (settings I use for that chart are: 5, 7, 4.5)
 
code:
 
SetBarsRequired(10000,10000); 
  


Please note that this group is for discussion between users only.

To get support from AmiBroker please send an e-mail directly to
SUPPORT {at} amibroker.com

For other support material please check also:
http://www.amibroker.com/support.html





SPONSORED LINKS
Investment management software Real estate investment software Investment property software
Software support Real estate investment analysis software Investment software


YAHOO! GROUPS LINKS