Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Enter on Third Bar open

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

    Enter on Third Bar open

    Hi,

    Once my strategy meets conditions I would like to enter on the THIRD bar OPEN.

    How can I code that? Does anyone have any examples?

    I would appreciate your help!

    #2
    Hello Rawheritage,

    Thanks for your post.

    When your condition is true save the bar number, then test that the current bar is 3 bars past the saved bar number. For example, savedBar is declared as private int savedBar;

    if (your conditions)
    {
    savedBar = CurrentBar; // store the current bar number
    }

    if (CurrentBar - savedBar == 3)
    {
    // entry order
    }

    Reference: http://ninjatrader.com/support/helpG...currentbar.htm

    Note: If (your conditions) become true again before 3 bars it will reset the count.

    Comment


      #3
      Hi Paul,

      If I used these lines in a strategy, is it enough to declare the savedBar as follows:

      private int savedBar;

      or do I have to specify something else in that line?

      Comment


        #4
        Hello WilliamW,

        Thanks for your post and welcome to the forums!

        That would be the correct way to declare an int variable in the regions Variable.

        The // entry order would be replaced by the actual order used for entry.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by CarlTrading, 03-31-2026, 09:41 PM
        1 response
        54 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by CarlTrading, 04-01-2026, 02:41 AM
        0 responses
        29 views
        0 likes
        Last Post CarlTrading  
        Started by CaptainJack, 03-31-2026, 11:44 PM
        0 responses
        40 views
        1 like
        Last Post CaptainJack  
        Started by CarlTrading, 03-30-2026, 11:51 AM
        0 responses
        56 views
        0 likes
        Last Post CarlTrading  
        Started by CarlTrading, 03-30-2026, 11:48 AM
        0 responses
        47 views
        0 likes
        Last Post CarlTrading  
        Working...
        X