Display lowest price between two crossover events

Category:
0
0

Hi,

I have created the scanner to determine the recent Golden Cross and Death Cross. Now I try to add a custom column in my scan output to show the lowest stock price between the 2 SMA crossovers.

However, the fold statement doesn’t allow me to use multiple variables.

I have determine say, A as the number of days from today for the Golden Cross and B as the number of days from today for the Death Cross. Now i need a way to determine the lowest price between A and B.

Anyone can help?

RESOLVED
Marked as spam
Posted by (Questions: 1, Answers: 1)
Asked on September 26, 2021 8:41 am
11 views
 ▲ 0 ▼ ✔ Private answer Since you are requesting a custom watchlist column to add to the scan results section I have moved this out of the "Stock Scanners" topic and into the "Watch Lists" topic. I have also updated the title of the question to more clearly describe the context of your request. I have learned to avoid using the "fold" looping structure because it's limitations make it extremely difficult to apply to anything useful. It also introduces extra load on the script because the loop will run each time the chart is updated. Here is my generic solution which includes two moving averages. The code displays minus 1 of no crossing below event is found. Once the crossing below event occurs it immediately tracks the lowest price until the moving averages cross back in the other direction. The recursive variable will then hold onto to that value (lowest low between crosses) until a new crossing below event occurs. At which point the cycle repeats. ```def maOne = Average(close, 50); def maTwo = Average(close, 200); def crossBelow = maOne crosses below maTwo; rec lowestBetweenCross = CompoundValue(1, if crossBelow then low else if maOne < maTwo and low > 0 and low < lowestBetweenCross[1] then low else if maOne > maTwo then lowestBetweenCross[1] else lowestBetweenCross[1], -1); plot data = lowestBetweenCross;``` Marked as spam Posted by Pete Hahn (Questions: 39, Answers: 3751) Answered on September 27, 2021 8:01 am