Price Headley's Percent R Thinkscript study - ThinkOrSwim Programming | futures trading

Go Back

> Futures Trading, News, Charts and Platforms > Platforms and Indicators > ThinkOrSwim > ThinkOrSwim Programming

Price Headley's Percent R Thinkscript study
Started:May 16th, 2013 (03:50 PM) by ikholobayev Views / Replies:1,881 / 1
Last Reply:May 22nd, 2013 (05:21 PM) Attachments:0

Welcome to

Welcome, Guest!

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

We are 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

Thread Tools Search this Thread

Price Headley's Percent R Thinkscript study

Old May 16th, 2013, 03:50 PM   #1 (permalink)
Trading Apprentice
Durham, NC, USA
Futures Experience: Intermediate
Platform: Thinkorswim
Favorite Futures: Stocks
Posts: 1 since May 2013
Thanks: 0 given, 0 received

Price Headley's Percent R Thinkscript study


I am a new member of this forum. I am trying to create a script based on Price Headley's %R method.

Here is the description of the method:

Williams %R is set to length = 30 days

When %R crosses above -20 that is considered a bullish setup bar.
The closing price of any one of the next five bars must close above the bullish setup bar's high. When that happens it is considered to be a favorable condition for a long entry.

Here is my script:
declare upper;

def WR = WilliamsPercentR("length" = 30);
def SetupBar = if WR crosses above -20 then high else double.NaN;
plot ConfirmBar = close > SetupBar within 5 bars;


The line highlighted in red doesn't work for some reason. I can overcome this with brute force by adding the following statements (but I don't like it very much):
declare upper;

def WR = WilliamsPercentR("length" = 30);
def SetupBar = if WR crosses above -20 then high else double.NaN;
plot ConfirmBar1 = close > SetupBar[1];
plot ConfirmBar2 = close > SetupBar[2];
plot ConfirmBar3 = close > SetupBar[3];
plot ConfirmBar4 = close > SetupBar[4];
plot ConfirmBar5 = close > SetupBar[5];






The brute force code results in multiple arrows appearing each time when a new bar makes a higher close in relation to the setup bar's high. I want the arrow to appear only once when that happens (be it on the 1st, 2nd ... 5th candle).

Please register on to view futures trading content such as post attachment(s), image(s), and screenshot(s).

Could anyone please help me with this? Thanks!

Last edited by ikholobayev; May 16th, 2013 at 04:17 PM.
Reply With Quote

Old May 22nd, 2013, 05:21 PM   #2 (permalink)
Knowledge Seeker
Dubai, UAE
Futures Experience: Intermediate
Platform: TOS, TradeStation
Broker/Data: OX, TradeStation
Favorite Futures: Stocks & Basic Options
RedK's Avatar
Posts: 171 since May 2012
Thanks: 44 given, 134 received

I would do it like this.. it's not the optimum code but simple.. may inspire a different approach for you.. the entry level will be visually painted for you and you get a single arrow up (but for each new crossing though).
cheers, K

declare upper;

def WR = WilliamsPercentR("length" = 30);
plot SetupBar = WR crosses above -20 ;

plot LongEntry = if SetupBar then high
else if SetupBar[1] then high[1] 
else if SetupBar[2] then high[2] 
else if SetupBar[3] then high[3] 
else if SetupBar[4] then high[4]  else double.NaN;

LongEntry.setpaintingStrategy (paintingstrategy.DASHES);
LongEntry.Setlineweight (2); LongEntry.setdefaultcolor(color.cyan);


Reply With Quote

Reply > Futures Trading, News, Charts and Platforms > Platforms and Indicators > ThinkOrSwim > ThinkOrSwim Programming > Price Headley's Percent R Thinkscript study

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Upcoming Webinars and Events (4:30PM ET unless noted)

An Afternoon with FIO trader bobwest

Elite only

NinjaTrader 8: Programming Profitable Trading Edges w/Scott Hodson

Elite only

Anthony Drager: Executing on Intermarket Correlations & Order Flow, Part 2

Elite only

Adam Grimes: Five critically important keys to professional trading

Elite only

Machine Learning Concepts w/FIO member NJAMC

Elite only

MarketDelta Cloud Platform: Announcing new mobile features

Dec 1

NinjaTrader 8: Features and Enhancements

Dec 6

Similar Threads
Thread Thread Starter Forum Replies Last Post
Apple's Stock Price Is Down Nearly 10 Percent—Time to Buy? Quick Summary News and Current Events 0 October 9th, 2012 02:20 PM
Possible study with ThinkScript? TonyB ThinkOrSwim 0 March 4th, 2012 10:27 PM
S&P Intraday Price Study Jeff65 Index Futures Trading 7 January 20th, 2012 10:38 PM
EasyLanguage Price Action PaintBar Study Big Mike EasyLanguage Programming 5 April 18th, 2010 12:28 AM

All times are GMT -4. The time now is 09:32 PM.

Copyright © 2016 by 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 2016-10-22 in 0.08 seconds with 20 queries on phoenix via your IP