Sat10252014

Last update02:10:46 PM

{module Teline4-WebAd 300x250 1}
{module Teline4-WebAd 300x250 2}
Back Home Departments Traders' Tips TRADERSSTUDIO: PRICE ZONE OSCILLATOR

TRADERSSTUDIO: PRICE ZONE OSCILLATOR

Shown here is the TradersStudio code for the Pzo and Vzo indicators and related systems from Walid Khalil and David Steckler’s articles, “Entering The Price Zone” in this issue and “In The Volume Zone” from the May 2011 issue. One of the inputs to the Pzo system is called “usePzo.”

When this input is set to equal “1,” then the indicator and system use the Pzo. If set to any other value, then the indicator and system use theVzo. Since my tests showed that trading the short side of the system resulted in net losses, I have also provided an input called “allowShorts” that will disable shorting if set to anything other than “1.” In the tests I ran, I set “allowShorts” = 0 so that shorting was disabled. The system code provided here for TraderStudio is based on the TradeStation code provided in the article and, as noted in the article, the divergence exit is not coded.

I ran a backtest using the Tradeplan module from 1/1/1992 to 4/15/2011 using a “Nasdaq 100–like” list of stocks, which contained 74 stocks. I used a Tradeplan that divided the capital into 74 equal pieces so that all signals could be taken. In Figure 10, I show the Tradeplan equity curve and in Figure 11, I show the Tradeplan underwater equity curve. For the test period, the compound annual return was 5.04% with a maximum drawdown of 24.52% on 3/11/2003.

FIGURE 10: TRADERSSTUDIO, PRICE ZONE OSCILLATOR/ VOLUME ZONE OSCILLATOR SYSTEM. Here is the equity curve from the Tradeplan module that resulted from a backtest of the PZO/VZO system using equal equity sizing, trading all signals from a list of 74 stocks similar to the NASDAQ 100.


FIGURE 11: TRADERSSTUDIO, SYSTEM DRAWDOWNS. This shows the underwater equity curve from the Tradeplan module that resulted from a backtest of the PZO/VZO system using equal equity sizing, trading all signals from a list of 74 stocks similar to the NASDAQ 100.

The code can be downloaded from the TradersStudio website at www.TradersStudio.com→Traders Resources→FreeCode orwww.TradersEdgeSystems.com/traderstips.htm. The code is also shown below.

TradersStudio code

' ENTERING THE PRICE ZONE
' Authors: Walid Khalil and David Steckler,
'          TASC June 2011
' Coded by: Richard Denning 04/16/2011
' www.TradersEdgeSystems.com

Function PZO(pLen)
' Default:
'pLen is  14. 
Dim R As BarArray
Dim CP As BarArray
Dim TC As BarArray
R = IFF(C > C[1],C,-C)
CP = XAverage(R,pLen)
TC = XAverage(C,pLen)
PZO = (CP / TC) * 100
End Function
'----------------------------------------------
'PZO INDICATOR:

Sub PZO_IND(pLen)
plot1(PZO(PLen))
plot2(60)
plot3(40)
plot4(0)
Plot5(-40)
Plot6(-60)
End Sub
'----------------------------------------------
'PZO OR VZO SYSTEM:
Sub PZO_SYS(pLen,emaLen,usePZO,allowShorts)
' pLen = 14
'allowShorts = 1 trade both long and short else only trade long
Dim xADX As BarArray
Dim xEMA As BarArray
Dim xVZO As BarArray
Dim xPZO As BarArray
Dim xMax As BarArray
Dim xMin As BarArray
Dim B2_SU As BarArray
Dim S2_SU As BarArray 
Dim MP As BarArray

MP = marketpos(0)
xPZO = PZO(pLen)
xVZO = VZO(pLen)
xADX = ADX(pLen,0)
xEMA = XAverage(C,emaLen)
If BarNumber = FirstBar Then
    xMax = 0
    xMin = 0
    B2_SU = 0
    S2_SU = 0
End If

If usePZO = 1 Then
    xMax = xPZO
    xMin = xPZO
Else
    xMax = xVZO
    xMin = xVZO
End If

If CrossesOver(xMin,0) Then B2_SU = 1 Else B2_SU = B2_SU[1]
If CrossesUnder(xMax,0)Then S2_SU = 1 Else S2_SU = S2_SU[1]

If xADX > 18 Then
    'ADX > 18 cases
    If MP <= 0 And C > xEMA Then
        If CrossesOver(xMax,-40) Then Buy("LE1",1,0,Market,Day)
        If B2_SU = 1 And CrossesOver(xMax,15) Then Buy("LE2",1,0,Market,Day)
    End If
    If MP > 0 Then
        If xMax[1] > 60 And xMax < xMax[1] Then ExitLong("LX1","",1,0,Market,Day)
        If C < xEMA And xMin < 0 Then ExitLong("LX2","",1,0,Market,Day)
    End If
    If MP >= 0 And C < xEMA And allowShorts = 1 Then
        If CrossesUnder(xMin,40) Then Sell("SE1",1,0,Market,Day)  
        If S2_SU = 1 And CrossesUnder(xMin,-5) Then Sell("SE2",1,0,Market,Day)
    End If
    If MP < 0 Then
        If xMin[1] < -60 And xMin > xMin[1] Then ExitShort("SX1","",1,0,Market,Day)
        If C > xEMA And xMax > 0 Then ExitShort("SX2","",1,0,Market,Day)
    End If
    
Else
    'ADX <= 18 cases
    If MP <= 0 Then
        If CrossesOver(xMax,-40) Then Buy("LE3",1,0,Market,Day)
        If CrossesOver(xMax,15) Then Buy("LE4",1,0,Market,Day)
    End If
    If MP > 0 Then 
        If xMax > 40 Then
            If xMax[1] > 60 And xMax < xMax[1] Then ExitLong("LX3","",1,0,Market,Day)   
        Else
            If C < xEMA And xMin < 0 Then ExitLong("LX4","",1,0,Market,Day)
            If xMin < -5 Then ExitLong("LX5","",1,0,Market,Day) 
        End If
    End If    
    If MP >= 0 And allowShorts = 1 Then
        If CrossesUnder(xMin,40) Then Sell("SE3",1,0,Market,Day)
        If CrossesUnder(xMin,-5) Then Sell("SE4",1,0,Market,Day)
    End If
           
    If MP < 0 Then
        If xMin < -40 Then
            If xMin[1] < -60 And xMin > xMin[1] Then ExitShort("SX3","",1,0,Market,Day)
        Else
            If C > xEMA And xMax > 0 Then ExitShort("SX4","",1,0,Market,Day)
            If xMax > 15 Then ExitShort("SX5","",1,0,Market,Day)
        End If
    End If
End If

If CrossesUnder(xMin,15) Then B2_SU = 0 Else B2_SU = B2_SU[1]
If CrossesOver(xMax,-5) Then S2_SU = 0 Else S2_SU = S2_SU[1]

End Sub
End Sub

—Richard Denning
info@TradersEdgeSystems.com
for TradersStudio

PTSK — The Professional Traders' Starter Kit
Home  | Working Money Magazine | S&C Magazine | Traders.com Advantage | Online Store | Traders’ Resource
Add a Product to Traders’ Resource | Message Boards | Subscribe/Renew | Free Trial Issue | Article Code | Search

DEPARTMENTS: Advertising | Editorial | Circulation | Employment | Contact Us | BY PHONE: (206) 938-0570

Join us on Facebook     Follow us on Twitter     Follow Us on StockTwits

Bookmark and Share Copyright © 1996-2014 Technical Analysis, Inc. All rights reserved. Read our disclaimer & privacy statement.

SUBSCRIBE TO OUR FREE
EMAIL NEWSLETTER!