Zero Balance Indicator

Discussion in 'Strategy Development' started by swingwaver, Feb 17, 2003.

  1. I make Zero Balance Indicator for TS2000i.
    Zero Blance indicator Larry Williams's indicator.
    Please see his book "The definitive guide ot futures trading"

    If you have interest, use it.

    I want to draw line in future.
    Do you know how to draw in future or left side of chart.
    with TS2000i.




    {*******************************************************************
    Description : Zero Balance Indicator.
    forecast_step is predict step value.
    Please see
    "The definitive guide ot futures trading"
    Larry Williams (japanese: p.297)

    Usage: Buy set up is that Zero balance line make
    continous lower low by 3 times.
    When Price crosses over Zero balance.
    Sell set up is that Zero Balance line make
    continous high high by 3 times.
    When Price crosses under Zero Balance.

    Parameter: forecast_step(3)
    3: predict 3 step future's point. (default)
    2: predict 2 step future's point.
    1: predict 1 step future's point.

    nakayama@swingwaver.com
    ********************************************************************}
    Input: forecast_step(3);

    Vars:
    Length(7), { Length for IR Low/High }
    IRLowbar(0),IRLowDitectBar(0),IRLow(0),
    IRHighBar(0),IRHighDitectBar(0),IRHigh(0);

    Vars:
    status(1),
    status_irlow(1),
    status_irhigh(0),
    Plotday(0),
    previous_day(0);

    Vars:
    ii(0),ID(0);

    Arrays:
    IR[8](0),
    ZeroBalance[4](0),
    ThreeRule[4](0);


    setplotcolor(3, red);

    { Definition of IR High/Low }
    if BarNumber > Length then begin
    condition1 = High > Highest(High,Length)[1];
    condition2 = Low < Lowest(Low,Length)[1];
    end;

    { Lowestbar(price,10) return bar number of ago that has
    most lowest price for 10 bars. This is important }
    if condition1 and status = status_irhigh then begin { To find IR Low }
    IRLowDitectBar = BarNumber;
    IRLowBar = LowestBar(Low, BarNumber-IRHighDitectBar+IRHighBar);
    IRLow = Lowest(Low,BarNumber-IRHighDitectBar+IRHighBar);
    status = status_irlow;
    Plot1[IRLowBar](IRLow,"IR");
    end;

    { Highestbar(price,10) return bar number of ago that has
    most highest price for 10 bars. This is important }
    if condition2 and status = status_irlow then begin { To find IR High }
    IRHighDitectBar = BarNumber;
    IRHighBar = highestbar(high,barnumber-IRLowDitectBar+IRLowBar);
    IRHigh = highest(high,barnumber-IRLowDitectBar+IRLowBar);
    status = status_irhigh;
    Plot1[IRHighBar](IRHigh,"IR");
    end;

    if status <> status[1] then begin {for analyising}

    For ii = 1 To Length begin { make room for new IR value}
    IR[ii] = IR[ii+1];
    end;

    if status = status_irlow then begin { Collect IR values }
    IR[Length + 1] = IRLow;
    Plotday = IRLowBar; { Plot Zerobalance day }
    end
    else begin
    IR[Length + 1] = IRHigh;
    Plotday = IRHighBar; { Plot Zerobalance day }
    end;

    if IR[1] <> 0 then begin
    {see p.299 and 306 of larry's book.}
    ZeroBalance[1] = IR[4] + IR[3] - IR[1]; { 1 forecast. }
    ZeroBalance[2] = IR[5] + IR[4] - IR[2]; { 2 forecast. }
    ZeroBalance[3] = ZeroBalance[1] + IR[5] - IR[3]; { 3 forecast. }
    for ii = 1 to 3 begin { make room for new forecast value}
    ThreeRule[ii] = ThreeRule[ii+1];
    end;
    ThreeRule[4] = ZeroBalance[3];
    condition3 = ThreeRule[2] >= ThreeRule[1] AND ThreeRule[3] >= ThreeRule[2] AND ThreeRule[4] >= ThreeRule[3];
    condition4 = ThreeRule[2] <= ThreeRule[1] AND ThreeRule[3] <= ThreeRule[2] AND ThreeRule[4] <= ThreeRule[3];
    {if ThreeRule[1] <> 0 then begin}
    if condition3 or condition4 then begin
    {setplotcolor(2,Green);}
    Plot2[Plotday](ZeroBalance[3], "ZB");
    end;
    {end;}
    if forecast_step = 1 and ZeroBalance[1] <> 0 then begin { 1 forecast. }
    Plot3[Plotday](ZeroBalance[1], "ZB");
    end;
    if forecast_step = 2 and ZeroBalance[2] <> 0 then begin { 2 forecast. }
    Plot3[Plotday](ZeroBalance[2], "ZB");
    end;
    if forecast_step = 3 and ZeroBalance[3] <> 0 then begin { 3 forecast. }
    Plot3[Plotday](ZeroBalance[3], "ZB");
    end;
    previous_day=Plotday;
    end;
    end;

    if date = LastCalcDate then begin
    if IR[1] <> 0 then begin
    {see p.299 and 306 of larry's book.}
    ZeroBalance[1] = IR[4] + IR[3] - IR[1]; { 1 forecast. }
    ZeroBalance[2] = IR[5] + IR[4] - IR[2]; { 2 forecast. }
    ZeroBalance[3] = ZeroBalance[1] + IR[5] - IR[3]; { 3 forecast. }
    for ii = 1 to 3 begin { make room for new forecast value}
    ThreeRule[ii] = ThreeRule[ii+1];
    end;
    ThreeRule[4] = ZeroBalance[3];
    condition3 = ThreeRule[2] >= ThreeRule[1] AND ThreeRule[3] >= ThreeRule[2] AND ThreeRule[4] >= ThreeRule[3];
    condition4 = ThreeRule[2] <= ThreeRule[1] AND ThreeRule[3] <= ThreeRule[2] AND ThreeRule[4] <= ThreeRule[3];
    {if ThreeRule[1] <> 0 then begin}
    if condition3 or condition4 then begin
    {setplotcolor(2,Green);}
    Plot2(ZeroBalance[3], "ZB");
    end;
    {end;}
    if forecast_step = 1 and ZeroBalance[1] <> 0 then begin { 1 forecast. }
    Plot3(ZeroBalance[1], "ZB");
    end;
    if forecast_step = 2 and ZeroBalance[2] <> 0 then begin { 2 forecast. }
    Plot3(ZeroBalance[2], "ZB");
    end;
    if forecast_step = 3 and ZeroBalance[3] <> 0 then begin { 3 forecast. }
    Plot3(ZeroBalance[3], "ZB");
    end;
    previous_day=Plotday;
    end;
    end;
     
  2. Your account is about to have a zero balance indicator. :p

    FRuiTY P.