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:	30
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 trader3000a, Today, 10:47 AM
        0 responses
        1 view
        0 likes
        Last Post trader3000a  
        Started by Blairski, Today, 09:30 AM
        0 responses
        9 views
        0 likes
        Last Post Blairski  
        Started by amelialliott, Today, 09:07 AM
        0 responses
        6 views
        0 likes
        Last Post amelialliott  
        Started by SuperDude123, Yesterday, 06:48 PM
        2 responses
        54 views
        0 likes
        Last Post NinjaTrader_Jason  
        Started by j4trdr, Yesterday, 10:23 PM
        1 response
        38 views
        0 likes
        Last Post NinjaTrader_Jason  
        Working...
        X