NexusFi: Find Your Edge


Home Menu

 





ThinkScript Scans


Discussion in ThinkOrSwim

Updated
    1. trending_up 2,795 views
    2. thumb_up 3 thanks given
    3. group 2 followers
    1. forum 14 posts
    2. attach_file 0 attachments




 
Search this Thread

ThinkScript Scans

  #1 (permalink)
ddtav478
Biloxi Mississippi
 
Posts: 8 since Aug 2022
Thanks Given: 3
Thanks Received: 0

Hello all,

I need quite a bit of help. I posted this question before on usethinkscript and I haven't received a response. I was looking at creating a scan in thinkorswim that scans for stocks that have had a significant drop in price (20% or more) during the day. I wanted to also scan for certain times of the day such as 15 minutes after market open. In short, I'm looking to create a scanner that will scan for a large bearish 15 min candle candle. If you have any suggestions, I'm open to all and I would like to learn a little more on this subject. Also, with this scan, could I potentially use it to look for large 30 min or 1 Hour bearish candles?

I created a scan before by using the default price performance scan that think or swim has, however it scans for 1 bar prior and it doesn't fit the price decrease of 20% or more.

Thank you
V/r

I started playing around with this scan, however I don't think this has what I'm looking for
 
Code
def newday=getday()==GetLastDay() and getday()<>getday()[1];
def cond=if newday[1] and open<close[1] and open[1]>close[1] then 1 else  if newday[1] then 0 else cond[1];
plot signal= cond;

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Cheap historycal L1 data for stocks
Stocks and ETFs
Trade idea based off three indicators.
Traders Hideout
Better Renko Gaps
The Elite Circle
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
 
  #2 (permalink)
RandomDude
Las Vegas, NV
 
Posts: 66 since Aug 2022
Thanks Given: 2
Thanks Received: 18

Only played with scanning a little bit, but I think what you want is something like:

 
Code
def cond= if (open - close)/open > .2 then 1 else 0;
plot signal= cond;

I don't think you need all the other stuff, but try it and let us know.

Think you could also parameterize the percentage for smaller time frames like

 
Code
input Magnitude = .20;
def cond= if (open - close)/open > Magnitude then 1 else 0;
plot signal= cond;
Here is how to do different time frames

https://www.hahn-tech.com/thinkorswim-mtf-macd-scan/


Edit:

Previous will give real-time results, if you want to wait until the first/previous bar is completed, then would be:

 
Code
def cond= if (open[1] - close[1])/open[1] > .2 then 1 else 0;
plot signal= cond;

Reply With Quote
Thanked by:
  #3 (permalink)
ddtav478
Biloxi Mississippi
 
Posts: 8 since Aug 2022
Thanks Given: 3
Thanks Received: 0



RandomDude View Post
Only played with scanning a little bit, but I think what you want is something like:

 
Code
def cond= if (open - close)/open > .2 then 1 else 0;
plot signal= cond;

I don't think you need all the other stuff, but try it and let us know.

Think you could also parameterize the percentage for smaller time frames like

 
Code
input Magnitude = .20;
def cond= if (open - close)/open > Magnitude then 1 else 0;
plot signal= cond;
Here is how to do different time frames



Edit:

Previous will give real-time results, if you want to wait until the first/previous bar is completed, then would be:

 
Code
def cond= if (open[1] - close[1])/open[1] > .2 then 1 else 0;
plot signal= cond;

This code will actually be really great. I had to actually do the code on paper because my poor coding skills. My next question will be the how to scan specific time? So how do I make the code to scan 11:45 to 12:00 (this should cover a specific bar)?

Reply With Quote
  #4 (permalink)
RandomDude
Las Vegas, NV
 
Posts: 66 since Aug 2022
Thanks Given: 2
Thanks Received: 18

Do you want to do this in real-time, or for any time after the fact? For example, are you always running it at 12:01? or could be running it at 1:52 for 11:45 to 12:00?

If always running at 12:01, either 1) put it on a daily chart, and then run the first option, or 2) put it on a 15-minute chart and run the second option.

If want to run at 1:52 for 11:45 to 12:00, then have to do more work on the code.

Reply With Quote
  #5 (permalink)
ddtav478
Biloxi Mississippi
 
Posts: 8 since Aug 2022
Thanks Given: 3
Thanks Received: 0

Precisely, I would like to be able to search for the 11:45 to 12:00 bar at any time of the day. For example, I wanted to find any stock that had a large 20% price decrease during 11:45 to 12:00. In theory, if my time was 3:00pm, I would like to find a large bear candle that occurred at 11:45 to 12:00. That’s my other major problem

Reply With Quote
  #6 (permalink)
ddtav478
Biloxi Mississippi
 
Posts: 8 since Aug 2022
Thanks Given: 3
Thanks Received: 0


RandomDude View Post
Do you want to do this in real-time, or for any time after the fact? For example, are you always running it at 12:01? or could be running it at 1:52 for 11:45 to 12:00?

If always running at 12:01, either 1) put it on a daily chart, and then run the first option, or 2) put it on a 15-minute chart and run the second option.

If want to run at 1:52 for 11:45 to 12:00, then have to do more work on the code.

Ok, So I'm thinking something similar to this example code
 
Code
def Aftr929 = secondsFromTime(1129) > 0; 
def Before931 = secondsTillTime(1146) > 0; 
def TodaysOpen = Aftr929 and Before931; 
plot Test = if TodaysOpen then open else double.nan;
However, I'm not sure how to combine the two codes together to make this work. Or should I write a code that says "get the open price of the bar at 1144 and closing price at 1201 and see if there is a 20% decrease" ? If so, then add to plot scan

Reply With Quote
  #7 (permalink)
RandomDude
Las Vegas, NV
 
Posts: 66 since Aug 2022
Thanks Given: 2
Thanks Received: 18

You have to hold the value to access it later, so for example this is what I use to plot the daily open, which doesn't change during the day.

 
Code
input StartTime = 0630;

#================================================================================================================

rec FirstOpen;

if (FirstOpen[1] == 0) {FirstOpen = first(open());

} else {

if (SecondsTillTime(StartTime+0300)) == 0 {

FirstOpen = open(); 

} else {

FirstOpen = FirstOpen[1];

}

}

#================================================================================================================

plot DailyOpen = FirstOpen;

AddVerticalLine((SecondsTillTime(StartTime + 0300)) == 0 , 5, Color.DARK_GREEN, Curve.FIRM);
Need to tweak it, can take a look later today.

Reply With Quote
  #8 (permalink)
ddtav478
Biloxi Mississippi
 
Posts: 8 since Aug 2022
Thanks Given: 3
Thanks Received: 0


RandomDude View Post
You have to hold the value to access it later, so for example this is what I use to plot the daily open, which doesn't change during the day.

 
Code
input StartTime = 0630;

#================================================================================================================

rec FirstOpen;

if (FirstOpen[1] == 0) {FirstOpen = first(open());

} else {

if (SecondsTillTime(StartTime+0300)) == 0 {

FirstOpen = open(); 

} else {

FirstOpen = FirstOpen[1];

}

}

#================================================================================================================

plot DailyOpen = FirstOpen;

AddVerticalLine((SecondsTillTime(StartTime + 0300)) == 0 , 5, Color.DARK_GREEN, Curve.FIRM);
Need to tweak it, can take a look later today.

Awesome. See I didn’t think about holding a value so this might be something I have to learn. The only coding I know is from general items from arduino.

Reply With Quote
  #9 (permalink)
RandomDude
Las Vegas, NV
 
Posts: 66 since Aug 2022
Thanks Given: 2
Thanks Received: 18

I think I can make it work quickly if you want to specify the time frame in the scan, but if you want to parameterize the time frame, then would need MTF code, which I am not familiar with, so have to figure it out.

I'd like to learn it, so not a big deal, but might take several days or so to get it done.

Unless someone reading this can do it faster.

Reply With Quote
  #10 (permalink)
ddtav478
Biloxi Mississippi
 
Posts: 8 since Aug 2022
Thanks Given: 3
Thanks Received: 0



RandomDude View Post
I think I can make it work quickly if you want to specify the time frame in the scan, but if you want to parameterize the time frame, then would need MTF code, which I am not familiar with, so have to figure it out.

I'd like to learn it, so not a big deal, but might take several days or so to get it done.

Unless someone reading this can do it faster.

I can specify. Probably 15 min @ 11:45 search time

Reply With Quote




Last Updated on August 29, 2022


© 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