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.
    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 memonolog, Today, 03:30 AM
        0 responses
        2 views
        0 likes
        Last Post memonolog  
        Started by toughiee, Today, 12:04 AM
        0 responses
        4 views
        0 likes
        Last Post toughiee  
        Started by vdoan20, Yesterday, 08:30 PM
        0 responses
        8 views
        0 likes
        Last Post vdoan20
        by vdoan20
         
        Started by gupagoer, Yesterday, 07:42 PM
        0 responses
        10 views
        0 likes
        Last Post gupagoer  
        Started by Holligoly, Yesterday, 05:13 PM
        2 responses
        11 views
        0 likes
        Last Post Holligoly  
        Working...
        X