NexusFi: Find Your Edge


Home Menu

 





OnBarUpdate not called for indicator within Stragety


Discussion in NinjaTrader

Updated
    1. trending_up 2,528 views
    2. thumb_up 0 thanks given
    3. group 2 followers
    1. forum 2 posts
    2. attach_file 0 attachments




 
Search this Thread
  #1 (permalink)
 corbeste 
Valencia/Spain
 
Experience: Intermediate
Platform: Investor/RT
Trading: FGBL, ES
Posts: 8 since Jun 2012
Thanks Given: 7
Thanks Received: 13

Hi,

I am playing with the priceactionswing indicator, and am running into a big problem - within my strategy, the PAS OnBarUpdate method is never called! I cant find anything relating to specific instructions on how to include an indicator within a strategy, so I simply created the indicator within the Initialise function of my strategy.

However the PAS OnBarUpdate is never called (verified with a print statement) and the structures within the object are never populated. Init and OnStartUp are called.

Is there an obvious step I am missing to link the embedded indicator to the data series of the strategy? I am an experienced programmer but very new to the NT universe, so I am not clear on how the OnBarUpdate event works and how to allow the indicator to subscribe to this event.

 
Code
 protected override void Initialize()
        {
            CalculateOnBarClose = true;
	    pas = PriceActionSwing(Input, _dtbStrength, _swingSize, SwingTypes.Standard);

        }
		
		protected override void OnStartUp()
		{
			
		}

        /// <summary>
        /// Called on each bar update event (incoming tick)
        /// </summary>
        protected override void OnBarUpdate()
        {
			Print (++_cnt);
                        // reference pas object contents


Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
More Than Capable: Hegseths War Warning Validates $114M …
Prediction Markets & Event Contracts
Pakistan Mediator in Tehran as Hormuz Normalization Coll …
Prediction Markets & Event Contracts
Memorandum Watch: How the 60-Day MOU Framework Makes May …
Prediction Markets & Event Contracts
Iran and Israel Stand Down: What $9M in Peace Contracts …
Prediction Markets & Event Contracts
CME Raises Energy Futures Margins After Iran-War Volatil …
Commodities
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
NexusFi site changelog and issues/problem reporting
15 thanks
Darmok and Jalad at Tanagra
3 thanks
Big Mike in Ecuador
1 thanks
30 Sessions
1 thanks
  #3 (permalink)
kandlekid
College Point, NY (Queens)
 
Posts: 63 since Nov 2009
Thanks Given: 5
Thanks Received: 20



corbeste View Post
Hi,

I am playing with the priceactionswing indicator, and am running into a big problem - within my strategy, the PAS OnBarUpdate method is never called! I cant find anything relating to specific instructions on how to include an indicator within a strategy, so I simply created the indicator within the Initialise function of my strategy.

However the PAS OnBarUpdate is never called (verified with a print statement) and the structures within the object are never populated. Init and OnStartUp are called.

Is there an obvious step I am missing to link the embedded indicator to the data series of the strategy? I am an experienced programmer but very new to the NT universe, so I am not clear on how the OnBarUpdate event works and how to allow the indicator to subscribe to this event.

 
Code
 protected override void Initialize()
        {
            CalculateOnBarClose = true;
	    pas = PriceActionSwing(Input, _dtbStrength, _swingSize, SwingTypes.Standard);

        }
		
		protected override void OnStartUp()
		{
			
		}

        /// <summary>
        /// Called on each bar update event (incoming tick)
        /// </summary>
        protected override void OnBarUpdate()
        {
			Print (++_cnt);
                        // reference pas object contents


I think your problem is that Initalize is only called once. You probably want to add the indicator to your plot using the Add method from Initialize then set pas from OnBarUpdate.

protected override void Initialize()
{
Add(PriceActionSwing( ...) );

}

protected override void OnBarUpdate()
{
pas = PriceActionSwing( ... );

...
}

Note: make sure that the arguments for the PriceActionSwing calls are precisely the same in both cases.


Reply With Quote




Last Updated on August 13, 2013


© 2026 NexusFi®, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Downloads - Top
no new posts