NexusFi: Find Your Edge


Home Menu

 





Price Headley's Percent R Thinkscript study


Discussion in ThinkOrSwim

Updated
    1. trending_up 4,044 views
    2. thumb_up 0 thanks given
    3. group 2 followers
    1. forum 1 posts
    2. attach_file 0 attachments




 
Search this Thread

Price Headley's Percent R Thinkscript study

  #1 (permalink)
ikholobayev
Durham, NC, USA
 
Posts: 1 since May 2013
Thanks Given: 0
Thanks Received: 0

Hello,

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:
 
Code
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;

ConfirmBar.SetPaintingStrategy(PaintingStrategy.Boolean_ARROW_UP);
ConfirmBar.SetDefaultColor(GetColor(1));
ConfirmBar.SetLineWeight(1);

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):
 
Code
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];

ConfirmBar1.SetPaintingStrategy(PaintingStrategy.Boolean_ARROW_UP);
ConfirmBar1.SetDefaultColor(GetColor(5));
ConfirmBar1.SetLineWeight(1);

ConfirmBar2.SetPaintingStrategy(PaintingStrategy.Boolean_ARROW_UP);
ConfirmBar2.SetDefaultColor(GetColor(5));
ConfirmBar2.SetLineWeight(1);

ConfirmBar3.SetPaintingStrategy(PaintingStrategy.Boolean_ARROW_UP);
ConfirmBar3.SetDefaultColor(GetColor(1));
ConfirmBar3.SetLineWeight(1);

ConfirmBar4.SetPaintingStrategy(PaintingStrategy.Boolean_ARROW_UP);
ConfirmBar4.SetDefaultColor(GetColor(1));
ConfirmBar4.SetLineWeight(1);

ConfirmBar5.SetPaintingStrategy(PaintingStrategy.Boolean_ARROW_UP);
ConfirmBar5.SetDefaultColor(GetColor(1));
ConfirmBar5.SetLineWeight(1);

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).




Could anyone please help me with this? Thanks!

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Trade idea based off three indicators.
Traders Hideout
MC PL editor upgrade
MultiCharts
REcommedations for programming help
Sierra Chart
Exit Strategy
NinjaTrader
ZombieSqueeze
Platforms and Indicators
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Spoo-nalysis ES e-mini futures S&P 500
33 thanks
Just another trading journal: PA, Wyckoff & Trends
28 thanks
Tao te Trade: way of the WLD
23 thanks
Bigger Wins or Fewer Losses?
23 thanks
GFIs1 1 DAX trade per day journal
21 thanks
  #2 (permalink)
 
RedK's Avatar
 RedK 
Dubai, UAE
 
Experience: Intermediate
Platform: TOS, TradeStation
Broker: OX, TradeStation
Trading: Stocks & Basic Options
Posts: 171 since May 2012
Thanks Given: 44
Thanks Received: 145

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

 
Code
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);

SetUpBar.SetPaintingStrategy(PaintingStrategy.Boolean_ARROW_UP);
SetUpBar.SetDefaultColor(color.cyan);
SetUpBar.SetLineWeight(1);

Visit my NexusFi Trade Journal Reply With Quote




Last Updated on May 22, 2013


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
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.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts