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

Re: [amibroker] Help with Kirshenbaum indicator



PureBytes Links

Trading Reference Links

With much interest i read the contributions regarding the Kirshenbaum indicator. Special thanks to Ed (Emp62) his contributions gave me a valuable insight how loops actually work...
 
When thorougly checking the calculated values, i came across different values (LinReg values) 
In my opinion the formula should be slightly changed as follows:
 
Original Empc posting:
aaa = LinRegIntercept(C, LPeriod);
bbb =
LinRegSlope(C
, LPeriod);
in my opinion should be changed to:
 
aaa = LinRegIntercept(C, LPeriod-1);
bbb =
LinRegSlope(C
, LPeriod-1);
Another thought when studying the indicator:
The "standard error calculation" measures the distance (C-Regpoint) for Lperiod days.
Obviously it make a huge difference whether the symbol is a 10$ trading stock or the Dow Index of 11000 points.
So my suggestion is to normalize the calculation for instance (C/Regpoint-1)*100 to calculate the procentual change.
 
Fred
 
 
 
 
 
SetBarsRequired(10000,10000);
PPeriod =
Param( "P Period", 12, 2, 100, 1
);
LPeriod =
Param( "L Period", 12, 2, 100, 1
);
NPeriod =
Param( "N Period", 2, 0, 10, 0.25
);
Bandwidth =
0
;

EmaP =
EMA(C
,PPeriod);

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

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

      RegPoint = aaa[ i ] + bbb[ i ] * j;
      
      
// calculate the standard error using the distance from line

      AE = AE + (
C[ (i - LPeriod) + j + 1 ] - RegPoint) ^ 2
;
   
   }
   
// standard error

avErr = (AE / LPeriod) ^
0.5
;

// save the bandwidth

Bandwidth[ i ] = avErr * NPeriod;

}


Buy = Ref(Cross(EmaP - Bandwidth,C),-1); BuyPrice = O
;
Sell = Ref(Cross(C, EmaP + Bandwidth),-1); SellPrice = O
;


SetChartOptions(0, chartShowDates
);
GraphXSpace = 5
;
Plot(C,"",colorWhite,64
);
Plot(EmaP,"",colorWhite,1
);
Plot(EmaP + Bandwidth,"",colorRed,1
);
Plot(EmaP - Bandwidth,"",colorBrightGreen,1
);

PlotShapes(IIf(Buy,shapeUpTriangle,0),colorWhite, layer = 0, yposition = BuyPrice, offset = 0
);
PlotShapes(IIf(Sell,shapeDownTriangle,0),colorYellow, layer = 0, yposition = SellPrice, offset = 0 );
 
 
 
----- Original Message -----
From: aajohah
Sent: Saturday, March 04, 2006 11:14 PM
Subject: RE: [amibroker] Help with Kirshenbaum indicator

With those settings I do not see there being a buy or sell on the chart since the close price is not out of the bands anywhere

 

Am I missing something?


Mark

 


From: amibroker@xxxxxxxxxxxxxxx [mailto:amibroker@xxxxxxxxxxxxxxx] On Behalf Of emp62
Sent: Saturday, March 04, 2006 4:23 PM
To: amibroker@xxxxxxxxxxxxxxx
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);
PPeriod =
Param( "P Period", 12, 2, 100, 1 );
LPeriod =
Param( "L Period", 12, 2, 100, 1 );
NPeriod =
Param( "N Period", 2, 0, 10, 0.25 );
Bandwidth =
0;

EmaP =
EMA(C,PPeriod);

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

for (i = LPeriod; i < BarCount; i++) {
      
   AE =
0;
   
for (j = 0; j < LPeriod; j++) {
   
      
// calculate point on regression line
      RegPoint = aaa[ i ] + bbb[ i ] * j;
      
      
// calculate the standard error using the distance from line
      AE = AE + (C[ (i - LPeriod) + j +
1 ] - RegPoint) ^ 2;
   
   }
   
// standard error
avErr = (AE / LPeriod) ^
0.5;

// save the bandwidth
Bandwidth[ i ] = avErr * NPeriod;

}

SetChartOptions(0, chartShowDates);
GraphXSpace =
5;
Plot(C,"",colorWhite,64);
Plot(EmaP,"",colorWhite,1);
Plot(EmaP + Bandwidth,"",colorRed,1);
Plot(EmaP - Bandwidth,"",colorBrightGreen,1);




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





YAHOO! GROUPS LINKS