I am trying to plot a price target based on the slope of the 50EMA from 11:30 CST until 15:30 CST.

I have the formula for the slope but I can’t figure out for the life of me how to get the average price of the 10 minute bar at 11:30 CST so I can multiply it by (slope/360).

I have tried:

if barnumber(18) then (open+close)/2

if secondsfromtime(930) between 10200 and 10800 then (open+close)/2

I already have a properly configured label for slope

I have created a label and know I can calculate the current bar ((open+close)/2) * (slope/360)

I just can’t figure out how to define that specific bars average price and plot the price target from 11:30 CST until 15:30 CST.

Obviously if I can get the avg price * (slope/360) I would need to multiply that by the remaining number of bars left in the day and then add that to my avg price to get my target price.

My current attempts have resulted in no plot and N/A on my label if I use double.nan in my definitions or a plot at 0 and 0 on my label if I use 0 in my definitions.

Hope this is clear enough.

sorry, no , it is not clear.

i think this might be similar to what you want. guessing you want a line only on the current day.

https://usethinkscript.com/threads/draw-a-trendline-based-on-time.9260/
-------

I'm going to type a lot of words here. some of them are just meant to help people to think about what they are trying to explain. my only goal is to help people communicate effectively.

Sometimes when you have an idea in your head, the words don't come out right. some things that can help to communicate an idea, reread it, look it over, sketch something out, have someone else read it.

--------

you say you have several pieces of data, but you don't list them, so we are left wondering.

-------

1.

trying to plot a price target based on the slope of the 50EMA from 11:30 CST until 15:30 CST.

do you mean ,

find 2 price values from an ema,

then draw a straight line through them,

and extend it to the last candle of the day?

-------------

2.

I have the formula for the slope but I can’t figure out for the life of me how to get the average price of the 10 minute bar at 11:30 CST so I can multiply it by (slope/360).

if you have the slope formula, then post it. then we will know if you are right.

why would you multiply it by (slope/360).? why /360?

why tell us what you're going to do, without telling us why.

i'm guessing you are trying to convert to angles. but why?

Tos can't draw vectors, a point and an angle. It draws lines between 2 price levels.

To draw straight line, you would figure out what change in price is needed, and then add that to the previous level, bar after bar.

this has an example that calcs an angle.

https://tlc.thinkorswim.com/center/reference/thinkScript/Functions/Math---Trig/ATan
----------

3.

if barnumber(18) then (open+close)/2

if secondsfromtime(930) between 10200 and 10800 then (open+close)/2

I would suggest using the function called between, instead of the word.

https://tlc.thinkorswim.com/center/reference/thinkScript/Functions/Others/Between
the following codes are untested

def x = if barnumber() == 18 then (open+close)/2 else x[1];

you know the time you want to read data, why not try to use it.

midbodyval() is equal to (open+close)/2

def starttime = if secondsfromtime(1130) == 0 then midbodyval() else starttime[1];

def endtime = if secondsfromtime(1530) == 0 then midbodyval() else endtime[1];

Now you have the price levels for the start time and the end time, so you can calculate the difference in price, after the end time.

def periodpricediff = if secondsfromtime(1130) == 0 then endtime - starttime else periodpricediff[1];

count how many bars are in the period.

def barqty = if secondsfromtime(1130) == 0 then 1 else if secondsfromtime(1130) > 0 and

secondstilltime(1530) <= 0 then barqty[1] + 1 else barqty[1];

then divide by the quantity of bars in the Period between start and end, to get the average price gain per bar, the slope.

def slopeprice = periodpricediff / barqty;

def na = double.nan;

def ema50= ...

def line1 = if secondsfromtime(1530) == 0 then ema50 else if secondsfromtime(1530) > 0 then line1[1] + slopeprice else na;

plot z = line1;

option

keep starting price in a var and add some price factor.

come up with some multiplayer as you go along to get the correct price change.. You can count the bars after the end time and multiply it by the price difference.

barsafter = if secondsfromtime(1530) == 0 then 0 else barsafter[1] + 1;

-------------

4.

I already have a properly configured label for slope

why mention something, but not show it.

-------

5.

Obviously if I can get the avg price * (slope/360)

you keep mentioning this slope/360?

where did it come from. it isn't obvious.

I think you are trying to make it too complicated by calculating an angle and using that to somehow to draw a line.

every time someone says, simply or obviously, it isn't. If you find yourself using these words, reread your last few sentences and see if you can expand on them.

-----------------

https://tlc.thinkorswim.com/center/reference/thinkScript/Functions/Tech-Analysis/MidBodyVal
https://usethinkscript.com/threads/how-to-plot-a-line-between-2-points.6945/#post-67309
4 examples, draw lines in expansion area

https://usethinkscript.com/threads/plotting-in-the-expansion-area.9765/#post-89607
-------

I typed this out on my phone, so I hope I don't have too many types