Bull and bear indicator

Vragen en suggesties over Vesticode

Moderator: Perry

Bull and bear indicator

Berichtdoor willie » zo 13 feb 2005, 22:18

De volgende indicator geeft een foutmelding.

Iemand dit werkend krijgt ?

------------
http://www.traders.com/Documentation/FE ... adestation

TRADESTATION: Bull And Bear Balance Indicator

Vadim Gimelfarb's article in this issue, "Bull And Bear Balance Indicator," describes a method of deducing market sentiment from close-to-close price movement. His system uses the various possible relationships between the previous close and current open, high, low, and close. Based on the pattern that each day exhibits, the indicator uses a pattern-specific calculation to determine bull and bear strength for the day.

In our code example, his categories are determined with several nested if-then-else statements. While they look a bit complex, they are really just assigning one of 11 bull categories to the day, then calculating the appropriate "bull power." After this is done, the code assigns one of 11 bear categories and does the appropriate bear power calculation.

As predicted by Gimelfarb, the resulting indicator is fairly noisy. He suggests averaging both the bear power and bull power calculations, then subtracting one from the other. Several averages are mentioned, so we have provided two averaging parameters for tweaking the indicator. The first is a length of an exponential average for both bull and bear calculations (the input named "Avg" in the code). The second is a length of an exponential moving average of the difference between bull power and bear power (the input named "Smoothing" in the code). This second average smooths the difference and produces the finished indicator (Figure 1).



Figure 1: TRADESTATION, BULL AND BEAR BALANCE INDICATOR. Here's a sample TradeStation chart demonstrating the smoothed bull and bear balance indicator on the S&P 500 e-mini. The histogram (the red vertical lines) shows the value of the bull and bear indicator at each bar.

---------

{Indicator: BullAndBear:}


inputs:
Avg( 20 ),
Smoothing( 5 ) ;
variables:
BullPower( 0 ),
BearPower( 0 ) ;
{Bull Power}
If Close < Open then
If Close[1] < Open then
?BullPower =
? MaxList(High - Close[1], Close - Low )
else
?BullPower =
? MaxList(High - Open, Close - Low)
else
If( Close > Open ) then
?If Close[1] > Open then
? BullPower = High - Low
?else
? BullPower =
? ?MaxList(Open - Close[1], High - Low )
else
?If( High - Close > Close - Low ) then
? If Close[1]< Open then
? ?BullPower = MaxList( High - ?Close[1],
? ? Close - Low )
? else
? ?BullPower = High - Open
?else
? If High - Close < Close - Low then
? ?If Close[1] > Open then
? ? BullPower = High - Low
? ?else
? ? BullPower = MaxList(Open - Close[1],
? ? ?High - Low )
? else
? ?If Close[1] > O then
? ? BullPower = MaxList( High - Open,
? ? ?Close - Low )
? ?else
? ? If Close[1] < O then
? ? ?BullPower = MaxList( Open
? ? ? - Close[1], High - Low )
? ? else
? ? ?BullPower = High - Low ;


If C<O then
If Close[1]>Open then
?BearPower = MaxList(Close[1]- Open,High - Low )
else
?BearPower = High - Low
else
If Close > Open then
?If Close[1] > Open then
? BearPower = Maxlist( Close[1] - Low, High
? ?- Close)
?else
? BearPower = Maxlist(Open - Low, High
? ?- Close )
else
?If High - Close > Close - Low then
? If Close[1] > Open then
? ?BearPower = MaxList(Close[1]-Open,
? ? High - Low )
? else
? ?BearPower = High - Low
?else
? If High - Close < Close - Low then
? ?If Close[1]>Open then
? ? BearPower = MaxList(Close[1]-Low,
? ? ?High - Close )
? ?else
? ? BearPower = Open - Low
? else
? ?If Close[1]> Open then
? ? BearPower = MaxList(Close[1]-Open,
? ? ?High - Low )
? ?else
? ? If Close[1]<O then
? ? ?BearPower = MaxList(Open - Low,
? ? ? High - Close)
? ? else
? ? ?BearPower = High - Low ;
plot1( Xaverage( XAverage( BullPower, Avg )
- XAverage( BearPower, Avg ),Smoothing ));
willie
 
Berichten: 53
Geregistreerd op: vr 10 okt 2003, 20:49

Bull and bear indicator

Berichtdoor Jo » ma 14 feb 2005, 8:25

Hoi,

Ziehier de werkende code voor de Bull & Bear indicator.


inputs: Avg( 20 ), Smoothing( 5 ) ;
variables: BullPower( 0 ), BearPower( 0 ) ;
{Bull Power}
If Close < Open then begin
If Close[1] < Open then
?BullPower = MaxList(High - Close[1], Close - Low)
else
BullPower = MaxList(High - Open, Close - Low); ?
end else
If Close > Open then begin
If Close[1] > Open then
? BullPower = High - Low
?else BullPower = MaxList(Open - Close[1], High - Low );
end else
If( High - Close > Close - Low ) then begin
If Close[1]< Open then
? ?BullPower = MaxList( High - ?Close[1], Close - Low )
?else BullPower = High - Open; ? ? ?
?end else
If (High - Close < Close - Low) then begin
If Close[1] > Open then
? ?BullPower = High - Low
? ?else BullPower = MaxList(Open - Close[1], High - Low );
end else
If Close[1] > O then
BullPower = MaxList( High - Open,Close - Low )
?else If Close[1] < O then
? ?BullPower = MaxList( Open - Close[1], High - Low )
?else BullPower = High - Low ;
{Bear Power}
If C<O then begin
If Close[1]>Open then
?BearPower = MaxList(Close[1]- Open,High - Low )
else BearPower = High - Low;
end else
If Close > Open then begin
If Close[1] > Open then
? BearPower = Maxlist( Close[1] - Low, High - Close)
else BearPower = Maxlist(Open - Low, High - Close );
end else
If High - Close > Close - Low then begin
If Close[1] > Open then
?BearPower = MaxList(Close[1]-Open,High - Low )
else BearPower = High - Low;
end else
If High - Close < Close - Low then begin
If Close[1]>Open then
? ?BearPower = MaxList(Close[1]-Low,High - Close )
? else BearPower = Open - Low;
end else
If Close[1]> Open then
? ? BearPower = MaxList(Close[1]-Open, High - Low )
? ?else If Close[1]<O then
? ?BearPower = MaxList(Open - Low, High - Close)
? ?else BearPower = High - Low ;

plot1( Xaverage(XAverage(BullPower,Avg )- XAverage(BearPower,Avg ),Smoothing ),'Avg');
plot2(BullPower,'Bull');
plot3(BearPower,'Bear');

Jo


(Edited by Jo at 7:50 am op 16,feb. 2005)


(Edited by Jo at 7:51 am op 16,feb. 2005)
Jo
 
Berichten: 44
Geregistreerd op: wo 07 jan 2004, 14:00

Bull and bear indicator

Berichtdoor willie » wo 16 feb 2005, 0:21

Hoi,


Bedankt voor je reactie,


Bij mij doet deze het niet, bij

If( High - Close > Close - Low ) thenbegin

stopt de boel.

gr.

willie
willie
 
Berichten: 53
Geregistreerd op: vr 10 okt 2003, 20:49

Bull and bear indicator

Berichtdoor Jo » wo 16 feb 2005, 7:52

Hoi,

Gelieve terug de code te kopieren via de knop Edit, code aangepast.

Moet lukken...

Jo
Jo
 
Berichten: 44
Geregistreerd op: wo 07 jan 2004, 14:00


Keer terug naar Vesticode

Wie is er online

Gebruikers op dit forum: Geen geregistreerde gebruikers en 13 gasten

cron