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 CaptainJack, 05-29-2026, 05:09 AM
      0 responses
      429 views
      0 likes
      Last Post CaptainJack  
      Started by CaptainJack, 05-29-2026, 12:02 AM
      0 responses
      281 views
      0 likes
      Last Post CaptainJack  
      Started by charlesugo_1, 05-26-2026, 05:03 PM
      0 responses
      241 views
      1 like
      Last Post charlesugo_1  
      Started by DannyP96, 05-18-2026, 02:38 PM
      1 response
      330 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 05-11-2026, 05:56 AM
      0 responses
      290 views
      0 likes
      Last Post CarlTrading  
      Working...
      X