• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

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:	18
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 waldoalvarez, Today, 04:59 PM
        0 responses
        2 views
        0 likes
        Last Post waldoalvarez  
        Started by habibalex, Today, 09:45 AM
        2 responses
        13 views
        0 likes
        Last Post habibalex  
        Started by junkone, Today, 03:42 PM
        1 response
        6 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by peterslane1, Today, 09:47 AM
        2 responses
        17 views
        0 likes
        Last Post aviat72
        by aviat72
         
        Started by SlickRick, Today, 02:47 PM
        1 response
        9 views
        0 likes
        Last Post NinjaTrader_Zachary  
        Working...
        X