Bull and Bear Balance Indicator

Discussion in 'TradeStation' started by feijian0000, Sep 17, 2012.

  1. The Bull and Bear Balance Indicator is from the Oct 2003 edition of the S&C magazine
    from an article by Vadim Gimelfarb. This version uses functional programming (geek talk), which I think would be easier to read than the one to be posted by Mark Mills, which uses nested if statements. The logic came from a translation from a formula for "another product". Note that the article is not very precise on how to smooth the plot.

    Type : Indicator, Name : Bull and Bear Balance Indicator

    input:avg(20),smooth(5);
    var:r1(0),r2(0),bull(0),bear(0);
    r1 = iff(c[1]>0, h-l, maxlist(o-c[1],h-l));
    r2 = iff(c[1]<0, h-l, maxlist(c[1]-o,h-l));

    bull=iff(c=o,
    iff(h-c=c-l,
    iff(c[1]>o,
    maxlist(h-o,c-l),r1),
    iff(h-c>c-l,
    iff(c[1]<o,
    maxlist(h-c[1],c-l),
    h-o),
    r1)),
    iff(c<o,
    iff(c[1]<o,
    maxlist(h-c[1],c-l),
    maxlist(h-o, c-l)),
    r1));

    bear=iff(c=o,
    iff(h-c=c-l,
    iff(c[1]<o,
    maxlist(o-l,h-c),r2),
    iff(h-c>c-l,
    r2,
    iff(c[1]>o,
    maxlist(c[1]-l,h-c),
    o-l))),
    iff(c<o,
    r2,
    iff(c[1]>o,
    maxlist(c[1]-l,h-c),
    maxlist(o-l, h-c))));

    plot1(xaverage(xaverage(bull,avg)-xaverage(bear,avg),smooth),"bbb");
     
  2. 熊牛平衡指数是干啥子的呢