Join useThinkScript to post your question to a community of 21,000+ developers and traders.
input count = 5;
def l = low(period = aggregationperiod.day);
def h = high(period = aggregationperiod.day);
def FiveBarLow = lowest(l,count);
def FiveBarHigh = highest(h,count);
AddLabel(1,"Lowest in Last 5 Days: " + FiveBarLow, color.white);
AddLabel(1,"Highest in Last 5 Days: " + FiveBarHigh, color.white);
Standard Deviation Bands... StdDev...hello ive been trying to find an indicator that would show me the range of a stock. for example if a stock opens at 4.00 and the high is 5.00 i want to know the range of that move. ive tried to make a code from it with no success, if anyone knows how to make this into a code i would truly appreciate any help with this.
hello ive been trying to find an indicator that would show me the range of a stock. for example if a stock opens at 4.00 and the high is 5.00 i want to know the range of that move. ive tried to make a code from it with no success, if anyone knows how to make this into a code i would truly appreciate any help with this.
#Price Change Difference from Open to High of Day
# By XeoNoX via usethinkscript.com
input timeFrame = {default DAY, WEEK, MONTH};
def high1 = high(period = timeFrame);
def open1 = open(period = timeFrame);
def x = (high1 - open1);
def rounded = Round(x);
AddLabel(yes, "High to Open Change: " + (x), if x > 0 then Color.UPTICK else if x == 0.0 then Color.WHITE else Color.RED);
I am newbie into technicals and looking for a theory/strategy on day trading. After multiple threads and other browsing through different youtube videos. Found out that I am looking kind of Open Range Breakout.
Kind of break the High that was made in first 15-30mins after certain period of time. Found this code to get the high between two timeframes.
# To find High for in first 30 mins
def Begin1 = 0930;
def End1 = 1000;
# Show Today only? (Default Yes)
def s = ShowTodayOnly;
# Create logic for OR definition:
def ORActive = if SecondsTillTime(End1) > 0 and SecondsFromTime(Begin1) >= 0 then 1 else 0;
# Create logic to paint only current day post-open:
def today = if s == 0 or GetDay() == GetLastDay() and SecondsFromTime(Begin1) >= 0 then 1 else 0;
# Track OR High:
rec ORHigh = if ORHigh[1] == 0 or ORActive[1] == 0 and ORActive == 1 then high else if ORActive and high > ORHigh[1] then high else ORHigh[1];
def O = ORHigh;
def firstHigh = If (O == 0 , na, O);
1. Is that possible to find Highest high/lowest low between two given time in a day (in a min chart). Ex: High between 10AM to 11AM)
2. Is that possible to find Highest High/Lowest Low between a given time in a day (in a min chart) and X number of candles after this time
3. Is that possible to find Highest High/Lowest Low between a given time in a day (in a min chart) and X number of candles before this time
Appreciate your help on this.
Ruby:input time = 1000; input bars = 5;#Hint bars: Must be greater than 1 for Clouds to appear input include_time_bar = no;#Hint include_time_bar: yes = in high/low commputations input show_clouds = yes; input show_vertical = yes; def bn = BarNumber(); def bn1 = if SecondsFromTime(time) == 0 then bn else bn1[1]; def toPaint1 = if Between(bn, bn1 + if include_time_bar then 0 else 1, bn1 + bars) then 1 else 0; def topaint = toPaint1[-bars - if include_time_bar then 0 else 1]; def rth = secondsfromTime(time)<0 and gettime()<=regularTradingend(getyyyYMMDD()); addverticalLine(show_vertical and bn == bn1, " Time is " + asprice(time), color.white, stroke = Curve.FIRM); #Highs/Lows of x bars before Time--------------------------------------------- def dayh = if topaint[1] == 0 and topaint == 1 then high else if topaint == 1 then Max(high, dayh[1]) else 0; def dayhi = if topaint[1] == 1 and topaint == 0 then dayh[1] else dayhi[1]; def dayl = if topaint[1] == 0 and topaint == 1 then low else if topaint == 1 then Min(low, dayl[1]) else 0 ; def daylo = if topaint[1] == 1 and topaint == 0 then dayl[1] else daylo[1]; def up = if topaint then dayhi[-bars - 1] else Double.NaN; def down = if topaint then daylo[-bars - 1] else Double.NaN; AddCloud(if !show_clouds then Double.NaN else up, down, Color.LIGHT_GRAY); input show_Plots_before_highs_lows = yes; plot p_dayhi = if !show_Plots_before_highs_lows or rth then Double.NaN else dayhi; p_dayhi.SetPaintingStrategy(PaintingStrategy.HORIZONTAL); p_dayhi.SetDefaultColor(Color.CYAN); plot p_daylo = if !show_Plots_before_highs_lows or rth then Double.NaN else daylo; p_daylo.SetPaintingStrategy(PaintingStrategy.HORIZONTAL); p_daylo.SetDefaultColor(Color.MAGENTA); #Highs/Lows of x Bars after Time------------------------------------------------- def dayh1 = if toPaint1[1] == 0 and toPaint1 == 1 then high else if toPaint1 == 1 then Max(high, dayh1[1]) else 0; def dayhi1 = if toPaint1[1] == 1 and toPaint1 == 0 then dayh1[1] else dayhi1[1]; def dayl1 = if toPaint1[1] == 0 and toPaint1 == 1 then low else if toPaint1 == 1 then Min(low, dayl1[1]) else 0 ; def daylo1 = if toPaint1[1] == 1 and toPaint1 == 0 then dayl1[1] else daylo1[1]; def up1 = if toPaint1 then dayhi1[-bars - 1] else Double.NaN; def down1 = if toPaint1 then daylo1[-bars - 1] else Double.NaN; AddCloud(if !show_clouds then Double.NaN else up1, down1, Color.LIGHT_ORANGE); input show_Plots_after_highs_lows = yes; plot p_dayhi1 = if !show_Plots_after_highs_lows or rth or topaint or topaint1 or secondsFromTime(time) == 0 then Double.NaN else dayhi1; p_dayhi1.SetPaintingStrategy(PaintingStrategy.HORIZONTAL); p_dayhi1.SetDefaultColor(Color.CYAN); plot p_daylo1 = if !show_Plots_after_highs_lows or rth or topaint or topaint1 or secondsFromTime(time) == 0 then Double.NaN else daylo1; p_daylo1.SetPaintingStrategy(PaintingStrategy.HORIZONTAL); p_daylo1.SetDefaultColor(Color.MAGENTA);
Great script. How can I add ability to choose Aggregation period as in input instead of hard coding it?@imenmyself1234 This will plot the highest and lowest of the past 5 days as labels.
Code:input count = 5; def l = def l = low(period = aggregationperiod.day); def h = high(period = aggregationperiod.day); def FiveBarLow = lowest(l,count); def FiveBarHigh = highest(h,count); AddLabel(1,"Lowest in Last 5 Days: " + FiveBarLow, color.white); AddLabel(1,"Highest in Last 5 Days: " + FiveBarHigh, color.white); def h = high(period = aggregationperiod.day); def FiveBarLow = lowest(l,count); def FiveBarHigh = highest(h,count); AddLabel(1,"Lowest in Last 5 Days: " + FiveBarLow, color.white); AddLabel(1,"Highest in Last 5 Days: " + FiveBarHigh, color.white);
Start a new thread and receive assistance from our community.
useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.
We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.
If you are new, or just looking for guidance, here are some helpful links to get you started.