Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

X bars passed

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

    X bars passed

    I am looking through all of the "Bars" in the keyword index to find what I might use for my situation, but I can't seem to find it.

    I want to make sure that there are at least 4 bars that have passed since the previous variable that was defined.

    For example, if I find a swing low that occurred 2 bars ago and I name that "SL1" then I want to make sure that there are at least 4 bars that pass before it starts searching for the next swing low that would be called SL2.

    Could you tell me how I could accomplish this?

    I have looked specifically under BarsPeriod and GetBar but I am not too sure that those are correct.

    #2
    Hello jg123,

    Thank you for your note.

    My recommendation would be when you get the first SL1 would be to store the current bar at that time as well.

    int myStartBar = CurrentBar;

    Then you can compare the Current running bar to the myStartBar when its 4 or greater than

    if(CurrentBar - myStartBar >= 4)
    Cal H.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by CarlTrading, 03-31-2026, 09:41 PM
    1 response
    131 views
    1 like
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 04-01-2026, 02:41 AM
    0 responses
    74 views
    1 like
    Last Post CarlTrading  
    Started by CaptainJack, 03-31-2026, 11:44 PM
    0 responses
    117 views
    2 likes
    Last Post CaptainJack  
    Started by CarlTrading, 03-30-2026, 11:51 AM
    0 responses
    111 views
    1 like
    Last Post CarlTrading  
    Started by CarlTrading, 03-30-2026, 11:48 AM
    0 responses
    89 views
    0 likes
    Last Post CarlTrading  
    Working...
    X