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 fire

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

    OnBarUpdate not fire

    OnBarUpdate does not fire when applying strategy to a Chart using Market Replay for ES 06-18. I have simplified the code to just display messages in the output window.

    namespace NinjaTrader.NinjaScript.Strategies
    {
    public class SimpleMACrossOver : Strategy
    {

    protected override void OnStateChange()
    {

    if (State == State.SetDefaults)
    {
    // NinjsAcript Output window
    NinjaTrader.Code.Output.Reset(PrintTo.OutputTab1);
    NinjaTrader.Code.Output.Process("SimpleMACrossOver ", PrintTo.OutputTab1);
    NinjaTrader.Code.Output.Process("State.SetDefaults ", PrintTo.OutputTab1);

    Description = @"SimpleMACrossOver.";
    Name = "SimpleMACrossOver";
    Calculate = Calculate.OnBarClose; //Calculate.OnEachTick
    BarsRequiredToTrade = 20;
    IsInstantiatedOnEachOptimizationIteration = false;

    }
    else if (State == State.DataLoaded)
    {
    NinjaTrader.Code.Output.Process("State.DataLoaded" , PrintTo.OutputTab1);
    }


    else if (State == State.Configure)
    {
    NinjaTrader.Code.Output.Process("State.Configure", PrintTo.OutputTab1);
    }
    }

    protected override void OnBarUpdate()
    {
    NinjaTrader.Code.Output.Process("Here", PrintTo.OutputTab1);
    }

    }
    }
    Attached Files

    #2
    Hello TradingDreamer,

    Thanks for your post.

    I do not see the same results testing with Market Replay Data: https://www.screencast.com/t/lhopHIls

    I did notice in your screenshot that the strategy is not enabled. The strategy will go through the SetDefaults and Configure states when settings are applied before the strategy gets enabled. Upon enablement, DataLoaded, Historical, and then Realtime states will iterate.

    Publicly available documentation for further reading can be found below.

    NinjaScript LifeCycle - https://ninjatrader.com/support/help...fecycle_of.htm

    OnStateChange() - https://ninjatrader.com/support/help...tatechange.htm

    Please let us know if we can be of further assistance.
    JimNinjaTrader Customer Service

    Comment


      #3
      Thank you. It's been a while since I have been coding. Enabling my Strategy worked.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Barry Milan, Yesterday, 10:35 PM
      5 responses
      17 views
      0 likes
      Last Post NinjaTrader_Manfred  
      Started by DanielSanMartin, Yesterday, 02:37 PM
      2 responses
      13 views
      0 likes
      Last Post DanielSanMartin  
      Started by DJ888, 04-16-2024, 06:09 PM
      4 responses
      13 views
      0 likes
      Last Post DJ888
      by DJ888
       
      Started by terofs, Today, 04:18 PM
      0 responses
      12 views
      0 likes
      Last Post terofs
      by terofs
       
      Started by nandhumca, Today, 03:41 PM
      0 responses
      8 views
      0 likes
      Last Post nandhumca  
      Working...
      X