tranforming an indicator into a function

Discussion in 'Trading Software' started by gg69, Dec 1, 2003.

  1. gg69

    gg69

    Hello,

    I’m a new user of tradestation 2000i, I have found the zig zag indicator in percent on web. And i would like to have it in function and not in indicator. I would like to change a zig zag indicator in a zig zag function. I don’t know how to change a indicator in a function.

    (I would like to have the zig zag function in points and not in % if you have)

    Many thanks.

    This is the zig zag indicator :

    {***********************************************************************
    Description : This Indicator plots ZigZag Percent
    Provided By : Omega Research, Inc. (c) Copyright 1999
    ************************************************************************}

    Inputs: WavePcnt(5), Color(darkgreen), Thicknes(1);
    Variables: SH(0), SL(0), RP(0), RPDate(0), RPTime(0), ZigZag(0), Switch(0),
    NextZig(0);

    IF CurrentBar = 1 Then Begin
    RP = MedianPrice;
    RPDate = Date;
    RPTime = Time;
    NextZig = Text_New(Date, Time, 0, NumToStr(WavePcnt, 0)+"%-");
    Text_SetColor(NextZig, Color);
    End;

    SH = SwingHigh(1, High, 1, 2);
    SL = SwingLow(1, Low, 1, 2);

    IF SH <> -1 Then Begin
    IF Switch <> -1 AND SH >= RP * (1+(WavePcnt*.01)) Then Begin
    Condition1 = True;
    Switch = -1;
    Condition2 = True;
    End;
    IF Condition1 = False AND Switch = -1 AND SH >= RP Then Begin
    TL_SetEnd(ZigZag, Date[1], Time[1], SH);
    Condition2 = True;
    End;
    IF Condition2 Then Begin
    Condition2 = False;
    RP = SH;
    RPDate = Date[1];
    RPTime = Time[1];
    End;
    End;

    IF SL <> -1 Then Begin
    IF Switch <> 1 AND SL <= RP - (RP*(WavePcnt*.01)) Then Begin
    Condition1 = True;
    Switch = 1;
    Condition2 = True;
    End;
    IF Condition1 = False AND Switch = 1 AND SL <= RP Then Begin
    TL_SetEnd(ZigZag, Date[1], Time[1], SL);
    Condition2 = True;
    End;
    IF Condition2 Then Begin
    Condition2 = False;
    RP = SL;
    RPDate = Date[1];
    RPTime = Time[1];
    End;
    End;

    IF Condition1 Then Begin
    Condition1 = False;
    ZigZag = TL_New(RPDate, RPTime, RP, RPDate[1], RPTime[1], RP[1]);
    TL_SetSize(ZigZag, Thicknes);
    TL_SetColor(ZigZag, Color);
    TL_SetExtRight(ZigZag, False);
    TL_SetExtLeft(ZigZag, False);
    IF False Then Plot1[1](RP, "RP");
    End;

    IF Switch = 1 Then Begin
    Text_SetLocation(NextZig, Date, Time, RP * (1+(WavePcnt*.01)));
    Text_SetStyle(NextZig, 1, 2);
    End;
    IF Switch = -1 Then Begin
    Text_SetLocation(NextZig, Date, Time, RP - (RP*(WavePcnt*.01)));
    Text_SetStyle(NextZig, 1, 2);
    End;