How to plot a 50% line for the hod including premarket. “Deathline, DL”


Category:
0
0

Having trouble getting this to work, I have had success with the open high of day but I need the actual high of day including the p/m action.  This 50% pullback line should change as the high of day increases.  My study is incorrect because it is showing the pullback as a % I need it to show that in $ amount and draw a line on the chart as well.  Thank you for your help I’m just getting started with script! Here’s my code:

 

input length = 1;#hint length:the number of trading days-ago for the change
def price = close(period = AggregationPeriod.day);
def Change = (price / price[length] – 1);

Plot PctChange = 100 * change*.5;
AddLabel(yes,”DL ” + Round(PctChange, 1) + “%”, if PctChange < 0 then color.RED else color.GREEN);

Attachments:
Marked as spam
Posted by (Questions: 2, Answers: 3)
Asked on June 21, 2019 7:39 am
283 views
0

Well I have some code for you that will plot the high of day including the extended hours session. (extended hours session includes previous day's post-market hours along with current day's pre-market hours). 

As to the 50% pull back line. I think you have not clearly defined how that should be computed. You did include some code and explained that the code computed that value as a percent rather than a value. It seems from your code that this percent is computed using the previous day's close. So does that mean you want this so-called "Death Line" to be computed as the midway point between the previous day's close and the current day's high?

Once I get this clarified I will change your question's title to better reflect the context of your question and make it easier for other viewers to search for and find this post.

( at June 23, 2019 9:44 am)
0
I want this study to reflect the current trading day only. hod (including p/m) - 50% marked on the chart with a line, for my strategy this will simulate the Deathline. thanks Pete!
( at June 25, 2019 9:39 am)
0
Ok I still have a question about how this is computed. From your clarification it seems you want to take the high of day and compute a level that is 50% below that level. So for a high of day that equals 10, you would want this 50% line to be drawn at 5. Is this correct?
( at June 25, 2019 9:52 am)
0
yes but if the hod changes and goes to 11 i want the 50% line to change as well. so $5.50 including p/m action!
( at June 25, 2019 11:33 am)
0
Private answer

 

try this, but there's a limitation you can only have one day of price action, if not it will take higher highs or lower lows from the days prior and and the calculation will change.

 

def AllTimeHigh = HighestAll(high);
def AllTimeLow = LowestAll(low);
plot fifty = (alltimeHigh + alltimelow)/2;

Attachments:
Marked as spam
Posted by (Questions: 8, Answers: 23)
Answered on June 30, 2019 6:31 pm
0
thank you so much!
( at July 2, 2019 10:54 am)