Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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.
    JimNinjaTrader Customer Service

    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.
        JimNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by trilliantrader, 04-18-2024, 08:16 AM
        4 responses
        18 views
        0 likes
        Last Post trilliantrader  
        Started by mgco4you, Today, 09:46 PM
        1 response
        7 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Started by wzgy0920, Today, 09:53 PM
        0 responses
        9 views
        0 likes
        Last Post wzgy0920  
        Started by Rapine Heihei, Today, 08:19 PM
        1 response
        10 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Started by Rapine Heihei, Today, 08:25 PM
        0 responses
        10 views
        0 likes
        Last Post Rapine Heihei  
        Working...
        X