NexusFi: Find Your Edge


Home Menu

 





OnBarUpdate not called for indicator within Stragety


Discussion in NinjaTrader

Updated
    1. trending_up 2,444 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?
Probability Collapse: Bitcoin $150k Craters from 15% to …
Prediction Markets & Event Contracts
March Jobs Report Update: 178K Beat vs 59K Expected, Wag …
Traders Hideout
Oil Surges ~18% in One Week as Iran Conflict Disrupts Gl …
Commodities
Five Days Until the Gap Dies -- CME Goes 24/7 on All Dig …
Traders Hideout
UCL Final Kicks Off at Noon ET: PSG at 56.5% as Iran May …
Prediction Markets & Event Contracts
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Sober Journey With S&P
24 thanks
2026 Jlab journal
10 thanks
Lady Vols Primer: Trading Volatility Journal
7 thanks
Algo automated / semi-automated trading anyone?
6 thanks
Trying to learn Volume and price action correlation
5 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