NexusFi: Find Your Edge


Home Menu

 





Price within X percent of high within Y days


Discussion in ThinkOrSwim

Updated
    1. trending_up 10,340 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:	394
Size:	4.0 KB
ID:	180049  
Reply With Quote

Can you help answer these questions
from other members on NexusFi?
About a successful futures trader who didnt know anythin …
Psychology and Money Management
Cheap historycal L1 data for stocks
Stocks and ETFs
Quantum physics & Trading dynamics
The Elite Circle
MC PL editor upgrade
MultiCharts
Trade idea based off three indicators.
Traders Hideout
 
  #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