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

Re: [amibroker] Help with Kirshenbaum indicator



PureBytes Links

Trading Reference Links

you can easily add possible buy and sell entry positions. See example below:
 
 
 
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





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


YAHOO! GROUPS LINKS