Count condition help

Forums ProRealTime English forum ProBuilder support Count condition help

Viewing 12 posts - 1 through 12 (of 12 total)
  • #67507

    Hi,

    I am trying to code an indicator which does a count. The count is set to zero and rises to one when high and low of a candle is less than the high and low of the previous candle. The count would be increased by one every time the high and low of a candle are lower than the high and low of the most recent candle on which the count was increased.

    The count would continue until X (to be defined).

    The count will reset to zero when a new high is formed; this means when the new high is higher than the high of the candle which preceded the count one candle.

    Any candles not adhering to the conditions above are to be ignored.

    Managed to write a code but it only looks at the previous candle rather than at the one on which the count increased, also can’t get the reset condition in. Code is below

    Could anyone please help me build up this code?

    Thanks

    #67509

    Try this (not tested)

     

    #67520

    Hi, thanks for the input, but your code is doing the same as the original code i put in.

    I need it to look at the candle which increased the count rather than the previous candle, and to reset to zero when a new high is formed.

    Any ideas?

    Thanks

    #67574

    Can you attach a screenshot where you draw numbers or something to better explain what you mean?

    Thank you.

    #69028

    Hi,

    Please find attached photo as an example. Whenever the high and low of a candle are less than or equal to the high and low of the candle with a new high(which has a 0 count), the count begins and is set to 1. The count increases to 2 when the high and low of a following candle are less than or equal to the high and low of the candle that increased the count to 1. The count increases to 3 when the high and low of a following candle are less than or equal to the high and low of the candle that increased the count to 2. The count increases to 4 when the high and low of a following candle are less than or equal to the high and low of the candle that increased the count to 3. The count continues only until it reaches 4.

    Whenever a new high is formed(whenever the high of a candle is higher than the high of the candle that had the previous count 0), the count resets to 0. Any other candles that do not meet the criteria are ignored. I hope this makes sense and someone could help with this.

    Thanks

    #69054

    There you go. Give me some feedback. Thanks.

     

    2 users thanked author for this post.
    #69103

    Hi,

    Thank you for your help again. Unfortunately is not returning what I am looking for; is the same problem as previously; rather than increasing the count when the high and low of a candle are equal to or less than the high and low of the candle that previously increased the count, is increasing the count when the high and low are equal to or less that the high and low of the preceding candle.

    Also when checking if a new high is formed, it looks at the previous candle rather than at the candle which was the previous high.

    I think the condition should be something like: “IF low < low[low of candle that increased the count] AND high < high[high of candle that increased the count] THEN “. Is something like this possible? Or can it only look at a specified candle eg. 1=previous candle?

     

    Thanks

    #69107

    I hope this will do, I tested it on Eur/Chf, 15min and it seems to be working.

     

    #69179

    The count of the candles is working now, thank you.

    The only problem left is that when checking if a new high is formed, it looks at the previous candle rather than at the candle which was the previous high.

    For example, on the chart you attached, let’s look at the first candles on the left which have the numbers 1 2 3 underneath. The candle which has the number 3 is followed by a red one and then by a blue one. The blue candle should have been number 4 (the high and low of this are less than the high and low of candle with count 3; red candle after the candle with the count of 3 should be ignored as the high of this is not higher than the high of candle 0)but it doesn’t because the red candle after the one with the count of 3 resets the count to 0 because is looking at the candle with the count 3 and a new high is formed. The high of the red candle should be looking at the high of the candle before the candle with the count 1 as this was the previous candle with the count 0.

    I hope this makes sense, as is quite complicated to explain.

    Thanks

    #69229

    For example, on the chart you attached, let’s look at the first candles on the left which have the numbers 1 2 3 underneath. The candle which has the number 3 is followed by a red one and then by a blue one. The blue candle should have been number 4 (the high and low of this are less than the high and low of candle with count 3; red candle after the candle with the count of 3 should be ignored as the high of this is not higher than the high of candle 0)but it doesn’t because the red candle after the one with the count of 3 resets the count to 0 because is looking at the candle with the count 3 and a new high is formed. The high of the red candle should be looking at the high of the candle before the candle with the count 1 as this was the previous candle with the count 0.

    Should it reference candle 0 or the candle that incremented the count?

     

    #69232

    The count will reset to zero when a new high is formed; this means when the new high is higher than the high of the candle which preceded the count one candle.

    You warned me not to reference candle 0 to increment count, but the previous candle that caused the count to be incremented, is that correct?

    When you talk about a new high, should I reference the high of candle 0 or the high of the candle that most recently caused the count to be incremented?

     

    #69233

    I modified the code to reflect your last post (I hope I could understand what you meant)

     

Viewing 12 posts - 1 through 12 (of 12 total)

Create your free account now and post your request to benefit from the help of the community
Register or Login