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:	28
Size:	93.9 KB
ID:	1103119

    Am I missing something obvious?

    Thanks.

    #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.

      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 LeonK, Today, 09:26 PM
        0 responses
        2 views
        0 likes
        Last Post LeonK
        by LeonK
         
        Started by NicholasJoannette, Today, 03:01 PM
        2 responses
        9 views
        0 likes
        Last Post NicholasJoannette  
        Started by rach1994, Today, 12:20 PM
        1 response
        34 views
        0 likes
        Last Post bltdavid  
        Started by litamm89, Today, 11:00 AM
        5 responses
        17 views
        1 like
        Last Post rafael_delima86  
        Started by rafael_delima86, Today, 05:01 PM
        0 responses
        2 views
        0 likes
        Last Post rafael_delima86  
        Working...
        X