Big Mike's Trading Forum
 

Go Back   Big Mike's Trading Forum

> Trading Forums > Platforms and Indicators > TradeStation > EasyLanguage Programming


Notices
     

Trying to Program WillTrend by Larry Williams
Started:February 15th, 2012 (08:30 PM) by kottgolf Views / Replies:4,526 / 11
Last Reply:December 2nd, 2013 (06:23 PM) Attachments:7

Welcome to Big Mike's Trading Forum.

Welcome, Guest!

This forum was established to help traders by openly sharing indicators, strategies, methods, trading journals and discussing the psychology of trading.

BMT is fundamentally different than most other trading forums:
  • We work extremely hard to keep things positive on our forums.
  • We do not tolerate rude behavior, trolling, or vendor advertising in posts.
  • We firmly believe in openness and encourage sharing. The holy grail is within you, it is not something tangible you can download.
  • We expect our members to participate and become a part of the community. Help yourself by helping others.


You'll need to register in order to view the content of the threads and start contributing to our community. It's free and simple, and we will never resell your private information.

-- Big Mike
     

Reply
 7  
 
Thread Tools Search this Thread

Trying to Program WillTrend by Larry Williams

Old February 15th, 2012, 08:30 PM   #1 (permalink)
Trading Apprentice
Montreal
 
Trading Experience: Intermediate
Platform: Multicharts
Favorite Instrument: Stocks
 
Posts: 13 since Feb 2012
Thanks: 2 given, 6 received

Trying to Program WillTrend by Larry Williams

Hi,
I am trying to program Larry Williams' WillTrend with Easylanguage.
I have three different sources that explain the indicator differently:

#1
High/Lowest midprice + Average True Range of the Past 66 Bars X 2.236
High/Lowest midprice - Average True Range of the Past 66 Bars X 2.236

#2
High/Lowest midprice + Average True Range of the Past 66 Bars X 3.2
High/Lowest midprice - Average True Range of the Past 66 Bars X 3.2

#3
And my friend who has trade navigator and is using WillTrend has the parameter at (2.5, 10) on his chart. (the code is hidden)

Does anybody have this indicator programmed or knows which formula Larry Williams uses?

Reply With Quote
     

Old February 15th, 2012, 08:30 PM   #2 (permalink)
Quick Summary
Quick Summary Post

Quick Summary is created and edited by users like you... Add FAQ's, Links and other Relevant Information by clicking the edit button in the lower right hand corner of this message.

     

Old February 16th, 2012, 01:34 AM   #3 (permalink)
Aspiring retail quant
The Netherlands
 
Trading Experience: None
Platform: MultiCharts .NET, R/RStudio
Broker/Data: LMAX, InteractiveBrokers/IQFeed
Favorite Instrument: Exchange-traded derivates
 
Posts: 603 since Apr 2010
Thanks: 2,232 given, 510 received



kottgolf View Post
Does anybody have this indicator programmed or knows which formula Larry Williams uses?

It doesn't really matter which settings are the "good" ones, since these probably need to be adapted to your own trading style, instrument, backtest results, etc.

However, what does matter is your explanation of the Will Trend indicator.

How should this be coded?


kottgolf View Post
High/Lowest midprice + Average True Range of the Past 66 Bars X 2.236
High/Lowest midprice - Average True Range of the Past 66 Bars X 2.236

1 - Is this the High of the bar divided by the lowest midprice? If so, over which period is this lowest mid price calculated (66?)?
Or...
2 - Is this the Highest midprice divided by the lowest midprice, and if so, over which period?
Or...
3 - Should the indicator use the high or low midprice over some period depending on some condition? If so, which is the period and which is the condition?

Also, a screenshot would be very helpful in order to code it. I already have point 3 coded, but without a screenshot I have no way of telling if this is something that you mean.

Reply With Quote
     
The following user says Thank You to Jura for this post:
     

Old February 16th, 2012, 07:09 AM   #4 (permalink)
Trading Apprentice
Montreal
 
Trading Experience: Intermediate
Platform: Multicharts
Favorite Instrument: Stocks
 
Posts: 13 since Feb 2012
Thanks: 2 given, 6 received

Hi Jura,
I attached a screenshot from my friend of AAPL on the close on Friday. As you can see, the WillTrend is similar to Wilder's volatility stop (WillTrend changes when crossed by the price).

In the screenshot, you can see the input K=2.5 and Numbars=10. I still think the formula is close to :
Highest/Lowest midprice + Average True Range of the Past 66 Bars X 2.236
Highest/Lowest midprice - Average True Range of the Past 66 Bars X 2.236

Possibly the Numbars=10 (in the screenshot) is the range for the highest/lowest midprice. (It cannot be ATR of the past 10 bars since the WillTrend of AAPL attached would not lag as nicely, 10 is too short to produce such a nice trailing stop as shown on the chart)

To answer your questions:
1- I am not sure about the period. It might be 10 or 66.
2- The only information I have is that it is the Highest/Lowest midprice. (sorry I wrote high/lowest midprice in the first message)
3- I am not aware that there is a condition. As you can see on the screen shot, the WillTrend should never retrace when price retraces. That is what makes this tool so good. As the price pullbacks, the WillTrend will not backoff like Wilder's Volatility stop.

Is the screenshot of any help?
Maybe I can get you another one.

Thanks

Attached Thumbnails
Trying to Program WillTrend by Larry Williams-willtrendmc1.jpg  
Reply With Quote
     
The following 3 users say Thank You to kottgolf for this post:
     

Old February 16th, 2012, 12:29 PM   #5 (permalink)
Aspiring retail quant
The Netherlands
 
Trading Experience: None
Platform: MultiCharts .NET, R/RStudio
Broker/Data: LMAX, InteractiveBrokers/IQFeed
Favorite Instrument: Exchange-traded derivates
 
Posts: 603 since Apr 2010
Thanks: 2,232 given, 510 received

Current BMT User Poll

Should sim traders that pretend to trade cash be allowed on BMT?

 
Thanks for the additional clarification Kottgolf, the screenshot definitely helps.

This is what I so far came up with..
 
Code
Inputs:
    Period(66),
    ATRMultiplication(2.236);
    
Variables:
    upperBand(0), lowerBand(0), midPrice(0), atr(0);

midPrice = (High + Low) * 0.50;
atr         = AvgTrueRange(Period) * ATRMultiplication;

// If we use two bands, there are no crossover with the Close, so
//        that probably isn't good.    
upperBand = Highest(midPrice, Period) + atr;
lowerBand = Lowest(midPrice, Period) - atr; 

// If we use two bands, and divide the highest by the lowest, we'll get the wrong results
//        with very low values (due to the division).
upperBand = IFF(Lowest(midPrice, Period) = 0, upperBand[1], (Highest(midPrice, Period) / Lowest(midPrice, Period)) + atr);
lowerBand = IFF(Lowest(midPrice, Period) = 0, lowerBand[1], (Highest(midPrice, Period) / Lowest(midPrice, Period)) - atr);

// If we use the four values, only the two middle lines (value2 & value3) 
//        are being triggered by the price.
value1 = Highest(midPrice, Period) + atr;
value2 = Highest(midPrice, Period) - atr;

value3 = Lowest(midPrice, Period) + atr;
value4 = Lowest(midPrice, Period) - atr;

// So, let's flip the line depending on the close:
if (Close > value3) then
    Plot1(MaxList(value2, value2[1]))
else
    Plot1(MinList(value3, value3[1]));
..but if you look at a screenshot, the indicator is very jaggy (compared with your friend's chart):

Please register to view the post attachment(s), image(s), or screenshot(s) - it's simple and free.


That doesn't look right.

Perhaps he uses some kind of moving average to smooth it? (Which is more thinking aloud then a specific question to you).


Btw, I see an "Edit Function" button in your friend's chart - I assume it's protected and he can't copy the function to you?

Reply With Quote
     
The following 2 users say Thank You to Jura for this post:
     

Old February 16th, 2012, 12:44 PM   #6 (permalink)
Trading Apprentice
Montreal
 
Trading Experience: Intermediate
Platform: Multicharts
Favorite Instrument: Stocks
 
Posts: 13 since Feb 2012
Thanks: 2 given, 6 received

Thanks for the quick reply Jura.
Your code looks very good.
I think I am going have to try many variations.
Yes the function for WillTrend on trade navigator is locked unfortunately.

Maybe he uses the 10 as a moving average to smooth it? Since the only reason I know there is a 10 somewhere is by looking at the inputs available for change in the AAPL trade navigator screenshot. (2.5 and 10)

The one thing I noticed with your chart of the indicator is that your indicator pulls away with the price sometimes eg. if the price is trending lower and the Indicator is above, if the price reverses and heads higher, the indicator should only stay flat or go lower, never go higher. Unless price goes above the indicator which then flips.

How would this be done? This is part of what makes this tool so great, you never give back too much profit.
Also, where would you smooth using a moving average? Smooth the Indicator by taking the previous 10 average?

Thanks again.

Reply With Quote
     

Old February 16th, 2012, 01:02 PM   #7 (permalink)
Aspiring retail quant
The Netherlands
 
Trading Experience: None
Platform: MultiCharts .NET, R/RStudio
Broker/Data: LMAX, InteractiveBrokers/IQFeed
Favorite Instrument: Exchange-traded derivates
 
Posts: 603 since Apr 2010
Thanks: 2,232 given, 510 received


kottgolf View Post
Maybe he uses the 10 as a moving average to smooth it? Since the only reason I know there is a 10 somewhere is by looking at the inputs available for change in the AAPL trade navigator screenshot. (2.5 and 10)

The one thing I noticed with your chart of the indicator is that your indicator pulls away with the price sometimes eg. if the price is trending lower and the Indicator is above, if the price reverses and heads higher, the indicator should only stay flat or go lower, never go higher. Unless price goes above the indicator which then flips.

How would this be done? This is part of what makes this tool so great, you never give back too much profit.
Also, where would you smooth using a moving average? Smooth the Indicator by taking the previous 10 average?

Perhaps we can use the ATR Trailing Stop Modified by Sylvian Vervoort, which looks like:
Please register to view the post attachment(s), image(s), or screenshot(s) - it's simple and free.


And has this code:
 
Code
{ ATR Modified with Trailing Stops - by Sylvain Vervoort.
    MetaStock code by http://trader-online.tk/MSZ/e-w-ATR_Modified_with_Trailing_Stops.html 
    Converted to MultiCharts EasyLanguage by TradingCode.Net}

Inputs: 
    Period(5),
    ATRMultiplication(3.5);
    
Variables:
    HiLo(0), Href(0), Lref(0), diff1(0), diff2(0), atrMod(0), loss(0), trail(0);
    
value1 = 1.5 * Average(High - Low, Period);
value2 = High - Low;

HiLo    = IFF(value2 < value1, value2, value1);

Href     = IFF(Low <= High[1], High - Close[1], ( (High - Close[1]) - (Low - High[1]) ) / 2);
Lref    = IFF(High >= Low[1], Close[1] - Low,  ( (Close[1] - Low) - (Low[1] - High)  ) / 2);

diff1    = MaxList(HiLo, Href);
diff2 = MaxList(diff1, Lref);

atrMod = XAverage(diff2, Period);
loss     = ATRMultiplication * atrMod;

trail = IFF(Close > trail[1] and Close[1] > trail[1], MaxList(trail[1], (Close - loss)),
            IFF(Close < trail[1] and Close[1] < trail[1], MinList(trail[1], (Close + loss)),
             IFF(Close > trail[1], Close - loss, Close + loss)));
             
Plot1(trail, "ATR Trailing Stop", Default, Default, 2);

if Close > trail then
    SetPlotColor(1, green)
else
    SetPlotColor(1, red);
If we use that code on the (current) interpretation of WillTrend, we get this (with 66 periods):

Please register to view the post attachment(s), image(s), or screenshot(s) - it's simple and free.


With this code:

 
Code
Inputs:
    Period(66),
    ATRMultiplication(2.236);
    
Variables:
    upperBand(0), lowerBand(0), midPrice(0), atr(0), trail(0);

midPrice = (High + Low) * 0.50;
atr         = AvgTrueRange(Period) * ATRMultiplication;

upperBand = Highest(midPrice, Period) - atr;
lowerBand = Lowest(midPrice, Period) + atr;

trail = IFF(Close > trail[1] and Close[1] > trail[1], MaxList(trail[1], lowerBand),
            IFF(Close < trail[1] and Close[1] < trail[1], MinList(trail[1], upperBand),
             IFF(Close > trail[1], lowerBand, upperBand)));

Plot1(trail);

if (Close > trail) then
    SetPlotColor(1, green)
else
    SetPlotColor(1, red);
However, I'm still doubtful about this, since when the above code is set to a low setting like 10, the lines become very jaggy and not looking like the example chart.

Reply With Quote
     
The following user says Thank You to Jura for this post:
     

Old February 16th, 2012, 02:50 PM   #8 (permalink)
Trading Apprentice
Montreal
 
Trading Experience: Intermediate
Platform: Multicharts
Favorite Instrument: Stocks
 
Posts: 13 since Feb 2012
Thanks: 2 given, 6 received

Alright now we've both got some code written.
AAPL is a picture of your code. As you can see, it doesn't lag higher at the end.
I played around with some of the code and got some interesting results.

AAPL2 is a picture with my code. (I tweaked your code, using Highest Value + Lowest Value (in past 10 bars)/2 instead of using the highest midprice and lowest mid price.



 
Code
Inputs: 
	Period(66),
	ATRMultiplication(2.236),
	MidPriceVar(10);

Variables:
 	upperBand(0), lowerBand(0), atr(0), trail(0),
 	midPrice1(0), midPrice2(0), midPrice(0);


atr         = AvgTrueRange(Period) * ATRMultiplication;



midPrice1=Lowestvalue(low,MidPriceVar);
midPrice2= Highestvalue(high,MidPriceVar);
midPrice= (midPrice1 + midPrice2)/2;

lowerBand= midPrice + atr;
upperBand=  midPrice - atr;


trail = IFF(Close > trail[1] and Close[1] > trail[1], MaxList(trail[1], upperBand),
            IFF(Close < trail[1] and Close[1] < trail[1], MinList(trail[1], lowerBand),
             IFF(Close > trail[1], upperBand, lowerBand)));
             


Plot1(trail);

if (Close > trail) then
    SetPlotColor(1, green)
else
    SetPlotColor(1, red);

Attached Thumbnails
Trying to Program WillTrend by Larry Williams-aapl.jpg   Trying to Program WillTrend by Larry Williams-aapl2.jpg  
Reply With Quote
     
The following user says Thank You to kottgolf for this post:
     

Old February 17th, 2012, 11:24 AM   #9 (permalink)
Trading Apprentice
Montreal
 
Trading Experience: Intermediate
Platform: Multicharts
Favorite Instrument: Stocks
 
Posts: 13 since Feb 2012
Thanks: 2 given, 6 received

What do you think Jura?

Reply With Quote
     

Old February 18th, 2012, 01:22 PM   #10 (permalink)
Aspiring retail quant
The Netherlands
 
Trading Experience: None
Platform: MultiCharts .NET, R/RStudio
Broker/Data: LMAX, InteractiveBrokers/IQFeed
Favorite Instrument: Exchange-traded derivates
 
Posts: 603 since Apr 2010
Thanks: 2,232 given, 510 received



kottgolf View Post
Alright now we've both got some code written.
AAPL is a picture of your code. As you can see, it doesn't lag higher at the end.
I played around with some of the code and got some interesting results.

AAPL2 is a picture with my code. (I tweaked your code, using Highest Value + Lowest Value (in past 10 bars)/2 instead of using the highest midprice and lowest mid price.

That seems correct to me. This version seems to capture the trend better than the previous versions did (and probably also better than the ATR Trailing Stop Modified code).

For example:
Please register to view the post attachment(s), image(s), or screenshot(s) - it's simple and free.


We'll probably never know the exact code for Larry William's WillTrend indicator (as far as I know, he hasn't shared it somewhere), but I think that using your interpretation of mid price (with the Highest(high) and Lowest(low)) comes very close to the reasoning behind the WillTrend indicator.

Thanks Kottgolf!

Reply With Quote
     
The following user says Thank You to Jura for this post:
     

Reply



Tags
aapl, atr, backtest, backtesting, bars, change, chart, close, code, color, condition, crossovers, easylanguage, formula, function, high, hilo, indicator, indicators, instrument, lagging, larry williams, line, metastock, ml, moving average, multicharts, neoticker, order, parameter, period, plot, price, profit, program, programming, pullbacks, puts, question, questions, range, settings, stop, stops, trade, trader, tradestation, trading, trailing, trailing stop, trailing stops, trend, values, volatility, willtrend
     

Big Mike's Trading Forum > Trading Forums > Platforms and Indicators > TradeStation > EasyLanguage Programming > Trying to Program WillTrend by Larry Williams

Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads
Thread Thread Starter Forum Replies Last Post
Larry Williams Idea Kush NinjaTrader Programming 10 April 7th, 2014 03:36 AM
Larry Levin's Secret of Traders (www.tradingadvantage.com) Cloudy Vendors and Product Reviews 8 February 4th, 2014 11:12 PM
BlackRock's Larry Fink Wants to Be 100% in Stocks Quick Summary News and Current Events 3 June 29th, 2011 09:20 AM
Williams Acc Dist indicator not plotting buzzsaw NinjaTrader Programming 4 June 16th, 2011 02:54 AM


All times are GMT -4. The time now is 06:07 PM.

Powered by vBulletin®
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
Copyright © 2014 by Big Mike Trading. All information is for educational use only and is not investment advice.
There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
 
no new posts

Page generated 2014-04-23 in 0.31 seconds with 20 queries on phoenix via your IP 50.19.33.5