Compare two swing lows


Category:
0
0

I am making a study to compare lows so far I have

Def swinglow = if low < low[1] and low < low[2] and low < low[-1] and low < low[-2] then 1 else 0;
plot sl = if swinglow then low else double.nan;

I want to be able to measure differences in the the lows i.e.
sl[1]<=sl[2] or sl[3]>sl[10] etc.
However this returns a N/A. Any advice? Thanks in advance

 

Marked as spam
Posted by (Questions: 1, Answers: 0)
Asked on January 9, 2020 2:02 pm
85 views
0
Private answer

In order to compare two swing lows using your code would require you to know exactly how many bars apart they are.

You can't use the index values: sl[1] <= sl[2] to compare the previous swing low to the swing low that came before it. Because those index values are actually looking at the previous bar and the bar previous to it. Not the swing lows themselves.

The real solution is far more complex than anything I would provide free of charge in the Q&A forum.

Marked as spam
Posted by (Questions: 37, Answers: 4118)
Answered on January 10, 2020 12:19 pm