Scanning for a relationship between the SMA(20) and the current bar.


Category:
0
0

I’m new here and apologize in advance if this is a stupid question. Here’s the pseudocode for the scan I’m trying to create:

  • ADX(14) is greater than 30
  • ADX(14) in this period is higher than ADX(14) in the last period
  • Current bar high is higher than SMA(20) and current bar low is lower than SMA(20)

I’m okay with lines one and two but I’m thrown by line three. Any help would be greatly appreciated.

Marked as spam
Posted by (Questions: 1, Answers: 0)
Asked on August 5, 2017 12:52 pm
144 views
0
Private answer

It is a shame you did not provide your code for conditions 1 and 2. How are other viewers going to understand the full scope of what you describe? For the third condition, we only need to lines of code. One to create the 20 period SMA and the other to test if the range formed by the high and low of any given bar span the 20 period SMA.

def smaTwenty = Average(close, 20);
def conditionThree = high > smaTwenty and low < smaTwenty;

Marked as spam
Posted by (Questions: 37, Answers: 4087)
Answered on August 5, 2017 9:43 pm
0

Thank you, Pete. I will do so (provide my code) in the future. It may do what you said (help others to see the full scope of what I’m attempting) and it will also provide a chance for a second set of eyes on what I think I know how to do in the likely case that I don’t actually know.

( at August 15, 2017 8:57 am)