/ES Futures Quasi-Algo 1 Hour Out Prediction for ThinkorSwim

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

/ES

Code:
#########################################################
#
#   Next Hour ES Trading Range
#     Algorithmic Prediction
#
#   Values Derived on Data from
#          2022-04-08 to
#          2022-06-17
#
#   @mashume at usethinkscript.com
#
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
#
#  This Version /ES only
#  Functional on 1, 2, 3, 5, 10, 15, 20, 30, 60 minute charts
#
#########################################################

declare upper;

def Y = 31556926;
def M = 2629743;
def D = 86400;
def H = 3600;
def HalfHour = 1800;
def epoch = (getTime() / 1000);
def YMD = (epoch % Y) - (epoch / Y);
def month = (Floor(YMD / M) + 1);
def GMT = Floor((epoch % D) / H);
def HOUR = if GMT > 4 then GMT - 4 else if GMT < 4 then (GMT + 24) - 4 else 0;

def tf = getAggregationPeriod();

def barsPerHour = if tf == AggregationPeriod.HOUR then 1
    else if tf == AggregationPeriod.THIRTY_MIN then 2
    else if tf == AggregationPeriod.TWENTY_MIN then 3
    else if tf == AggregationPeriod.FIFTEEN_MIN then 4
    else if tf == AggregationPeriod.TEN_MIN then 6
    else if tf == AggregationPeriod.FIVE_MIN then 12
    else if tf == AggregationPeriod.THREE_MIN then 20
    else if tf == AggregationPeriod.TWO_MIN then 30
    else if tf == AggregationPeriod.MIN then 60
    else double.nan;
    

def q1 =
    if HOUR == 0 then -3.500000
    else if HOUR == 1 then -6.250000
    else if HOUR == 2 then -9.562000
    else if HOUR == 3 then -5.500000
    else if HOUR == 4 then -7.250000
    else if HOUR == 5 then -5.250000
    else if HOUR == 6 then -6.250000
    else if HOUR == 7 then -7.500000
    else if HOUR == 8 then -13.375000
    else if HOUR == 9 then -22.812000
    else if HOUR == 10 then -16.875000
    else if HOUR == 11 then -12.250000
    else if HOUR == 12 then -11.000000
    else if HOUR == 13 then -13.812000
    else if HOUR == 14 then -14.312000
    else if HOUR == 15 then -12.250000
    else if HOUR == 16 then -2.500000
    else if HOUR == 17 then -20.875000
    else if HOUR == 18 then -2.750000
    else if HOUR == 19 then -5.500000
    else if HOUR == 20 then -5.062000
    else if HOUR == 21 then -3.000000
    else if HOUR == 22 then -2.500000
    else -2.250000;
def q3 =
    if HOUR == 0 then 3.500000
    else if HOUR == 1 then 5.250000
    else if HOUR == 2 then 6.000000
    else if HOUR == 3 then 9.500000
    else if HOUR == 4 then 4.000000
    else if HOUR == 5 then 5.000000
    else if HOUR == 6 then 6.000000
    else if HOUR == 7 then 6.250000
    else if HOUR == 8 then 5.875000
    else if HOUR == 9 then 12.000000
    else if HOUR == 10 then 10.250000
    else if HOUR == 11 then 10.000000
    else if HOUR == 12 then 9.500000
    else if HOUR == 13 then 9.500000
    else if HOUR == 14 then 13.250000
    else if HOUR == 15 then 10.000000
    else if HOUR == 16 then 6.500000
    else if HOUR == 17 then 5.125000
    else if HOUR == 18 then 3.500000
    else if HOUR == 19 then 5.500000
    else if HOUR == 20 then 4.812500
    else if HOUR == 21 then 5.000000
    else if HOUR == 22 then 5.250000
    else 3.312000;
def m2 =
    if HOUR == 0 then 0.000000
    else if HOUR == 1 then 0.500000
    else if HOUR == 2 then -1.750000
    else if HOUR == 3 then 3.000000
    else if HOUR == 4 then -1.750000
    else if HOUR == 5 then 0.250000
    else if HOUR == 6 then 0.250000
    else if HOUR == 7 then -1.000000
    else if HOUR == 8 then -3.750000
    else if HOUR == 9 then -7.000000
    else if HOUR == 10 then -2.250000
    else if HOUR == 11 then 0.500000
    else if HOUR == 12 then 0.000000
    else if HOUR == 13 then -2.125000
    else if HOUR == 14 then -1.500000
    else if HOUR == 15 then -2.000000
    else if HOUR == 16 then 2.250000
    else if HOUR == 17 then -0.250000
    else if HOUR == 18 then 0.500000
    else if HOUR == 19 then -0.250000
    else if HOUR == 20 then 0.750000
    else if HOUR == 21 then 1.000000
    else if HOUR == 22 then 1.500000
    else 0.750000;

def midline = hl2(period = AggregationPeriod.HOUR)[1];
def median = hl2(period = AggregationPeriod.HOUR)[1] + m2;
def upper = median + (q3);
def lower = median + (q1);

plot c = midline;
c.setStyle(CURve.SHORT_DASH);
c.setDefaultColor(getColor(7));

plot median_line = median[barsPerHour];
median_line.SetPaintingStrategy(PaintingStrategy.DASHES);
median_line.SetDefaultColor(getColor(3));
plot expected_upper = upper[barsPerHour];
expected_upper.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
expected_upper.SetDefaultColor(getColor(1));
plot expected_lower = lower[barsPerHour];
expected_lower.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
expected_lower.SetDefaultColor(getColor(5));

addcloud(expected_upper, expected_lower, color.white, color.white);
def upside = (expected_upper[(-1 * barsPerHour)] - close);
def downside = (close - expected_lower[(-1 * barsPerHour)]);
addLabel(yes, "current upside: " + upside + "  current downside: " + downside, if upside > downside then color.dark_green else if downside > upside then color.dark_red else color.dark_gray);

def dist_to_median = (median_line[(-1 * barsPerHour)] - close);
addLabel(yes, "Distance to Median: " + dist_to_median, 
if dist_to_median > 5 then color.green 
else if dist_to_median > 1 then color.dark_green 
else if dist_to_median < -5 then color.red
else if dist_to_median < -1 then color.dark_red 
else color.gray);

\NQ

Code:
#########################################################
#
#   Next Hour NQ Trading Range
#     Algorithmic Prediction
#
#   Values Derived on Data from
#          2022-04-08 to
#          2022-06-17
#
#   @mashume at usethinkscript.com
#
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
#
#  This Version /NQ only
#  Functional on 1, 2, 3, 5, 10, 15, 20, 30, 60 minute charts
#
#########################################################

declare upper;

def Y = 31556926;
def M = 2629743;
def D = 86400;
def H = 3600;
def HalfHour = 1800;
def epoch = (getTime() / 1000);
def YMD = (epoch % Y) - (epoch / Y);
def month = (Floor(YMD / M) + 1);
def GMT = Floor((epoch % D) / H);
def HOUR = if GMT > 4 then GMT - 4 else if GMT < 4 then (GMT + 24) - 4 else 0;

def tf = getAggregationPeriod();

def barsPerHour = if tf == AggregationPeriod.HOUR then 1
    else if tf == AggregationPeriod.THIRTY_MIN then 2
    else if tf == AggregationPeriod.TWENTY_MIN then 3
    else if tf == AggregationPeriod.FIFTEEN_MIN then 4
    else if tf == AggregationPeriod.TEN_MIN then 6
    else if tf == AggregationPeriod.FIVE_MIN then 12
    else if tf == AggregationPeriod.THREE_MIN then 20
    else if tf == AggregationPeriod.TWO_MIN then 30
    else if tf == AggregationPeriod.MIN then 60
    else double.nan;
    

def q1 =
    if HOUR == 0 then -14.562000
    else if HOUR == 1 then -21.000000
    else if HOUR == 2 then -37.750000
    else if HOUR == 3 then -21.812000
    else if HOUR == 4 then -28.312000
    else if HOUR == 5 then -20.000000
    else if HOUR == 6 then -24.812000
    else if HOUR == 7 then -31.000000
    else if HOUR == 8 then -57.000000
    else if HOUR == 9 then -102.188000
    else if HOUR == 10 then -68.938000
    else if HOUR == 11 then -50.562000
    else if HOUR == 12 then -45.562000
    else if HOUR == 13 then -54.375000
    else if HOUR == 14 then -55.375000
    else if HOUR == 15 then -45.250000
    else if HOUR == 16 then -9.250000
    else if HOUR == 17 then 9.125000
    else if HOUR == 18 then -12.750000
    else if HOUR == 19 then -20.562000
    else if HOUR == 20 then -20.812000
    else if HOUR == 21 then -12.750000
    else if HOUR == 22 then -8.750000
    else -9.750000;
def q3 =
    if HOUR == 0 then 13.625000
    else if HOUR == 1 then 20.750000
    else if HOUR == 2 then 21.250000
    else if HOUR == 3 then 38.500000
    else if HOUR == 4 then 14.000000
    else if HOUR == 5 then 18.937500
    else if HOUR == 6 then 24.750000
    else if HOUR == 7 then 27.312500
    else if HOUR == 8 then 29.250000
    else if HOUR == 9 then 70.062500
    else if HOUR == 10 then 41.500000
    else if HOUR == 11 then 45.812500
    else if HOUR == 12 then 37.562500
    else if HOUR == 13 then 37.750000
    else if HOUR == 14 then 42.562500
    else if HOUR == 15 then 40.562500
    else if HOUR == 16 then 27.250000
    else if HOUR == 17 then 50.375000
    else if HOUR == 18 then 16.062500
    else if HOUR == 19 then 20.500000
    else if HOUR == 20 then 19.562500
    else if HOUR == 21 then 21.062500
    else if HOUR == 22 then 21.312500
    else 14.312000;
def m2 =
    if HOUR == 0 then -1.625000
    else if HOUR == 1 then 1.750000
    else if HOUR == 2 then -9.500000
    else if HOUR == 3 then 10.125000
    else if HOUR == 4 then -5.875000
    else if HOUR == 5 then -0.250000
    else if HOUR == 6 then 0.250000
    else if HOUR == 7 then -4.500000
    else if HOUR == 8 then -16.750000
    else if HOUR == 9 then -23.250000
    else if HOUR == 10 then -8.125000
    else if HOUR == 11 then 2.750000
    else if HOUR == 12 then -2.625000
    else if HOUR == 13 then -9.125000
    else if HOUR == 14 then -10.000000
    else if HOUR == 15 then -3.375000
    else if HOUR == 16 then 10.000000
    else if HOUR == 17 then 9.500000
    else if HOUR == 18 then 3.000000
    else if HOUR == 19 then 1.000000
    else if HOUR == 20 then 3.250000
    else if HOUR == 21 then 2.875000
    else if HOUR == 22 then 6.000000
    else 3.750000;

def midline = hl2(period = AggregationPeriod.HOUR)[1];
def median = hl2(period = AggregationPeriod.HOUR)[1] + m2;
def upper = median + (q3);
def lower = median + (q1);

plot c = midline;
c.setStyle(CURve.SHORT_DASH);
c.setDefaultColor(getColor(7));

plot median_line = median[barsPerHour];
median_line.SetPaintingStrategy(PaintingStrategy.DASHES);
median_line.SetDefaultColor(getColor(3));
plot expected_upper = upper[barsPerHour];
expected_upper.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
expected_upper.SetDefaultColor(getColor(1));
plot expected_lower = lower[barsPerHour];
expected_lower.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
expected_lower.SetDefaultColor(getColor(5));

addcloud(expected_upper, expected_lower, color.white, color.white);
def upside = (expected_upper[(-1 * barsPerHour)] - close);
def downside = (close - expected_lower[(-1 * barsPerHour)]);
addLabel(yes, "current upside: " + upside + "  current downside: " + downside, if upside > downside then color.dark_green else if downside > upside then color.dark_red else color.dark_gray);

def dist_to_median = (median_line[(-1 * barsPerHour)] - close);
addLabel(yes, "Distance to Median: " + dist_to_median, 
if dist_to_median > 5 then color.green 
else if dist_to_median > 1 then color.dark_green 
else if dist_to_median < -5 then color.red
else if dist_to_median < -1 then color.dark_red 
else color.gray);
 

TSLA

Code:
#########################################################
#
#   Next Hour TSLA Trading Range
#     Algorithmic Prediction
#
#   Values Derived on Data from
#          2022-03-24 to
#          2022-06-17
#
#   @mashume at usethinkscript.com
#
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
#
#  This Version /TSLA only
#  Functional on 1, 2, 3, 5, 10, 15, 20, 30, 60 minute charts
#
#########################################################

declare upper;

def Y = 31556926;
def M = 2629743;
def D = 86400;
def H = 3600;
def HalfHour = 1800;
def epoch = (getTime() / 1000);
def YMD = (epoch % Y) - (epoch / Y);
def month = (Floor(YMD / M) + 1);
def GMT = Floor((epoch % D) / H);
def HOUR = if GMT > 4 then GMT - 4 else if GMT < 4 then (GMT + 24) - 4 else 0;

def tf = getAggregationPeriod();

def barsPerHour = if tf == AggregationPeriod.HOUR then 1
    else if tf == AggregationPeriod.THIRTY_MIN then 2
    else if tf == AggregationPeriod.TWENTY_MIN then 3
    else if tf == AggregationPeriod.FIFTEEN_MIN then 4
    else if tf == AggregationPeriod.TEN_MIN then 6
    else if tf == AggregationPeriod.FIVE_MIN then 12
    else if tf == AggregationPeriod.THREE_MIN then 20
    else if tf == AggregationPeriod.TWO_MIN then 30
    else if tf == AggregationPeriod.MIN then 60
    else double.nan;
    

def q1 =
    if HOUR == 0 then 0.000000
    else if HOUR == 1 then 0.000000
    else if HOUR == 2 then 0.000000
    else if HOUR == 3 then 0.000000
    else if HOUR == 4 then -3.285000
    else if HOUR == 5 then -2.593000
    else if HOUR == 6 then -4.777000
    else if HOUR == 7 then -3.765000
    else if HOUR == 8 then -8.792000
    else if HOUR == 9 then -13.224000
    else if HOUR == 10 then -8.848000
    else if HOUR == 11 then -6.939000
    else if HOUR == 12 then -5.660000
    else if HOUR == 13 then -5.239000
    else if HOUR == 14 then -6.410000
    else if HOUR == 15 then -3.349000
    else if HOUR == 16 then -1.300000
    else if HOUR == 17 then -0.756000
    else if HOUR == 18 then -1.420000
    else if HOUR == 19 then -6.267000
    else if HOUR == 20 then 0.000000
    else if HOUR == 21 then 0.000000
    else if HOUR == 22 then 0.000000
    else 0.000000;
def q3 =
    if HOUR == 0 then 0.000000
    else if HOUR == 1 then 0.000000
    else if HOUR == 2 then 0.000000
    else if HOUR == 3 then 0.000000
    else if HOUR == 4 then 1.860000
    else if HOUR == 5 then 2.132500
    else if HOUR == 6 then 2.672500
    else if HOUR == 7 then 2.992500
    else if HOUR == 8 then 6.406247
    else if HOUR == 9 then 12.220125
    else if HOUR == 10 then 8.290009
    else if HOUR == 11 then 3.532196
    else if HOUR == 12 then 3.799881
    else if HOUR == 13 then 3.787537
    else if HOUR == 14 then 3.503479
    else if HOUR == 15 then 4.752119
    else if HOUR == 16 then 1.500000
    else if HOUR == 17 then 1.905000
    else if HOUR == 18 then 1.340000
    else if HOUR == 19 then 11.182500
    else if HOUR == 20 then 0.000000
    else if HOUR == 21 then 0.000000
    else if HOUR == 22 then 0.000000
    else 0.000000;
def m2 =
    if HOUR == 0 then 0.000000
    else if HOUR == 1 then 0.000000
    else if HOUR == 2 then 0.000000
    else if HOUR == 3 then 0.000000
    else if HOUR == 4 then -0.455000
    else if HOUR == 5 then -0.115000
    else if HOUR == 6 then -1.010000
    else if HOUR == 7 then -0.795000
    else if HOUR == 8 then -1.720000
    else if HOUR == 9 then -0.535000
    else if HOUR == 10 then -0.276000
    else if HOUR == 11 then -1.619000
    else if HOUR == 12 then -0.295000
    else if HOUR == 13 then -0.287000
    else if HOUR == 14 then -1.628000
    else if HOUR == 15 then 0.367000
    else if HOUR == 16 then 0.035000
    else if HOUR == 17 then 0.440000
    else if HOUR == 18 then -0.065000
    else if HOUR == 19 then 1.640000
    else if HOUR == 20 then 0.000000
    else if HOUR == 21 then 0.000000
    else if HOUR == 22 then 0.000000
    else 0.000000;

def midline = hl2(period = AggregationPeriod.HOUR)[1];
def median = hl2(period = AggregationPeriod.HOUR)[1] + m2;
def upper = median + (q3);
def lower = median + (q1);

plot c = midline;
c.setStyle(CURve.SHORT_DASH);
c.setDefaultColor(getColor(7));

plot median_line = median[barsPerHour];
median_line.SetPaintingStrategy(PaintingStrategy.DASHES);
median_line.SetDefaultColor(getColor(3));
plot expected_upper = upper[barsPerHour];
expected_upper.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
expected_upper.SetDefaultColor(getColor(1));
plot expected_lower = lower[barsPerHour];
expected_lower.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
expected_lower.SetDefaultColor(getColor(5));

addcloud(expected_upper, expected_lower, color.white, color.white);
def upside = (expected_upper[(-1 * barsPerHour)] - close);
def downside = (close - expected_lower[(-1 * barsPerHour)]);
addLabel(yes, "current upside: " + upside + "  current downside: " + downside, if upside > downside then color.dark_green else if downside > upside then color.dark_red else color.dark_gray);

def dist_to_median = (median_line[(-1 * barsPerHour)] - close);
addLabel(yes, "Distance to Median: " + dist_to_median, 
if dist_to_median > 5 then color.green 
else if dist_to_median > 1 then color.dark_green 
else if dist_to_median < -5 then color.red
else if dist_to_median < -1 then color.dark_red 
else color.gray);
 
Has anyone done a study on validating the time prediction? This is really interesting
There is no real validation... the values are based on hourly data over the proceeding 60 days at 5m. The values for each hour are aggregated, and basic statistics (q1, q3, and median) are calculated. Those are then adjusted as movement vs the previous hour's HL2 candle and plotted for the hour. I think there is more on it here somewhere. The only validation you could really run is against the computed values, and you're welcome to look through here for the source code. I think I published it -- perhaps as a google collab notebook.

EDIT[/b/]
Here's the link from previously in this thread:
https://usethinkscript.com/threads/...ut-prediction-for-thinkorswim.6282/post-61282

-mashume
 
Last edited:
Hi there, I was looking for something similar to this. The idea was to have data from the last X amount of days (the bigger the sample the better), and then fetch the Hi and Low for each hour in regards to the open of each day. And this data will be used to predict the movement of the next two hours. BUT..
..BUT the prediction, to be more accurate, should compare the same hours from the days before and they should have a similar pattern in order to throw a prediction..

For example we are at 11:00 am
From 9:00 to 10:00am the price Hi reached 2% above the open and the Low reached -1% below the open. (we will call this (A)
From 10:00 to 11:00am the hi reached 3% above the open and the low 1% above the open. (we will call this (B)
(And we'll call them both together AB).

The prediction would grab AB, and it will show the different possible outcomes for the 11:00 to 12:00 and the 12:00 to 13:00 periods.
Ideally there would be more than 1 outcome so it would rank them according to the amount of times that that outcome has appeared in the past. There might be old patterns similar to A and others similar to B but for the indicator to show a prediction, there must be patterns similar to AB, if there are non, then the indicator will show no prediction, if the indicator shows too many predictions then we should consider adding one more hour: C, so it would have to fetch the ones that coincide with ABC, reducing the possible outcomes.


Some notes:
The range from the open could be separated in areas ex: from 0 to 2% from 2% to 4% and so on in order to give a little bit more of freedom to the indicator. (I know that those percentages are exaggerated but you get my point..)
Ideally the amount of days and hours to look back could be modified.
Ideally the different outcomes can be displayed with a number that indicates how many times it happened.
I trade the ES so I thought this for futures, though I usually use the 9:30 open as a guide.
I'm open for different ideas and If someone is willing to give it a try and code this, that would be great, because my programing skills are similar to the ones an intelligent horse could have, and I don't see this indicator as something easy to achieve.
 
@mashume would it be possible to get it to work on a 1000 tick chart?
No, this one does not work on tick charts due to the use of offset bars. Tick charts do not have a predictable number of bars for a given timeframe, and so there is no way to get the predicted values to show up in the right place.

-mashume
 
Hi there, I was looking for something similar to this. The idea was to have data from the last X amount of days (the bigger the sample the better), and then fetch the Hi and Low for each hour in regards to the open of each day. And this data will be used to predict the movement of the next two hours. BUT..
..BUT the prediction, to be more accurate, should compare the same hours from the days before and they should have a similar pattern in order to throw a prediction..

For example we are at 11:00 am
From 9:00 to 10:00am the price Hi reached 2% above the open and the Low reached -1% below the open. (we will call this (A)
From 10:00 to 11:00am the hi reached 3% above the open and the low 1% above the open. (we will call this (B)
(And we'll call them both together AB).

The prediction would grab AB, and it will show the different possible outcomes for the 11:00 to 12:00 and the 12:00 to 13:00 periods.
Ideally there would be more than 1 outcome so it would rank them according to the amount of times that that outcome has appeared in the past. There might be old patterns similar to A and others similar to B but for the indicator to show a prediction, there must be patterns similar to AB, if there are non, then the indicator will show no prediction, if the indicator shows too many predictions then we should consider adding one more hour: C, so it would have to fetch the ones that coincide with ABC, reducing the possible outcomes.


Some notes:
The range from the open could be separated in areas ex: from 0 to 2% from 2% to 4% and so on in order to give a little bit more of freedom to the indicator. (I know that those percentages are exaggerated but you get my point..)
Ideally the amount of days and hours to look back could be modified.
Ideally the different outcomes can be displayed with a number that indicates how many times it happened.
I trade the ES so I thought this for futures, though I usually use the 9:30 open as a guide.
I'm open for different ideas and If someone is willing to give it a try and code this, that would be great, because my programing skills are similar to the ones an intelligent horse could have, and I don't see this indicator as something easy to achieve.
I have experimented with various versions of this script myself:
1. the original, which uses all available data and calculates Q1, Q2, and Q3 for each hour of the day based on the historical movements for that time of day from the close of the last hour.
2. A version which looks at the previous 2 hours to attempt to determine whether the prediction should be based on UU, UD, DU, or DD hour pairs
3. A version which looked at the hour proceeding the projection and tried to determine if the movement was 'large', or 'small' based on being within or in excess of one standard deviation of the normal statistical movement.

Of all the versions, I find that this original is the one I use most often. I don't use distance from the day's open since futures (especially currencies) move to their own global schedules and seldom reference only their US open (which would be 6pm ET? or would it be market open i.e. 9:30 ET???) So I don't use daily open and movement from that for much of anything.

I have not released the code for all of these versions, but there is a link to a python notebook somewhere in this thread if you want to see all the statistics that go into processing the data into the indicator.

Remember that ToS is not a full blown AI capable environment. What you propose is borderline machine learning (ML) and would be good on a desktop, but not necessarily in ToS. In fact, I don't do any of the statistical processing in ToS... that's all python which prints out (to screen) the code for the indicator, ready to paste into ToS.

I like the sharing of ideas, thank you for posting your thoughts here. I don't want to be negative, and perhaps someone will take up the challenge of your idea and program it. I hope so. It would be interesting to see the differences. But it won't be me at the moment.

Thanks again for contributing to this thread, and happy trading,
mashume
 
@mashume hi Sir. I am interested in learning to update by myself the data for this indicator.
Is there any tutorial or indications about how to do it??
Thanks.
 
@mashume hi Sir. I am interested in learning to update by myself the data for this indicator.
Is there any tutorial or indications about how to do it??
Thanks.
Take a look at post #27 in this thread:
https://usethinkscript.com/threads/...ut-prediction-for-thinkorswim.6282/post-61282
it has a link to a Google Collab Notebook with a [slightly early] version of the python code that generates this indicator. If you go through that, it should be somewhat clearer how this works, and I'll be happy to answer questions about the code here any time.

There isn't really a tutorial, but the notebook should run and generate an updated script. If it doesn't, please write back here and we'll try to sort out your problems with it.

Good luck,
mashume
 
Take a look at post #27 in this thread:
https://usethinkscript.com/threads/...ut-prediction-for-thinkorswim.6282/post-61282
it has a link to a Google Collab Notebook with a [slightly early] version of the python code that generates this indicator. If you go through that, it should be somewhat clearer how this works, and I'll be happy to answer questions about the code here any time.

There isn't really a tutorial, but the notebook should run and generate an updated script. If it doesn't, please write back here and we'll try to sort out your problems with it.

Good luck,
mashume
many thanks. I will have a look.
have a great day!
 
Amazing script! Thank you for this... btw can it work for Crude Oil (CL) futures? I'm still trying to figure it out how to edit the script and run it...

tickers = ['ES=F', 'CL=F', '^VIX', 'GC=F', 'ZN=F']
es_data = yf.Ticker('ES=F')

Like here why does F equals different symbols?? Can you help me with the CL script? while I try to understand this... 😅
 
Amazing script! Thank you for this... btw can it work for Crude Oil (CL) futures? I'm still trying to figure it out how to edit the script and run it...

tickers = ['ES=F', 'CL=F', '^VIX', 'GC=F', 'ZN=F']
es_data = yf.Ticker('ES=F')

Like here why does F equals different symbols?? Can you help me with the CL script? while I try to understand this... 😅
These are the way that the YFinance API handles futures. ToS says "/ES", YFin says "ES=F". Potato, potato; tomato, tomato.
 
The script fetches data for the last 60 days, since that's all the YFinance API will serve up at 5m resolution.

-mashume
Few questions.
Does the code have to updated to get /es levels? How often does the code have to be updated? 60 days?
Can the code used on lower time frame? 2 min chart?
 

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
448 Online
Create Post

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