Announcement

Collapse
No announcement yet.

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, 05: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 Franck Z, Today, 09:49 AM
      0 responses
      6 views
      0 likes
      Last Post Franck Z  
      Started by pvtrader, Today, 08:02 AM
      2 responses
      7 views
      0 likes
      Last Post pvtrader  
      Started by Natoc, Today, 03:04 AM
      1 response
      17 views
      0 likes
      Last Post NinjaTrader_Jason  
      Started by Rudy2323, Today, 02:56 AM
      2 responses
      28 views
      0 likes
      Last Post Rudy2323  
      Started by tonynt, Yesterday, 02:07 PM
      1 response
      38 views
      0 likes
      Last Post NinjaTrader_Jason  
      Working...
      X