https://usethinkscript.com/threads/ipo-stocks.4379/#post-40322I want to create a study to use in the stock scanner that shows stocks trading for less than 200 days (they don't have a 200 moving average yet).
My attempt to code this shows stocks that have just started trading for 200 days (DOCS for instance), but that's not what I'm looking for. Any help would be greatly appreciated!Code:plot Data = compoundvalue(1, if IsNan(close[200]) then 1 else 0,close);
Join useThinkScript to post your question to a community of 21,000+ developers and traders.
Thanks, so I guess it is not possible.Moved you to this thread. Members have provided what they have used.
def test = Open()[0];
AddCloud(if highest(test, 1) > 0 then Double.POSITIVE_INFINITY else Double.NaN, if Highest(test, 1) > 0 then Double.NEGATIVE_INFINITY else Double.NaN, Color.RED, Color.GREEN);
AddCloud(if highest(test, 90) > 0 then Double.POSITIVE_INFINITY else Double.NaN, if Highest(test, 90) > 0 then Double.NEGATIVE_INFINITY else Double.NaN, Color.BLUE, Color.CURRENT);
AddCloud(if barnumber()<=90 then Double.POSITIVE_INFINITY else Double.NaN, Double.NEGATIVE_INFINITY, Color.RED, Color.RED);
AddCloud(if between(barnumber(), 90, 180) then Double.POSITIVE_INFINITY else Double.NaN, Double.NEGATIVE_INFINITY, Color.BLUE, Color.BLUE);
AddCloud(if barnumber()<=90 then Double.POSITIVE_INFINITY else Double.NaN, Double.NEGATIVE_INFINITY, Color.RED, Color.RED);
Currently, there is no identifications of "IPO".Hi,
Is there a way to find the lowest and highest daily values of any stock since the beginning of its trading period (IPO)?
I tried using a the Lowest(Low, standard input lookback period) but this doesn't work and returns N/A.
Appreciate any help.
@stock2020 @tradephoricTOS built in scanner - filtering based on IPO date
How can I add a filter to a scanner for including only companies that have been trading for at least X years?
Thanks
Ruby:def ymd = GetYYYYMMDD(); def bn = BarNumber(); def hd = GetMaxValueOffset(high, 252); def begindate = if bn == HighestAll(bn - hd) then ymd else begindate[1]; input days = 90; def enddate = if bn == HighestAll(bn - hd) + days then ymd else enddate[1]; input showlabel = yes; AddLabel(showlabel, " Cloud Range : " + AsPrice(begindate) + " - " + AsPrice(enddate)); input showverticalline = yes; AddVerticalLine(showverticalline and ymd == begindate, ""); AddVerticalLine(showverticalline and ymd == enddate, ""); DefineGlobalColor("Range", Color.RED); input showcloud = yes; AddCloud(if showcloud and Between(bn, HighestAll(bn - hd), HighestAll(bn - hd) + 90) then Double.POSITIVE_INFINITY else Double.NaN, Double.NEGATIVE_INFINITY, GlobalColor("Range"), GlobalColor("Range"));
Def Days; Def Date;
If BarNumber() == 1 {
Date = getyYYYMMDD();
Days = highestall(daysFromDate(Date));
} else {
Date = Date[1];
Days = Days[1];
}
;
Def Days90 =
DaysFromDate(Date) <= 90;
;
Def Days200 =
Days <= 200;
;
AddCloud(
if Days90 and Days200
then Double.POSITIVE_INFINITY
else Double.NaN,
Double.NEGATIVE_INFINITY,
Color.LIGHT_RED
);
The ToS data feeds do not have expiration of lockup period information available to filter on.Is there a way to scan for upcoming end of IPO lockup period?
Since the lockup period ends, I don't want to just scan for x days since IPO. I want to scan for any upcoming expiration of lockup period within x number of days?
or is this info available easily somewhere else?
No new ideas. But your post was moved here as this thread has everything that has been discussed on this forum on this topicI would also like to find a script that will identify stocks with less than 252 trading days. Any new ideas on this topic?
def d = isnaN(open [1]);
plot scan = d;
Hello,
Is there a function that can output the days a stock traded since IPO?
Thanks
It sounds like you are attempting to use barnumber function to find an IPO.I am trying in the following way on a daily aggregation to track IPOs, but it seems not to be working. Can you please suggest @Joshua
Code:def a = isnan(open[1])==1; plot scan = a;
it works on the chart, try to scan, not workable.See if this helps. This is a workaround some of thinkscript's limitations when dealing with symbols opened less than the 'barsago' days. As mentioned, there may be simpler solutions, but this may be what you are requesting. The attached chart shows the same study in both the upper and lower panes.
View attachment 2214Code:#Example Highest Volume within Last barsago #Usethinkscript request #Workaround to handle charts with less than barsago input bars #Sleepyz #Use at least on a 2 YEAR DAILY CHART input barsago = 252; input showlabel = yes; def lastbar = if IsNaN(close[-1]) and !IsNaN(close) then BarNumber() else Double.NaN; def range = CompoundValue(1, if Between(BarNumber(), HighestAll(lastbar) - barsago, HighestAll(lastbar)) then 1 else 0, 1); #Highest Volume on a chart with more bars than barsago def vol = if range[1] == 0 and range == 1 then volume else if volume > vol[1] then volume else vol[1]; def volext = if BarNumber() > HighestAll(lastbar) then volext[1] else vol; def volb = if range == 1 and volume == vol then BarNumber() else Double.NaN; plot v252_end = if HighestAll(lastbar) > barsago and BarNumber() >= HighestAll(volb) then volext else Double.NaN; v252_end.setdefaultColor(color.yellow); v252_end.setpaintingStrategy(paintingStrategy.HORIZONTAL); #Highest Volume on a chart with less bars than barsago def r = if HighestAll(lastbar) < barsago then 1 else 0; def volh = if BarNumber() == 1 and !IsNaN(range) then volume else if volume > volh[1] then volume else volh[1]; def volhext = if BarNumber() > HighestAll(lastbar) then volhext[1] else volh; def volb1 = if volume == volh then barnumber() else Double.NaN; plot v1_end = if isnan(r) or r then volhext else double.nan; v1_end.setdefaultColor(color.yellow); v1_end.setpaintingStrategy(paintingStrategy.HORIZONTAL); AddLabel(showlabel, "Highest Volume" + (if r==1 then " Less than " else " ") + barsago + " days ago == " + (if r==1 then volh else vol), Color.YELLOW); addverticalLine(if r==1 then barnumber()==highestall(volb1) else barnumber()==highestall(volb),"",color.yellow);
it works on the chart, try to scan, not workable.
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.