Using Summation to identify double bottom
Forums › ProRealTime English forum › ProScreener support › Using Summation to identify double bottom
- This topic has 5 replies, 2 voices, and was last updated 3 months ago by sgrech.
-
-
09/16/2024 at 5:29 PM #237650
Please see attached chart screenshot
I am trying to identify where a 10 period ma (broken blue line) does not make a lower low
I thought I could use summation function.
something like
Where 10ma>10ma[1] and 10ma[1]<10ma[2] (ie 10ma has reversed direction)
using summation exmaine the last n bars (lets n = 6) ma10<ma10[1] and look for assets where the count=>5 (remember the for latest bar the ma10>ma10[1])
Then for the prior 10 bars prior to bar 6 I need to see assets where the ma10[]>ma10[]>=7
Then for the 14 bars prior to that i need return assets where ma10[]<ma10[] >=12
If all three criteria are met then include in results.
I hope this making sense. Basically I wish to examine the 6 bars then the prior 10 bars prior and then the 14bars prior to that so looking at total 30 bars
Any help would be appreciated.
Thank you very much
Simon
09/17/2024 at 6:32 AM #23767209/17/2024 at 8:29 AM #237680Hi Simon,
I believe there’s a more efficient way to approach the problem to reduce computational time while still getting the results you’re looking for.
Instead of manually iterating over the bars, you can use a combination of the 10-period moving average and a check for direction changes. Additionally, with the summation function, you can quickly verify how many times this change has occurred within a range of N bars. Here’s how the code might look:1234567891011// Calculate the 10-period moving averagema10 = average[10](close)// Check for the direction changechange = ma10 > ma10[1] and ma10[1] < ma10[2]// Use summation to check how many times the change occurred in the last 15 barscheck = summation[15](change)// Use barssince to find how many bars have passed since the last changebar = barssince(change)This approach optimizes the calculations and reduces complexity, while being more efficient in terms of runtime. You can adjust the number of bars to examine or combine it with other criteria as needed.
I hope this helps.09/17/2024 at 9:34 AM #237684Thanks this does help.
Thinking I will only look for those asset where the check = 2
// Use summation to check how many times the change occurred in the last 15 barscheck = summation[15](change)Is there a way to somehow check whether for the 2nd (latest) change in direction, that MA10 value is above MA10 value at the time of the 1st change in direction?Many thanksSimon09/17/2024 at 11:42 AM #237702Here you have an example:
12345678910111213141516171819// Calculate the 10-period moving averagema10 = average[10](close)// Check for the direction changeif ma10 >= ma10[1] and ma10[1] < ma10[2] thenprevMAvalue=MAvaluechange=1MAvalue=ma10[1]elsechange=0endif// Use summation to check how many times the change occurred in the last 15 barscheck = summation[15](change)// Use barssince to find how many bars have passed since the last changebar = barssince(change)return ma10 coloured("orange"), MAvalue coloured("darkblue"), prevMAvalue coloured("red")style(dottedline)09/17/2024 at 3:37 PM #237718Thank for this, although this appears to be an indicator? Just in case I did not make myself clear .
I am seeking to screen for assets where the 2nd change of direction the 10ma value is higher than the 10ma at the point where the first change of direction occurred.
-
AuthorPosts
Find exclusive trading pro-tools on