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 NullPointStrategies, Today, 05:17 AM
      0 responses
      52 views
      0 likes
      Last Post NullPointStrategies  
      Started by argusthome, 03-08-2026, 10:06 AM
      0 responses
      130 views
      0 likes
      Last Post argusthome  
      Started by NabilKhattabi, 03-06-2026, 11:18 AM
      0 responses
      70 views
      0 likes
      Last Post NabilKhattabi  
      Started by Deep42, 03-06-2026, 12:28 AM
      0 responses
      44 views
      0 likes
      Last Post Deep42
      by Deep42
       
      Started by TheRealMorford, 03-05-2026, 06:15 PM
      0 responses
      49 views
      0 likes
      Last Post TheRealMorford  
      Working...
      X