Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Unable to re-enter on same bar as exit when using an added 1 tick data series

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

    Unable to re-enter on same bar as exit when using an added 1 tick data series

    In my strategy I am calculating entries on on a UniRenko chart (Closes[0])
    I also have a second DataSeries at 1 Tick to calculate exits (Closes[1])

    Code:
    AddDataSeries(Data.BarsPeriodType.Tick, 1);

    After I take an exit in my strategy on Closes[1][0], I would like to be able to re-enter on the upcoming Closes[0][0]. Is that possible? My current code does not seem to work. Simplied logic is below:


    Code:
    if (BarsInProgress == 0) {
    
    if (
    Open[0] > Close[0]
    && CurrentBar > lastOrderBar
    )
    {
    
    lastOrderBar = CurrentBar;
    EnterShort(Convert.ToInt32(DefaultQuantity), "SE"); // this should re-enter since i have exited short position below and reset lastOrderBar to 0???
    
    }
    
    }
    
    
    
    if (BarsInProgress == 1) {
    
    stopShort = High[1];
    if(CrossAbove(Closes[1], stopShort, 1)) {
    
    lastOrderBar = 0;
    ExitShort();
    
    }
    
    }

    this should re-enter since i have exited short position on BarsInProgress(1) and reset lastOrderBar to 0???

    #2
    Hello torch2k,

    Thanks for your post.

    Where are you testing the strategy? (Live chart, Playback with market replay data, or the Strategy analyzer)

    What is the calculate setting of the strategy? (Calculate.OnBarClose, Calculate.OnPriceChange, Calculate.OnEachTick)

    Please use Print statements in both execution blocks to verify that both exit and entry are being hit in order.
    Reference: https://ninjatrader.com/support/help...script_cod.htm

    Comment


      #3
      Hi Paul,

      I am testing the strategy on a live chart's data. And, as soon as I typed that out, I realized that I did not have tick replay enabled on my chart. After enabling I am now seeing some issues with my code, so I need to go back and fix that now. Thanks!

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Mindset, 04-21-2026, 06:46 AM
      0 responses
      90 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by M4ndoo, 04-20-2026, 05:21 PM
      0 responses
      137 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Started by M4ndoo, 04-19-2026, 05:54 PM
      0 responses
      68 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Started by cmoran13, 04-16-2026, 01:02 PM
      0 responses
      120 views
      0 likes
      Last Post cmoran13  
      Started by PaulMohn, 04-10-2026, 11:11 AM
      0 responses
      71 views
      0 likes
      Last Post PaulMohn  
      Working...
      X