Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

OnBarUpdate not getting raised in Strategy

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

    OnBarUpdate not getting raised in Strategy

    Hi there,

    I am developing a strategy, and wanting to debug it. I have put break point in the OnBarUpdate event but it is not getting hit.

    I then put a break point on the first line in the OnBarUpdate event in the SampleMACrossOver strategy:
    Code:
    if (CurrentBar < BarsRequiredToTrade)
    And attached the debugger to NT, and then added and loaded up the SampleMACrossOver strategy on a minute chart that had 5 days of data loaded.

    The break point does not get hit. I added Print statement as the first line of the OnBarUpdate event in the SampleMACrossOver strategy:
    Code:
    Print("Test");
    It compiled when I saved, and I then opened the NT Output window and removed and re-added the strategy to the chart.
    Nothing was printed to the Output window.

    I would have expected that the OnBarUpdate event would be raised for all historical bars and each tick that came in realtime (I have the calculate property set to On Each Tick).

    I have also tried with Calculate set to OnBarClose, but it makes no difference.

    I added a clause to the OnStateChange to detect:
    Code:
    if (State == State.Configure)
    {
        Print("State.Configure");
    }
    I added a break point on the Print line above and also in the State.DataLoaded state clause, and the Configure one does get hit, but the DataLoaded one does not. So breakpoints are working.

    Also this SampleMACrossOver has the lines:
    Code:
    AddChartIndicator(smaFast);
    AddChartIndicator(smaSlow);
    But no indicators are added to the chart, when I add the Strategy.

    The chart is a minute chart, on the FDAX 12-17 and I can see price moves as they happen on the chart, but the strategy just does nothing....

    I am running a Windows 10 64 bit PC with NT 8.0.9.0 64-bit (Multi-Broker) using the sim account.

    What am I doing wrong here?

    Thanks for your time.
    Last edited by codeowl; 11-28-2017, 06:17 AM. Reason: Added more detail.

    #2
    Hello codeowl,

    Thanks for opening the thread with some clear steps we can follow with the bundled SampleMACrossover strategy. The detail provided is much appreciated.

    I ran through enabling debug mode on the NinjaScript Editor, opening Visual Studio, placing a breakpoint, attaching the debugger, and then finally enabling the SampleMACrossover strategy. My breakpoint in OnBarUpdate() was hit.

    I made a quick demo video showing the steps I took: https://www.screencast.com/t/6vaLTrjseP8

    If you are seeing something else taking these steps could you let us know so we can take a further look?

    For the thread's reference, publicly available documentation on using Visual Studio to debug NinjaScripts can be found here: https://ninjatrader.com/support/help..._debugging.htm

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

    Comment


      #3
      NinjaTrader_Jim,

      Thanks heaps for the quick response and the video mate!!

      Twas a "school boy error" on my part... I didn't have the Strategy enabled! lolololl

      Your steps in the vid made this clear, so thanks for taking the time to make it, much appreciated!

      Regards,

      codeowl.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Shansen, 08-30-2019, 10:18 PM
      24 responses
      941 views
      0 likes
      Last Post spwizard  
      Started by Max238, Today, 01:28 AM
      0 responses
      9 views
      0 likes
      Last Post Max238
      by Max238
       
      Started by rocketman7, Today, 01:00 AM
      0 responses
      4 views
      0 likes
      Last Post rocketman7  
      Started by wzgy0920, 04-20-2024, 06:09 PM
      2 responses
      28 views
      0 likes
      Last Post wzgy0920  
      Started by wzgy0920, 02-22-2024, 01:11 AM
      5 responses
      33 views
      0 likes
      Last Post wzgy0920  
      Working...
      X