Weekly Price Level


Category:
0
0

Hey all –

I was wondering if anyone could help me with a bit of coding for the following:

– Price level across whole WEEKLY chart 2% from current weekly open price.

If it wasn’t too much effort I’d like to have two more variables within the same code (i.e. 5% and 10%)

Much appreciated!

RESOLVED
Marked as spam
Posted by (Questions: 4, Answers: 2)
Asked on July 26, 2020 3:26 pm
63 views
0
Private answer

A screenshot showing exactly what you have in mind would have been very helpful here.

Let's see if I understand this correctly.

For a chart set to weekly time frame, you would like a horizontal plot to display a value based on the current week's opening price, times 2%. You would like that plot to extended for the entire length of chart. So one value based on the current week's opening price, is plotted for the entire chart.

If this is correct, then the last bar on the chart contains the value we need to base our computations. The code that follows includes a user adjustable input so that you can adjust the percent value used to compute the plot. This code can be applied to any time frame and the code will always base the computations on the opening price of the last bar on the chart.

input percentThreshold = 2.0;
def lastBar = !IsNaN(close) and IsNaN(close[-1]);
plot weeklyOpen = HighestAll(if lastBar then open else Double.NaN) * (1 + percentThreshold * 0.01);

Marked as spam
Posted by (Questions: 37, Answers: 4118)
Answered on July 26, 2020 4:49 pm
0
Thank you very much Pete! That's exactly what I meant.
( at July 27, 2020 7:25 am)