Auto Significant Price Levels for ThinkorSwim

@SleepyZ ... much thanks! I took what you did and applied it (separately) to all of the important lines that I track. This is now perfect for me. I'm sharing it back with hopes that it might help you or anyone else.

Note: 1. The chart is fat with indicators now. 5 or 6 as I recall. And can become fatter still if other things (moving averages, vwaps, etc.) are added. 2. Also note that the current day's lines are always thick with a weight of 3 and the extensions are always thin with a weight of 1.

Here is the chart link with all of the indicators inside: https://tos.mx/Nx3MGrR

This provided 5 perfect scalp trades today!! 1.) First touch off of half gap 2.) reversal when price went back up to the RTH open 3.) the next touch and bounce at half gap 4.) after price dropped below half gap and then went back to it and reversed down (VX confirmed that a short could be taken there) 5.) and a sweet bounce off of yesterday's high.



@rlohmeyer
@diazlaz


Does anyone have any thoughts on how we can eliminate all VERTICAL lines?





@SleepyZ , @rlohmeyer , @diazlaz
 
Done. Here's an updated chart link for anyone who is interested: http://tos.mx/XVQQoUk

Note the bounces at 12:40 central time. Perfection with ES off of yesterday's high, SPY off of the premarket low, NQ & QQQ off of their respective half gaps and VX off of the low from 2 days prior. What confluence!


.
@SleepyZ , @rlohmeyer , @diazlaz

Oops... sorry to flood this thread, but the code is not right when it comes to the index (SPY, QQQ, IWM, etc.). At this point it is only correct for the respective futures (ES, NQ, RTY, etc.) . I'll figure it out and correct it and post results back here when I have them.

The issues have to do with when the index opens and closes vs. when the future opens & closes.
 
Last edited:
I am sorry I do not understand your question. The chart you posted as an illustration is a 30 minute chart. The grid has to be setup based on it's usefulness relative to the time frame you are considering. For example, on daily chart for spy I would setup the Increment as 5 and the Major as 10.
On a 5 minute chart I would set it with the Increment at 1 and the Major at 5. The grid is only useful if you consider certain price levels to be INHERENTLY useful.

You can see what I am referring to in post 124 where the chart is setup with the Increment at 1 and the Major at 5 (in magenta). Those levels acted as support and resistance in real time price action.

Regards,
Bob
Can you please share the volume indicator you have? One that shows both the selling and buying pressure?
 
@SleepyZ ... much thanks! I took what you did and applied it (separately) to all of the important lines that I track. This is now perfect for me. I'm sharing it back with hopes that it might help you or anyone else.

Note: 1. The chart is fat with indicators now. 5 or 6 as I recall. And can become fatter still if other things (moving averages, vwaps, etc.) are added. 2. Also note that the current day's lines are always thick with a weight of 3 and the extensions are always thin with a weight of 1.

Here is the chart link with all of the indicators inside: https://tos.mx/Nx3MGrR

This provided 5 perfect scalp trades today!! 1.) First touch off of half gap 2.) reversal when price went back up to the RTH open 3.) the next touch and bounce at half gap 4.) after price dropped below half gap and then went back to it and reversed down (VX confirmed that a short could be taken there) 5.) and a sweet bounce off of yesterday's high.



@rlohmeyer
@diazlaz
Very Nice @RickK
 
@mr_nicegy
Below the image from today showing the indicator on 5 min chart of the spy. The link id below to the code.

Indicator adapted from @horserider indicator and added inputs to allow a begin and end time for showing the volume bars so as to take out the first bar and last bar and give perspective on the meat of one days trading volume.
5riWMNy.jpg


http://tos.mx/fmrd8xT

Regards,
Bob
 
@RickK

Here is simple code to extend any line into the future from a specific starting date. It gives you 2 inputs for the date and the price you want to extend. Duplicate the code and rename each plotted average for the type of line you are extending. Below is an image of yesterdays Open Price on the 5 minute Spy chart extended into today and all future days until you don't need it anymore.

Code:
input BeginDate = 20230328;
input price = 397.05;
plot AVG =  if DaysFromDate(BeginDate) >= 0
   then MovingAverage(averageType.SIMPLE, price, 1)
   else double.nan;

i0ZXxGn.jpg
What are those lines you have can i get the study for it?
 
What are those lines you have can i get the study for it?

Please refer to Post #1 for the most recent chart/grid set-up I use to trade SPY---all the indicators can be used on other index instruments, such as futures, if modified for those instruments. The download link is there also.

Regards,
Bob
 
Latest revision as of 4/26/23.

Here it is on a present grid setup I use for trading Spy on the 5 minute time frame, which is what I use presently. And below the image is the share link. Any questions let me know:
View attachment 8736

http://tos.mx/udTF9eo

Thanks to @BenTen and many other members who helped me with my coding journey to get to a chart setup I can trade with.

Regards,
Bob
Bob, This is a great script. Any chance you have a users guide for it?
 
Can I know what do you mean by half gap?
Did you know that by clicking on a member's name, you can easily check when they were last seen on the uTS forum? It's a great way to keep track of who's been around recently, and who hasn't. Speaking of which, it looks like @RickK has not been seen in a while. :(

A Google search found this definition of 'half-gap'.
https://thepatternsite.com/gapsetups.html#:~:text=A half gap is half,close to today's opening price.
It is not clear if it applies to @RickK post.
 
Oops... sorry to flood this thread, but the code is not right when it comes to the index (SPY, QQQ, IWM, etc.). At this point it is only correct for the respective futures (ES, NQ, RTY, etc.) . I'll figure it out and correct it and post results back here when I have them.

The issues have to do with when the index opens and closes vs. when the future opens & closes.
I combined your indicator, will, I got the AI to combine your indicator. I need to edit it for my purposes. But instead of 6, it is now in 1. http://tos.mx/!Si7XXKKj

5BzS7Oz.png
 
Since I trade 15min bars now, I setup SR lines for after hours and premarket hours. My new code is below the image. I credit a few notable coders for their contributions, especially @Wiinii and @SleepyZ. Code after image:
Rs1FDlL.jpeg


Code:
#-----------SR Lines----------#
def AP = AggregationPeriod.DAY;
def show_GBXH = yes;
def Show_GBXL = yes;
def na = Double.NaN;


#----- Premarket High/Low -----#
# Some code based on code by Mobius
# Created by Wiinii

def bn = BarNumber();
def h  = high;
def l  = low;
def o = open;
def c = close;
def yc = close(period = AP)[1];

def GlobeX = GetTime() < RegularTradingStart(GetYYYYMMDD());
def ONhigh = if GlobeX and !GlobeX[1] then h else if GlobeX and h > ONhigh[1] then h else ONhigh[1];
def ONhighBar = if show_GBXH and GlobeX and h == ONhigh then bn else na;
def ONlow = if GlobeX and !GlobeX[1] then l else if GlobeX and l < ONlow[1] then l else ONlow[1];
def ONlowBar = if Show_GBXL and GlobeX and l == ONlow then bn else na;
def OverNightHigh = if BarNumber() == HighestAll(ONhighBar) then ONhigh else OverNightHigh[1];
def OverNightLow = if BarNumber() == HighestAll(ONlowBar) then ONlow else OverNightLow[1];

plot PM_High;
plot PM_Low;
def  PM_H = if IsNaN(close) then PM_H[1] else if OverNightHigh > 0 then OverNightHigh else na;
def  PM_L = if IsNaN(close) then PM_L[1] else if OverNightLow > 0 then OverNightLow else na;
if !IsNaN(close(period = AP)[-1]) {
    PM_High = na;
    PM_Low = na;
} else {
    PM_High = PM_H;
    PM_Low  = PM_L;
}

PM_High.SetLineWeight(2);
PM_High.SetDefaultColor(Color.GREEN);
PM_High.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
PM_High.HideBubble();
PM_High.HideTitle();

PM_Low.SetLineWeight(2);
PM_Low.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
PM_Low.SetDefaultColor(Color.RED);
PM_Low.HideBubble();
PM_Low.HideTitle();

#------After_Market_HL_TimeRange_using_ProfileHL----#
#Complements @Sleepyz
def showtodayonly = no;
def afterbegin = 1600;
def afterend   = 2359;

input pricePerRowHeightMode = {AUTOMATIC, default TICKSIZE};
def height;
switch (pricePerRowHeightMode) {
case AUTOMATIC:
    height = PricePerRow.AUTOMATIC;
case TICKSIZE:
    height = PricePerRow.TICKSIZE;
}

def afterrth  = if IsNaN(close) then afterrth[1] else SecondsFromTime(afterbegin) >= 0 and SecondsTillTime(afterend) > 0;
def aftercond = afterrth != afterrth[1];

profile aftervol = VolumeProfile("startNewProfile" = aftercond and SecondsTillTime(afterend) >= 0, "onExpansion" = no, "numberOfProfiles" = 1000, pricePerRow = height);


profile aftervol1 = VolumeProfile("startNewProfile" = aftercond, "onExpansion" = no, "numberOfProfiles" = 1000, pricePerRow = height);


def afterhProfile = if IsNaN(aftervol.GetHighest()) then afterhProfile[1] else aftervol1.GetHighest();
def afterlProfile = if IsNaN(aftervol.GetLowest())  then afterlProfile[1] else aftervol1.GetLowest();
def afteruprof    = if !afterrth or IsNaN(close) then afteruprof[1] else afterhProfile;
def afterlprof    = if !afterrth or IsNaN(close) then afterlprof[1] else afterlProfile;

plot AM_High =  if showtodayonly and GetDay() != GetLastDay() then Double.NaN else afteruprof;
plot AM_Low  =  if showtodayonly and GetDay() != GetLastDay() then Double.NaN else afterlprof;

AM_High.SetDefaultColor(Color.LIGHT_GREEN);
AM_High.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
AM_High.SetlineWeight(2);

AM_Low.SetDefaultColor(Color.LIGHT_RED);
AM_Low.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
AM_Low.SetlineWeight(2);

#--------------First Half Hour Bar-----------------#
def OBH_ =  if SecondsFromTime(930) == 0 and SecondsTillTime(930) == 0 then h else OBH_ [1];
plot OBH = if OBH_ > 0 then OBH_ else Double.NaN;
OBH.SetPaintingStrategy(PaintingStrategy.DASHES);
OBH.SetDefaultColor(Color.GREEN);
OBH.SetLineWeight(2);

def OBL_ =  if SecondsFromTime(930) == 0 and SecondsTillTime(930) == 0 then l else OBL_ [1];
plot OBL = if OBL_ > 0 then OBL_ else Double.NaN;
OBL.SetPaintingStrategy(PaintingStrategy.DASHES);
OBL.SetDefaultColor(Color.RED);
OBL.SetLineWeight(2);

#------------Day Lines--------------#
def after_open = if SecondsFromTime(935) >= 0 then 1 else 0;
plot D_Open = if after_open then open(period = AP) else na;
D_Open.SetDefaultColor(Color.YELLOW);
D_Open.SetPaintingStrategy(PaintingStrategy.POINTS);
D_Open.SetLineWeight(1);
D_Open.HideTitle();
D_Open.HideBubble();

def DOX_ = if !IsNaN(D_Open) and IsNaN(D_Open[-1]) then D_Open else DOX_[1];
plot DOX = if IsNaN(D_Open[-1]) then DOX_[-1] else Double.NaN;
DOX.SetDefaultColor(Color.YELLOW);
DOX.SetPaintingStrategy(PaintingStrategy.POINTS);
DOX.SetLineWeight(1);


plot D_High = if after_open then high(period = AP) else na;
D_High.SetDefaultColor(Color.GREEN);
D_High.SetPaintingStrategy(PaintingStrategy.POINTS);
D_High.SetLineWeight(1);
D_High.HideTitle();
D_High.HideBubble();

def DHX_ = if !IsNaN(D_High) and IsNaN(D_High[-1]) then D_High else DHX_[1];
plot DHX = if IsNaN(D_High[-1]) then DHX_[-1] else Double.NaN;
DHX.SetDefaultColor(Color.GREEN);
DHX.SetPaintingStrategy(PaintingStrategy.POINTS);
DHX.SetLineWeight(1);

plot D_Low = if after_open then low(period = AP) else na;
D_Low.SetDefaultColor(Color.RED);
D_Low.SetPaintingStrategy(PaintingStrategy.POINTS);
D_Low.SetLineWeight(1);
D_Low.HideTitle();
D_Low.HideBubble();

def DLX_ = if !IsNaN(D_Low) and IsNaN(D_Low[-1]) then D_Low else DLX_[1];
plot DLX = if IsNaN(D_Low[-1]) then DLX_[-1] else Double.NaN;
DLX.SetDefaultColor(Color.RED);
DLX.SetPaintingStrategy(PaintingStrategy.POINTS);
DLX.SetLineWeight(1);

plot Y_Close = if after_open then close(period = AP)[1] else na;
Y_Close.SetPaintingStrategy(PaintingStrategy.SQUARES);
Y_Close.SetDefaultColor(Color.DARK_ORANGE);
Y_Close.SetLineWeight(1);
Y_Close.HideTitle();
Y_Close.HideBubble();

def YCX_ = if !IsNaN(Y_Close) and IsNaN(Y_Close[-1]) then Y_Close else YCX_[1];
plot YCX = if IsNaN(Y_Close[-1]) then YCX_[-1] else Double.NaN;
YCX.SetDefaultColor(Color.DARK_ORANGE);
YCX.SetPaintingStrategy(PaintingStrategy.SQUARES);
YCX.SetLineWeight(1);

plot Y_High = if after_open then high(period = AP)[1] else na;
Y_High.SetDefaultColor(Color.GREEN);
Y_High.SetPaintingStrategy(PaintingStrategy.SQUARES);
Y_High.SetLineWeight(1);
Y_High.HideTitle();
Y_High.HideBubble();

def YHX_ = if !IsNaN(Y_High) and IsNaN(Y_High[-1]) then Y_High else YHX_[1];
plot YHX = if IsNaN(Y_High[-1]) then YHX_[-1] else Double.NaN;
YHX.SetDefaultColor(Color.GREEN);
YHX.SetPaintingStrategy(PaintingStrategy.SQUARES);
YHX.SetLineWeight(1);

plot Y_Low = if after_open then low(period = AP)[1] else na;
Y_Low.SetDefaultColor(Color.RED);
Y_Low.SetPaintingStrategy(PaintingStrategy.SQUARES);
Y_Low.SetLineWeight(1);
Y_Low.HideTitle();
Y_Low.HideBubble();

def YLX_ = if !IsNaN(Y_Low) and IsNaN(Y_Low[-1]) then Y_Low else YLX_[1];
plot YLX = if IsNaN(Y_Low[-1]) then YLX_[-1] else Double.NaN;
YLX.SetDefaultColor(Color.RED);
YLX.SetPaintingStrategy(PaintingStrategy.SQUARES);
YLX.SetLineWeight(1);


#Vol Sig
def v = volume;
input volx = 1.03;
def VC = v > v[1] * volx;
plot VoLSig = if VC then close else Double.NaN;
VoLSig.SetPaintingStrategy(PaintingStrategy.SQUARES);
VoLSig.SetDefaultColor(Color.WHITE);
VoLSig.SetLineWeight(3);

#ADR Label#################################
input AdrAvgLength = 21;
def dr = high(period = AP)[1] - low(period = AP)[1];
def tdr = high(period = AP) - low(period = AP);
def ADR = Round(ExpAverage( dr, AdrAvgLength), 2);
input Addlabel = yes;
def drp = Round((tdr / ADR) * 100, 0);
AddLabel(yes, "ADR" + AdrAvgLength + "|$" + ADR  + "  DR|$" + Round(tdr, 2) + "/" + drp + "%", Color.YELLOW);
 
Since I trade 15min bars now, I setup SR lines for after hours and premarket hours. My new code is below the image. I credit a few notable coders for their contributions, especially @Wiinii and @SleepyZ. Code after image:


I added the premarket to my personal version of that indicator. Since those levels tend to be respected. I am also adding gap clouds. I can't say the half gap does much from what I saw on the indicator though. Can you explain the logic?
 

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
371 Online
Create Post

Similar threads

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

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.

How do I get started?

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.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top