Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Conditions and Order Management Calculation

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

    Conditions and Order Management Calculation

    Hello,
    Is it possible to have my conditions checked OnBarClose and at the same time have my order management conditions updated OnEachTick?

    Currently I have everything listed under " protected override void OnBarUpdate() "

    What should I do? Is it possible?

    #2
    Hello KINGKODA,

    Thanks for your inquiry.

    Bar closes are triggered by a "tick through." You could trigger events that occur on bar closes by using IsFirstTickOfBar. The bar that had just closed can be referenced with a BarsAgo of 1 for each Series<t> object. (Close[1] on that tick for the close price of that bar that had just closed. This would be Close[0] for OnBarClose calculation modes.) Your other logic that should occur on each tick should happen outside of this condition.

    Code:
    if(IsFirstTickOfBar)
    {
    	double CurrentTick = Close[0];
    	double ClosedBar = Close[1];
    }
    Documentation on IsFirstTickOfBar is publicly available here - https://ninjatrader.com/support/help...ttickofbar.htm

    Please let us know if we can be of further assistance.

    Comment


      #3
      Thanks Jim,

      The Strategy needs to Calculate.OnEachTick to be able to add if(IsFirstTickOfBar) which calculates onbarclose.

      I was wondering if the reverse is possible. To have the Strategy Calculate.OnBarClose, then to add a Syntax for oneachtick calculations.

      Would protected override void OnMarketData work? If not, what is possible?

      Comment


        #4
        Hello KINGKODA,

        Calculate.OnEachTick and Calculate.OnBarClose will have different barsAgo indexing, so you would not be able to use the same indexing for Calculate.OnBarClose to get the value for the last tick that comes in. Price Series objects will update based on the Calculate mode.

        You could use OnMarketData for level 1 events that come in for each tick, however it should be noted that this is a realtime data stream and will not work historically unless Tick Replay is used.

        Additional reference for OnMarketData() can be found here - https://ninjatrader.com/support/help...marketdata.htm

        Please let us know if you have any additional questions.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by NullPointStrategies, Yesterday, 05:17 AM
        0 responses
        54 views
        0 likes
        Last Post NullPointStrategies  
        Started by argusthome, 03-08-2026, 10:06 AM
        0 responses
        131 views
        0 likes
        Last Post argusthome  
        Started by NabilKhattabi, 03-06-2026, 11:18 AM
        0 responses
        73 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