how to find the biggest candlestick over the last 10 bars
Forums › ProRealTime English forum › ProBuilder support › how to find the biggest candlestick over the last 10 bars
- This topic has 3 replies, 2 voices, and was last updated 7 years ago by ck1066.
-
-
08/07/2017 at 11:07 AM #4266108/07/2017 at 12:07 PM #42666
You line of code tests the current RANGE with that of the 10th bar before, but there can be greater ones in the middle!
Try this one:
12y = summation[12](range > range[1])GRAPH y AS "y"It makes a sum of your condition for the number of bars in brackets. The output is in how many bars your condition is true, even not consecutively. If you need it to be consecutive you have to test the output against the number in brackets to check if they match.
You could also use FOR…NEXT loops, but it’s far more time consuming!
I tested it on AudCad DAILY and found a match on May 13th, 2013, but the odd thing is that it seems to output a value which is 2 less than the number in brackets. 12 will found 10, 11 will output 9…
Sorry, can’t figure out why, you will have to experiment a bit.
GRAPH is useless for the logic, I used it just for debugging purposes only.
08/07/2017 at 11:40 PM #42721Sorry, but SUMMATION is not the correct instruction, because it checks that each range, from the current one down to the nth one, is greater that the previous. So they need to be consecutively smaller that the previous one.
So the correct solution is to use FOR… NEXT loops:
123456789101112x = 0 //let's start the count from 0for i = 1 to 10if range > range[i] then //range never changes, it is always the currentx = x + 1 //one and it is tested against all previous ten,endif //no need for them to be always smaller thannext //the previous one, just smaller than the current one!if x = 10 then //if x = 10 then all 10 previous ranges are less. //than the current one.endif1 user thanked author for this post.
08/08/2017 at 9:34 AM #42735 -
AuthorPosts