NexusFi: Find Your Edge


Home Menu

 





Price within X percent of high within Y days


Discussion in ThinkOrSwim

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




 
Search this Thread

Price within X percent of high within Y days

  #1 (permalink)
eddieo
New York, NY
 
Posts: 4 since Feb 2015
Thanks Given: 1
Thanks Received: 0

TOS offers a "Near_High_Lows" study for its scans, image attached.

Parameters on the built in version of this are "Current price is within [X] percent of the [252] period [High/Low]"

I'm looking to customize this to add a "within n bars" parameter. Could anyone give me a thinkscript tip on how to do this?


Thanks,
EddieO


P.S. The ThinkScript behind the default study is:


#Wizard text: The current price
##Wizard input: price
#Wizard text: is within
#Wizard input: choice1
#Wizard text: % of the
#Wizard input: period
#Wizard text: period
#Wizard input: choice

def price = close;
input period = 252;
input choice = {default High, Low};
input choice1 = 3;

def hi = high;
def lo = low;

plot scan;
switch (choice) {
case High:
scan = price >= highest(hi,period)* ((100 - choice1) /100);
case Low:
scan = price <= lowest(lo,period)* ((100 + choice1) /100);;
}

Attached Thumbnails
Click image for larger version

Name:	Capture.PNG
Views:	391
Size:	4.0 KB
ID:	180049  
Reply With Quote

Can you help answer these questions
from other members on NexusFi?
REcommedations for programming help
Sierra Chart
Trade idea based off three indicators.
Traders Hideout
Exit Strategy
NinjaTrader
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
MC PL editor upgrade
MultiCharts
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Just another trading journal: PA, Wyckoff & Trends
35 thanks
Tao te Trade: way of the WLD
24 thanks
Bigger Wins or Fewer Losses?
19 thanks
GFIs1 1 DAX trade per day journal
16 thanks
Spoo-nalysis ES e-mini futures S&P 500
14 thanks
  #2 (permalink)
DaveDoggyDogg
Los Angeles,CA USA
 
Posts: 16 since Mar 2017
Thanks Given: 0
Thanks Received: 7

I figured ide add this for people that like your thinkscript code for thinkorswim ( TOS ), the code below is to add a COLUMN in the COLUMNS that will display the how far the current price is from the days HIGH in percentage format.

COLUMN CODE BELOW: PERCENT FROM CURRENT DAYS HIGH
 
Code
plot x=round(100*((close/high)-1),1);

Reply With Quote
  #3 (permalink)
DaveDoggyDogg
Los Angeles,CA USA
 
Posts: 16 since Mar 2017
Thanks Given: 0
Thanks Received: 7


If you want it charted, here is a STUDY that will allow u to chart it in the top left corner. Of the TOS chart.

CHART THE PERCENT FROM HIGH IN CORNER (customizable)
Thinkscript STUDY CODE BELOW:

 
Code
#HINT: This chart label shows the percent change down from the high.above \n\n IMPORTANT: If a new IPO you need to change the length to max of number of days since IPO release.

input length = 252;  #HINT length: There are 252 trading days in a year or change to 1 for DAYS high or 5 for weekly high
input show_label = yes;
input Label_Color_Choice = {"magenta", "green", "pink", "cyan", "orange", default "red", "blue", "gray", "violet"};

def top = highest(high(period = AggregationPeriod.DAY), length);
def prctDrop = ((close(period = AggregationPeriod.DAY)/top)-1);

def NewHigh = high == top;

AddLabel(show_label and !NewHigh, "Percent down off high: ( " +  AsPercent(prctDrop) + " )  ", GetColor(Label_Color_Choice));

AddLabel(show_label and NewHigh, "new 52-week high TODAY", (CreateColor(51, 204, 0)));

Reply With Quote




Last Updated on March 30, 2017


© 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