Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Setting Calculate gives Compiler Error

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

    Setting Calculate gives Compiler Error

    According to the NT8 Help documentation, one can set Calculate as follows:
    Code:
    protected override void OnStateChange()
    {
        if (State == State.SetDefaults)
        {
            // Calculate on the close of each bar
            Calculate = Calculate.OnBarClose;
        }
    }
    When I do that in an AddOn, I get a compiler error:

    Click image for larger version

Name:	NT8 Calculate Compiler Error.png
Views:	101
Size:	93.9 KB
ID:	1103119

    Am I missing something obvious?

    Thanks.
    Multi-Dimensional Managed Trading
    jeronymite
    NinjaTrader Ecosystem Vendor - Mizpah Software

    #2
    Hello jeronymite,

    Thanks for your question.

    Calculate will be available when we are working with a NinjaScript that utilizes OnBarUpdate. This is not available in AddOn where we would need to use BarsRequests to request and process bar data.

    BarsRequests do not offer a Calculate mode, but will calculate following OnEachTick processing. We can identify when a bar has closed if the index for the updating bar changes in the BarsRequest update event.

    Code:
    private int last = -1;
    
    private void BROnBarUpdate(object sender, NinjaTrader.Data.BarsUpdateEventArgs e)
    {    
        /* Depending on the BarsPeriod type of your barsRequest you can have situations where more than one bar is
           updated by a single tick. Be sure to process the full range of updated bars to ensure you did not miss a bar. */
    
        ClearOutputWindow();
    
        // Output bar information on each tick 
        for (int i = e.MinIndex; i <= e.MaxIndex; i++)
        {
            if (i != last)
            {
                NinjaTrader.Code.Output.Process("NewBar", PrintTo.OutputTab1);
                last = i;
            }
        }
    }
    BarsRequest - https://ninjatrader.com/support/help...arsrequest.htm

    We look forward to being of further assistance.
    JimNinjaTrader Customer Service

    Comment


      #3
      Thanks, Jim.

      I'm already using BarsRequest, and it's good to know the Calculate mode.

      I was surprised that trying to use Calculate in an AddOn caused a compile-time error. I would have hoped for a more graceful means of "unavailability".

      Also, may I recommend that the documentation be updated to state that Calculate is not available in AddOns, and to refer to BarsRequest and its OnEachTick Calculate mode, please?

      Thanks again.
      Multi-Dimensional Managed Trading
      jeronymite
      NinjaTrader Ecosystem Vendor - Mizpah Software

      Comment


        #4
        Hello jeronymite,

        Thanks for your feedback.

        I have submitted your request to the Product Management group for consideration.
        JimNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by elirion, Today, 01:36 AM
        0 responses
        3 views
        0 likes
        Last Post elirion
        by elirion
         
        Started by gentlebenthebear, Today, 01:30 AM
        0 responses
        4 views
        0 likes
        Last Post gentlebenthebear  
        Started by samish18, Yesterday, 08:31 AM
        2 responses
        9 views
        0 likes
        Last Post elirion
        by elirion
         
        Started by Mestor, 03-10-2023, 01:50 AM
        16 responses
        390 views
        0 likes
        Last Post z.franck  
        Started by rtwave, 04-12-2024, 09:30 AM
        4 responses
        34 views
        0 likes
        Last Post rtwave
        by rtwave
         
        Working...
        X