PDA

View Full Version : Method interrupt


snaphook
12-03-2008, 01:38 PM
If OnBarUpdate() calls a method and that method subsequently calls a 3rd method, will OnBarUpdate() interrupt/preempt the completion of either of those methods on any new tick?, Or if a new tick comes in that will trigger a call to the first method, such as setting a new bar high or low.

OnBarUpdate() calls NewHighLow() if a tick creates a new or equals the old bar High or Low. NewHighLow() performs the calculations and calls DrawPatterns() as the last statement. I have been having problems with patterns not being displayed or removed when no longer valid. Hitting F5, however, makes everything look as it should.

Snap

NinjaTrader_Josh
12-03-2008, 01:48 PM
No "interruption" occurs. When you are in your strategy's OnBarUpdate() it takes whatever is the latest processed tick from your indicator. This may be the same tick the strategy is processing now or it can even be the previous tick. There is no guarantee of the order because of the multi-threaded nature of these processes.

snaphook
12-03-2008, 07:50 PM
That's what I thought, si I guess I'll have to dig a little deeper.

snaphook
12-03-2008, 08:10 PM
On rereading your message, I noticed you said, "When you are in your strategy's OnBarUpdate() it takes whatever is the latest processed tick from your indicator."

This situation occurs in the indicator, not the strategy. Does that make any difference?

NinjaTrader_Bertrand
12-04-2008, 05:22 AM
Hi snaphook,

I am not 100% sure if it makes a difference, will check...

But you try forcing an update of your embedded indicator calculations -
http://www.ninjatrader-support.com/HelpGuideV6/Update.html

snaphook
12-05-2008, 07:12 AM
Any further thoughts on this subject. The problem cropped up again this morning during a furious gold rush. That is typically when the problem occurs, during fast markets making new bar highs and lows. The patterns appear and disappear (drawn and removed depending on validity of the signal) but on the next bar a refresh brings them out right where they should have been.

NinjaTrader_Josh
12-05-2008, 07:15 AM
snaphook,

Let us clarify, what is the exact scenario you have?

Strategy calling indicator? Calculation in indicator? Calculation in the strategy? Please be as specific as possible in outlining what you seeing and I will let you know if that is expected or not. Thank you.

snaphook
12-05-2008, 07:59 AM
First, let me say that you all are the best at customer service.

Precisely this deals with Woodies CCI and is in the pattern recognition indicator with no strategy involved. OnBarUpdate() simply looks for bar highs and lows. When a new high/low is made, or an existing one is met, a call is made to void NewHighLow() which performs the analysis/calculations and sets variables instantiated in the variables region to identify the pattern that has been detected. At the completion of this method control is returned to OnBarUpdate() which calls DrawPatterns() which checks the variables set in NewHighLow() and draws objects in the panel or removes them, depending on if a pattern was found or an old one is no longer valid.

If no high/low is reached, OnBarUpdate() calls DrawPatterns() w/o calling NewHighLow(). I doubt this is absolutely required, but it is there because of this problem.

The problem is that in fast markets, the patterns are drawn and removed by DrawPatterns() with rapidly changing prices and sometimes they will not be redrawn on a new high/low. Because this occurs in fast markets it is hard for me to see what is happening.

I used to have the whole thing in OnBarUpdate() and did not have this problem, but cpu load was very high.

I hope this gives you enough info. Thanks for any help you can provide,
Snap

NinjaTrader_Josh
12-05-2008, 08:10 AM
So you are doing this?
1. OnBarUpdate -> method1
2. method1 does calculations
3. method1 ->OnBarUpdate
4. OnBarUpdate -> method2

Otherwise
1. OnBarUpdate -> method2

Issue is you feel OnBarUpdate is going to method2 preemptively in the first scenario?

Unfortunately the only way to figure out what is happening here is to debug. Use print logs and slowly track out its behavior.