Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How many bars ago did a signal happen?

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

    How many bars ago did a signal happen?

    NT support,

    Could you please help?

    Probably a really simple question, how do I determine how many bars ago a signal occurred?

    For instance, if I was using a standard MA crossover with CrossAbove(). How could I work back in the USDJPY (for example) prices to determine how may bars ago a CrossAbove happened?

    Thanks and regards,

    drolles

    #2
    Hi drolles,

    You may want to look into MRO, LRO for this. They express the number of bars since a condition.





    You can also custom code it. This can be done by capturing CurrentBar at the time of a condition, and then taking the difference of CurrentBar & this captured value.

    Code:
    #region Variables
    private int myConditionBar;
    #endregion

    protected override void OnBarUpdate()
    {
    if (Close[0] > Open[0])
    myConditionBar = CurrentBar;

    int barsSinceUpClose = CurrentBar - myConditionBar;
    }
    Ryan M.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by CarlTrading, 05-11-2026, 05:56 AM
    0 responses
    31 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, 05-10-2026, 08:12 PM
    0 responses
    21 views
    0 likes
    Last Post CarlTrading  
    Started by Hwop38, 05-04-2026, 07:02 PM
    0 responses
    184 views
    0 likes
    Last Post Hwop38
    by Hwop38
     
    Started by CaptainJack, 04-24-2026, 11:07 PM
    0 responses
    342 views
    0 likes
    Last Post CaptainJack  
    Started by Mindset, 04-21-2026, 06:46 AM
    0 responses
    264 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Working...
    X