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 out of the money, Today, 11:14 PM
        0 responses
        10 views
        0 likes
        Last Post out of the money  
        Started by out of the money, Today, 11:10 PM
        1 response
        11 views
        0 likes
        Last Post out of the money  
        Started by Specularix, Today, 01:28 PM
        15 responses
        136 views
        0 likes
        Last Post FMtrader  
        Started by lfbxindekaishi, Today, 10:32 PM
        0 responses
        12 views
        0 likes
        Last Post lfbxindekaishi  
        Started by dweems, 11-15-2022, 11:37 AM
        4 responses
        32 views
        0 likes
        Last Post dweems
        by dweems
         
        Working...
        X