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

Indicators don't update intrabar - Realtime & Calculate OnPriceChange or Tick

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

    Indicators don't update intrabar - Realtime & Calculate OnPriceChange or Tick

    I have been struggling to find out why my code, Based on Hull or other Indicators, running Realtime, do not change value Intrabar with PriceChange or Tick Calculate. They only change value on IsFirstTickOfBar. Note: They do change between to different values sets on every other Update, but on NewBar (First Tick) the change is significant.

    I have attached some Output data from one of my tests to show what I am talking about. I have included below the key code lines that create the data.
    The Output data does include my Calculate and State (shows Realtime).

    A factor seems to be the HUL calls WMA three times and WMA performs some of its calculations on on the First Tick of Bar. Close[0] Open[0] etc. do update with price.
    Here is the code extracted from my Strategy that creates the variable recorded in Output.

    // At Class Level
    private HMA HullSlow; // Hull indicaor - Slowest period
    private HMA HullFast; // Hull indicaor - Fastest period

    // In DataLoaded
    HullSlow = HMA(Close, SlowHullPeriod);
    HullFast = HMA(Close, FastHullPeriod);

    // In OnBarUpdate
    ROCHullSlow[0] = HullSlow[0] - HullSlow[1];
    FSHullDelta[0] = HullFast[0] - HullSlow[0];

    (I have tried various permutations of the HMA (Hull) such as looking at one bar back on First Tick (which is recommended) but they have little effect other than pushing the results back in time)

    Attached Ouput from my test print statements (Captured in PlayBack after change from Historical to Realtime). from my test print statements. Records 1 8-29-21.txt

    It confuses me that the guides including SampleEnterOnceExitEveryTick (Using LinReg which also gates on First Tick) lead me to think that these indicator values do update Intrabar.

    #2
    Hi JGRtrader, thanks for posting.

    Please call Update() on your indicators on each OnBarUpdate call to ensure their OnBarUpdate method is called in sync e.g.

    Code:
    HullSlow.Update();
    HullFast.Update();
    
    //after this, the indicators will be up to date.
    Kind regards,
    -ChrisL
    Chris L.NinjaTrader Customer Service

    Comment


      #3
      VS did not like the construct you suggested. But I discovered after collecting and studying a lot of date with each OnBarUpdate that the indicator i am using HUL while it varies as a bar builds, it makes a bigger step change on the first tick of new bar. So the NT cross detect method generally does not fire until the 1st tick.

      The HUL code shows three calls WMA in which some of the code only executes on first bar.

      So I can't really use HUL for much during the build of bars but only at the beginning of a new bar. With 1000 bar chart say, this is a problem so I am figuring out another way to do what I want.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by benmarkal, Yesterday, 12:52 PM
      3 responses
      23 views
      0 likes
      Last Post NinjaTrader_Gaby  
      Started by helpwanted, Today, 03:06 AM
      1 response
      19 views
      0 likes
      Last Post sarafuenonly123  
      Started by Brevo, Today, 01:45 AM
      0 responses
      11 views
      0 likes
      Last Post Brevo
      by Brevo
       
      Started by pvincent, 06-23-2022, 12:53 PM
      14 responses
      244 views
      0 likes
      Last Post Nyman
      by Nyman
       
      Started by TraderG23, 12-08-2023, 07:56 AM
      9 responses
      388 views
      1 like
      Last Post Gavini
      by Gavini
       
      Working...
      X