Welcome to the Traders Laboratory Forums.
Coding Forum Collaborate, receive help, or discuss coding related issues.

Reply
Old 02-15-2009, 07:52 PM   #1

Join Date: Jul 2008
Location: Valdosta, GA
Posts: 48
Ignore this user

Thanks: 1
Thanked 0 Times in 0 Posts

Need Code for W %R with 2 HMAs for TS?

I know Larry Williams used W %R with moving averages to win Futures Championships. However, I'm not sure how to use the basic W %R code and add two Hull moving averages, one fast, one slow, in the code. You can overlay in tradestation 1 or many moving averages on an indicator by scaling it on the same sub-graph as the indicator, and changing scale of the MAs to no axis. I don't think it's has the same effect as plotting the HMAs into the code, rather than scaling them on no axis. Thanks for any help.

Curtis
clbradley is offline  
Reply With Quote
Old 02-17-2009, 09:33 PM   #2
zdo

Join Date: Nov 2007
Location: boonies
Posts: 1,349
Ignore this user

Thanks: 317
Thanked 355 Times in 256 Posts
Blog Entries: 104

Re: Need Code for W %R with 2 HMAs for TS?

Curtis,

Are you trying to run HMA's on the price/chart or of the %R
zdo is offline  
Reply With Quote
Old 02-18-2009, 07:42 AM   #3

Join Date: Jul 2008
Location: Valdosta, GA
Posts: 48
Ignore this user

Thanks: 1
Thanked 0 Times in 0 Posts

Re: Need Code for W %R with 2 HMAs for TS?

On the chart of the W %R, but want to code it within the W %R code, so think it needs to be extra plots in the code. Thanks for asking, can you help with that?

Curtis
clbradley is offline  
Reply With Quote
Old 02-18-2009, 10:57 AM   #4
zdo

Join Date: Nov 2007
Location: boonies
Posts: 1,349
Ignore this user

Thanks: 317
Thanked 355 Times in 256 Posts
Blog Entries: 104

Re: Need Code for W %R with 2 HMAs for TS?

Curtis,

Please find eld attached.
Not tested.
Not style, color, etc. formatted either...

hth,

zdo
Attached Files
File Type: eld WPRWAVGS.ELD (5.7 KB, 10 views)
zdo is offline  
Reply With Quote
The Following 2 Users Say Thank You to zdo For This Useful Post:
sunilrohira (08-29-2009), Tams (03-24-2011)
Old 02-18-2009, 11:06 AM   #5

Join Date: Oct 2006
Location: na
Posts: 307
Ignore this user

Thanks: 33
Thanked 89 Times in 58 Posts

Re: Need Code for W %R with 2 HMAs for TS?

This should do what you are looking for. I dont have TS, but I do have OEC and got it compile in there. I had to add a couple functions that you will probably not need, but no big deal. I didnt do anything with coloring, that's a pretty basic thing. Hope this is what you were looking for.

Code:
inputs: 
	RLength( 14 ), 
	OverSold( 20 ), 
	OverBought( 80 ), 
	price(Close), 
	length1(20),
	Length2(40);

variables:
	PctR(0), HMA1(0), HMA2(0);
	
PctR = PercentR( RLength ) ;
HMA1= jtHMA(PctR, length1);
HMA2=jtHMA(PctR,length2);

Plot1( PctR, "%R" ) ;
Plot2( OverBought, "OverBot" ) ;
Plot3( OverSold, "OverSld" ) ;
Plot4(HMA1, "HMA1");
Plot5(HMA2, "HMA2");




#function jtHMA

Inputs: price(NumericSeries), length(NumericSimple);
Vars: halvedLength(0), sqrRootLength(0);


if ((ceiling(length / 2) - (length / 2)) <= 0.5) then
halvedLength = ceiling(length / 2)
else
halvedLength = floor(length / 2);

if ((ceiling(SquareRoot(length)) - SquareRoot(length)) <= 0.5) then
sqrRootLength = ceiling(SquareRoot(length))
else
sqrRootLength = floor(SquareRoot(length));

Value1 = 2 * WAverage(price, halvedLength);
Value2 = WAverage(price, length);
Value3 = WAverage((Value1 - Value2), sqrRootLength);

jtHMA = Value3;




#function PercentR
inputs: Length( numericsimple ) ;
variables: HH( 0 ), Divisor( 0 ) ;

HH = Highest( High, Length ) ;
Divisor = HH - Lowest( Low, Length ) ;

if Divisor <> 0 then 
	PercentR = 100 - ( ( HH - Close ) / Divisor ) * 100
else
	PercentR = 0 ;
	

	

#function WAverage
inputs: 
	Price( numericseries ), 
	Length( numericsimple ) ; { will get divide-by-zero error if Length = 0 }

variables: 
	WtdSum( 0 ), 
	CumWt( 0 ) ;

WtdSum = 0 ;
for Value1 = 0 to Length - 1 
	begin
	WtdSum = WtdSum + ( Length - Value1 ) * Price[Value1] ;
	end ;
CumWt = ( Length + 1 ) * Length * .5 ;
WAverage = WtdSum / CumWt ;
Attached Files
File Type: txt %R wtih 2 HMA.txt (1.6 KB, 11 views)
trader273 is offline  
Reply With Quote
The Following User Says Thank You to trader273 For This Useful Post:
sunilrohira (08-29-2009)

Reply

Thread Tools
Display Modes Help Others By Rating This Thread
Help Others By Rating This Thread:


Similar Threads
Thread Thread Starter Forum Replies Last Post
Req Coder to Code This sillykiddo Coding Forum 0 01-02-2009 11:52 PM
Tradestation Code Help ephi144 Coding Forum 3 11-29-2008 08:05 PM
Anyone Use the HMAs ephi144 Beginners Forum 8 11-25-2008 05:03 PM
Quick TS Code Help Please ephi144 Coding Forum 1 11-10-2008 01:15 PM
Help To Code My EA pepe1 Coding Forum 0 06-24-2008 01:41 PM

All times are GMT -4. The time now is 12:29 PM.
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
CS to VB integration by DeskLancer
©2006-2011 Traders Laboratory, All Rights Reserved.