Plot line from 20 day high 60 days ago?


Category:
0
0

Thanks for your time. Sorry about the confusion. I know its frustrating trying to help someone yet not knowing what they want. This is the same question as above just repost to add pictures through cloud link. Last quesiton can be deleted/removed.

The scan in the link I posted has alot of logic in it, but for simplicity I want to draw a line from a 10 day high 10 days ago, and a 20 day high 60 days ago.

https://www.stockfetcher.com/sfforums/?mid=149271

https://drive.google.com/file/d/1dRyssRnjeWof6o1TbZGoHC9jqoC-Elh9/view?usp=sharing

https://drive.google.com/file/d/1qpvs2ZtEuS96c4tQjmxNkIPOtqR6MqoX/view?usp=sharing

Included two picture. Hope they help. vpeak1 is the 20 day high, vpeak2 is the 10 day high.

Again thanks for your time. Hopefully I was clearer this time.

the scan

https://www.stockfetcher.com/sfforums/?mid=149271

two pics from shareable cloud link

https://drive.google.com/file/d/1dRyssRnjeWof6o1TbZGoHC9jqoC-Elh9/view?usp=sharing

https://drive.google.com/file/d/1qpvs2ZtEuS96c4tQjmxNkIPOtqR6MqoX/view?usp=sharing

Marked as spam
Posted by (Questions: 3, Answers: 1)
Asked on May 5, 2020 9:07 am
98 views
0
Private answer

Thanks for providing those screenshots to help explain your request. In the future you can simply add those screenshots as attachments when you post a new question. The only time you need to use cloud drive is if you are posting in the comments section of the question or answer.

The following code creates a new custom chart study that plots a horizontal line across the entire chart with user adjustable inputs to change the number of bars to check for highest high as well as the number of bars back to find that highest high.

input highestInXBars = 10;
input lookBackBars = 10;
def highestInBarsBack = Highest(high, highestInXBars);
def lastBar = !IsNaN(close) and IsNaN(close[-1]);
def targetHigh = if lastBar then highestInBarsBack[lookBackBars] else 0;

As shown in the screenshot below you can change those inputs to 20 and 60 in order to get the highest high in 20 bars from 60 bars ago. You can add the chart study numerous times to the same chart and adjust the inputs to suit your needs.

And because I know someone will ask for a way to do the lowest lows, there is another section of code that will plot the lows:

input lowestInXBars = 10;
input lookBackBars = 10;
def lowestInBarsBack = Lowest(low, lowestInXBars);
def lastBar = !IsNaN(close) and IsNaN(close[-1]);
def targetLow = if lastBar then lowestInBarsBack[lookBackBars] else Double.POSITIVE_INFINITY;
plot level = LowestAll(targetLow);

The screenshot below does not display the lowest low code because that was not part of the request. But it works in exactly the same way.

Attachments:
Marked as spam
Posted by (Questions: 37, Answers: 4118)
Answered on May 5, 2020 10:00 am