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 CarlTrading, 03-31-2026, 09:41 PM
      1 response
      43 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 04-01-2026, 02:41 AM
      0 responses
      21 views
      0 likes
      Last Post CarlTrading  
      Started by CaptainJack, 03-31-2026, 11:44 PM
      0 responses
      30 views
      1 like
      Last Post CaptainJack  
      Started by CarlTrading, 03-30-2026, 11:51 AM
      0 responses
      50 views
      0 likes
      Last Post CarlTrading  
      Started by CarlTrading, 03-30-2026, 11:48 AM
      0 responses
      41 views
      0 likes
      Last Post CarlTrading  
      Working...
      X