Join useThinkScript to post your question to a community of 21,000+ developers and traders.
Im looking for a study to identify stocks that have a price gap up from previous days close to current days open by a variable percentage.
Is there a study inside of Think or Swim for this or could someone provide a code for such?
Thanks!!
#The Prior Close has changed by atleast X(Percent) from todays open (both up/bullish and down/bearish)
#Set aggregation to DAY
#For regular trading hours only. Does not include extened hours
#### Change Percent "2.5" to desired percent value
def percent = 2.5;
def price = open;
def length = 1;
def x = 100*(price / price[length]-1);
plot scan = x >= percent or x <= -percent;
is there a way to find gaps from previous day's high (and low) as opposed to previous day's close ? Thanks
did you find one you'd be willing to share?
ToS has a built in scan for this if you simply want a gap on today's daily candle above or below a point on yesterday's daily candle.Im looking for a study to identify stocks that have a price gap up from previous days close to current days open by a variable percentage.
Is there a study inside of Think or Swim for this or could someone provide a code for such?
Thanks!!
Follow these directions?Pre-Market Gap from Previous Close for ThinkorSwim - can't seem to work scanner not been able to work for me..
I tried running this scan, but I am not getting back any results. Essentially I am looking for any gap up or gap down, 100,000 in volume & above $10. Would be ideal for all this to be in one scan. I ran on 5min timeframe and I did see results, but not on daily. I added volume criteria and returned nothing. Hopefully someone can help. IOK, OK, I am an OCD programmer. I modified it slightly to make it a bit more gooder and you don't have to delete anything. Just set the inputs in your scan.
-------------------------------------------------------------------
Code:input percentGap = 0.5; input direction = {default Up, Down}; def dnColor = 5; # red def upColor = 6; # green def arrowColor; def arrowDirection; def marketOpen = 0930; def marketPreOpen = 0730; def marketClose = 1555; def PrevClose = if SecondsTillTime(marketClose) == 0 and SecondsFromTime(marketClose) == 0 then close else PrevClose[1]; def ScanActive = if SecondsTillTime(marketOpen) >= 0 and SecondsFromTime(marketPreOpen) > 0 then 1 else 0; def ll = if ScanActive and !ScanActive[1] then low else if !ScanActive then double.nan else if ScanActive and low < ll[1] then low else ll[1]; def hh = if ScanActive and !ScanActive[1] then high else if !ScanActive then double.nan else if ScanActive and high > hh[1] then high else hh[1]; def isPlot; def gapChange; switch (direction) { case Up: arrowColor = upColor; arrowDirection = PaintingStrategy.BOOLEAN_ARROW_UP; gapChange = 1.0 + (percentGap / 100.0); isPlot = if ScanActive and ll > PrevClose * gapChange then 1 else 0; case Down: arrowColor = dnColor; arrowDirection = PaintingStrategy.BOOLEAN_ARROW_DOWN; gapChange = 1.0 - (percentGap / 100.0); isPlot = if ScanActive and hh < PrevClose * gapChange then 1 else 0; } plot GapPlot = (isPlot == 1); GapPlot.SetPaintingStrategy(arrowDirection); GapPlot.SetDefaultColor(GetColor(arrowColor));
@Stevengo By definition, this is only an intraday indicator.I tried running this scan, but I am not getting back any results. Essentially I am looking for any gap up or gap down, 100,000 in volume & above $10. Would be ideal for all this to be in one scan. I ran on 5min timeframe and I did see results, but not on daily. I added volume criteria and returned nothing. Hopefully someone can help. I
Thank you
I moved your post here. Try the study in the top post and read how other members are using it throughout this threadhi,
I want to know if I can see in the pre-market gap up or down the percentage of the stocks ?
I can't see that before the market is open ? is there any formula ?
thanks
moti
Try this, it should answer what you are looking for.hi,
I want to know if I can see in the pre-market gap up or down the percentage of the stocks ?
I can't see that before the market is open ? is there any formula ?
thanks
moti
The watchlist is the 2nd script in the 1st post of this threadThank You all for these posts. I was able to get the premarket scanner to work! Can you please help me get a script to add to a custom column in the search results that will state the Gap% either up or down? I can then sort by the gap%. Thanks!
Thanks MerryDay. But I tried that in premarket and in regular hours but in the column with the custom formula it returns the value: 9.22337203685477E16. It lists this for all stocks in my search results. I tried pasting all the formulas in this thread into my custom column (hoping to get lucky) but none of them returned the actual gap percentage.The watchlist is the 2nd script in the 1st post of this thread
You are right. That scripts seems to be fubarThanks MerryDay. But I tried that in premarket and in regular hours but in the column with the custom formula it returns the value: 9.22337203685477E16. It lists this for all stocks in my search results. I tried pasting all the formulas in this thread into my custom column (hoping to get lucky) but none of them returned the actual gap percentage.
Hi, Can I request help with this code. I'm trying to get this column to show before/after market hours. I tried a couple of scenarios but could not get it working.This indicator adds a custom column to your watchlist of stocks that show when a gap has formed on the daily chart.
- Red = Gap down
- Green = Gap up
- White = No gap
thinkScript Code
Code:# Billy Bob's Better Gap Indicator for Column alert input Detect_Gaps_By = {default "percent", "dollars"}; input Min_Gap_Size = 1.0; # Define Candle Body def bodyTop = Max(open, close); def bodyBottom = Min(open, close); # Define a gap and its direction def MinGapSize; switch (Detect_Gaps_By) { case "percent": MinGapSize = Min(close[1] * (Min_Gap_Size/100),5); case "dollars": MinGapSize = Min_Gap_Size; }; def GapUp = bodyBottom - bodyTop[1] >= MinGapSize; def GapDown = bodyTop - bodyBottom[1] <= -MinGapSize; plot isGap = if GapUp then 1 else if GapDown then 2 else 0; isgap.AssignValueColor(if isgap ==1 then color.green else if isgap == 2 then color.red else color.white); AssignBACKGROUNDColor(if isgap ==1 then color.green else if isgap == 2 then color.red else color.white);
Shareable Link
https://tos.mx/wMCwUM
Credit:
Did you ever figure this out?Hello. I found Mobius's scan (script below). Can someone help me change it?
I want a gap scanner (yesterday's close to premarket price). I want to find stocks that Gap Up and down. I ran it during regular mkt hours and I get too many results. How can I modify this script?
Changes
#1. compare current close to yesterdays close. Current close should be up until the market opens at 9:30. So, after 9:30 the list becomes static it does not change.
#2. include stocks that are gapping up and down. it would be nice to have the ability to change the gap percentage threshold from 1% to 3% or any % i want to look for.
Thanks for any tips you can offer.
Here's the script.
# Premarket Scan
# Mobius
# Scan looks for premarket price to be above previous day close and premarket volume to be above 1000
def ExtHrs = getTime() >= RegularTradingEnd(getYYYYMMDD());
def c = if ExtHrs and !ExtHrs[1]
then close[1]
else c[1];
def isRollover = GetYYYYMMDD() != GetYYYYMMDD()[1];
def beforeStart = GetTime() < RegularTradingStart(GetYYYYMMDD());
def vol = if isRollover and beforeStart
then volume
else if beforeStart
then vol[1] + volume
else vol[1];
def PreMarketVol = if IsNaN(vol)
then PreMarketVol[1]
else vol;
plot scan = if between(c, 1, 100) and PreMarketVol > 1000 and close > c then 1 else 0;
Not yet. I am still trying to refine a premarket gap scanner that will find stocks gapping up and down.Did you ever figure this out?
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.