Peak Valley
Forums › ProRealTime English forum › ProBuilder support › Peak Valley
- This topic has 5 replies, 3 voices, and was last updated 5 years ago by Nicolas.
-
-
06/19/2019 at 10:40 AM #101028
Hi, I have seached forums for “Peak” / “Valley” functions but not exactly found what Im looking for.
Im looking for a method / function to identify peaks / valleys which are not so pointy. For example using a moving average with 500 on a price curve generates this type of slow peaks / valleys. The functions I have found in the forum doesnt find these peaks / valleys.
Any idea what type of code I could use to identify those ones. They often have a few bars of a horizontal line in the middle.
06/19/2019 at 11:10 AM #101032Yes, a PEAK is when your average is the highest within a range of bars, VALLEY is when it’s the lowest.
Peaks & Valleys12345678910111213DEFPARAM CalculateOnLastBars = 3000p = 500LookBack = 500MyAvg = average[p,0](close)Valley = lowest[LookBack](MyAvg)Peak = highest[LookBack](MyAvg)x = 0IF MyAvg = Peak THENx = 1ELSIF MyAvg = Valley THENx = -1ENDIFRETURN x,006/19/2019 at 8:11 PM #101077Thanks! Thats a good definition of PEAK / VALLEY.
I have another question, it might not be on the same topic but related how would you define or try to measure falling, for example a falling ADX.
06/19/2019 at 9:04 PM #101080A falling ADX is current ADX < previous ADX.
The falling is even stronger the more periods you account for ADX < previous one!
06/19/2019 at 11:20 PM #101083Examples:
Falling ADX123456Periods = 14 //14 ADX periodsLookBack = 3 //3 consecutive falling ADX periodsMyAdx = Adx[Periods]IF summation[LookBack](MyAdx < MyAdx[1]) = LookBack THEN//actions to be taken when ADX is falling for 3 LOOKBACK consecutive periodsENDIFyou need to replace MyAdx < MyAdx[1] with MyAdx > MyAdx[1] for a rising ADX.
1 user thanked author for this post.
06/20/2019 at 7:30 AM #101090As for peak and valley, you can also use any type of highest high / lowest low detection such as zigzag, fractals, swing hi/lo, donchian channel, ..
1 user thanked author for this post.
-
AuthorPosts
Find exclusive trading pro-tools on