Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Create indicator

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Create indicator

    How to create an indicator that would count the number of consecutive candles for a specified period. Consecutive means several times in a row Open> Close or Close> Open.

    Regards!

    #2
    Hello U0000999,

    Thanks for your post.

    You would need to use an integer variable as a counter (one for each type, up/down bar). In coding, you would check to see if the Close is greater than open and if so to increment the Up counter as well as "reset" the down counter to zero. If the Open is greater than the close then increment the down counter and reset the Up counter.

    Or if you don't want to reset the counters you could just increment the counters.

    Here is a simple example where upCounter and downCounter are created as int at the class level.:

    if (Close[0] > Open[0])
    {
    upCounter++; // increment the up bar counter
    }
    else if (Close[0] < Open[0])
    {
    downCounter++; // incrementg the down bar counter
    }

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by SalmaTrader, 07-07-2026, 10:26 PM
    0 responses
    35 views
    0 likes
    Last Post SalmaTrader  
    Started by CarlTrading, 07-05-2026, 01:16 PM
    0 responses
    20 views
    0 likes
    Last Post CarlTrading  
    Started by CaptainJack, 06-17-2026, 10:32 AM
    0 responses
    12 views
    0 likes
    Last Post CaptainJack  
    Started by kinfxhk, 06-17-2026, 04:15 AM
    0 responses
    18 views
    0 likes
    Last Post kinfxhk
    by kinfxhk
     
    Started by kinfxhk, 06-17-2026, 04:06 AM
    0 responses
    20 views
    0 likes
    Last Post kinfxhk
    by kinfxhk
     
    Working...
    X