Meta:
	Weblink("http://www.tradesignalonline.com/lexicon/view.aspx?id=16748"),
    Synopsis("Price Zone Oscillator Strategy, based on the indicator from the 05/2011 issue of Stocks And Commodities.This strategy is
    useful in uptrends, downtrends or even sideways market conditions. It can be seen as a complement to the Volume Zone Oscillator."),
    Subchart( False );
	
Inputs:
	Period_PZO( 14 , 1 ),
	Period_ADX( 14 , 1 ),
	Level_ADX( 18 , 1 ),
	Period_EMA( 60 , 1 ),
	Upper_Line_1( 60 , 1 ),
	Upper_Line_2( 40 , 1 ),
	Upper_Line_3( 15 , 1 ),
	Lower_Line_1( -5 , -100 ),
	Lower_Line_2( -40 , -100 ),
	Lower_Line_3( -60 , -100 );

Vars: 
	adxValue, trendFilter, absClose, digitalClose, avgDigitalClose, avgClose,
	pzOscillator, B2_SU(FALSE), S2_SU(FALSE), numMarketPosition;

numMarketPosition = MarketPosition;
absClose = AbsValue(Close);

digitalClose = Sign(Close - Close[1]) * absClose;
avgDigitalClose = XAverage(digitalClose, Period_PZO);
avgClose = Xaverage(absClose, Period_PZO);
 
if avgClose <> 0 then 
	pzOscillator = 100 * avgDigitalClose / avgClose;

adxValue = ADX(Period_ADX);
trendFilter = XAverage(Close, Period_EMA);

if adxValue > Level_ADX then 
	begin 

		if numMarketPosition <= 0 and Close > trendFilter then 
			begin
   				if pzOscillator crosses over Lower_Line_2 then 
   					Buy("BUY1")  next bar at market;
   
   				if pzOscillator crosses over 0 then 
   					B2_SU = TRUE;
   					
   				if B2_SU and pzOscillator crosses over Upper_Line_3 then
					Buy("BUY2")  next bar at market;
  			end;
  			
  		if  numMarketPosition > 0 then 
  			begin
   				if pzOscillator[1] > Upper_Line_1 and pzOscillator < pzOscillator[1] then 
					Sell("SELL1") next bar at market; 
					
   				if Close < trendFilter and pzOscillator < 0 then 
					Sell("SELL2") next bar at market; 
  			end;
  			
  		if numMarketPosition >= 0 and Close < trendFilter then 
  			begin
 				if pzOscillator crosses under Upper_Line_2 then 
					Short("SELL SHORT1")  next bar at market;
					
   				if pzOscillator crosses under 0 then S2_SU = TRUE;
   				
   				if S2_SU and pzOscillator crosses under -5 then
					Short("SELL SHORT2")  next bar at market;
  			end;
  			
  		if  numMarketPosition < 0 then 
  			begin
   				if pzOscillator[1] < -60 and pzOscillator > pzOscillator[1] then 
					Cover("COVER1") next bar at market; 
					
   				if Close > trendFilter and pzOscillator > 0 then 
					Cover("COVER2") next bar at market; 
  			end;
	end
else 
	begin
		if numMarketPosition <= 0 then 
			begin
   				if pzOscillator crosses over Lower_Line_2 then 
   					Buy("BUY3")  next bar at market;
   					
   				if pzOscillator crosses over Upper_Line_3 then 
   					Buy("BUY4")  next bar at market;
 			 end;
  
  		if  numMarketPosition > 0 then 
  			begin
   				if pzOscillator > Upper_Line_2 then 
   					begin
    					if pzOscillator[1] > Upper_Line_1 and pzOscillator < pzOscillator[1] then 
    						Sell("SELL3") next bar at market;
    
    					if Close < trendFilter and pzOscillator < 0 then
							Sell("SELL4") next bar at market; 
  					end 
  				else If pzOscillator < -5 then 
  					Sell("SELL5") next bar at market; 
  			end;
  			
  		if numMarketPosition >= 0 then 
  			begin
  				if pzOscillator crosses under Upper_Line_2 then 
					Short("SELL SHORT3")  next bar at market;
					
   				if pzOscillator crosses under -5 then 
   					Short("SELL SHORT4")  next bar at market;
  			end;
  			
  		if  numMarketPosition < 0 then 
  			begin
   				if pzOscillator < -40 then 
   					begin
    					if pzOscillator[1] < Lower_Line_3 and pzOscillator > pzOscillator[1] then 
    						Cover("COVER3") next bar at market;
    					
    					if Close > trendFilter and pzOscillator > 0 then
							Cover("COVER4") next bar at market; 
   					end 
   				else if pzOscillator > Upper_Line_3 then 
					Cover("COVER5") next bar at market; 
  			end;
	end;
	
if pzOscillator crosses under Upper_Line_3 then 
	B2_SU = FALSE;
	
if pzOscillator crosses over -5 then 
	S2_SU = FALSE;

// *** Copyright tradesignal GmbH ***
// *** www.tradesignal.com ***