|
Attention! Read the forum rules carefully before posting a topic.
Try to find an answer in Wiki before asking a question. Submit programming questions in this forum only. Off topics are strictly forbidden.
Any topics which do not satisfy these rules will be deleted.
Capturing Multi Time Frame indicators |
[SquareRoot]
|
Post subject: Capturing Multi Time Frame indicators |
Post rating: 0
|
Posted: Fri 14 Jan, 2011, 01:51
|
|
User rating: 0
Joined: Tue 15 Sep, 2009, 00:44 Posts: 20
|
I'm not sure how to properly capture indicator values from the onBar event. I am receiving "thread queue overloaded with tasks" error msgs and am wondering if this could be the problem.
Is the following code sequence correct? or do the lower timeframes come first ... Should I remove the return statements in each "if" structure?
public void onBar(Instrument instrument, Period period, IBar askBar, IBar bidBar) throws JFException { if (instrument != currentInstrument) return; if (period == Period.ONE_HOUR) { ema60 = indicators.ma(instrument,Period.ONE_HOUR,OfferSide.BID,IIndicators.AppliedPrice.CLOSE, 50,IIndicators.MaType.EMA,1); return; //remove this? }
if (period == Period.THIRTY_MINS) { ema30 = indicators.ma(instrument,Period.THIRTY_MINS,OfferSide.BID,IIndicators.AppliedPrice.CLOSE, 50,IIndicators.MaType.EMA,1); return; //remove this? }
if (period == Period.FIFTEEN_MINS) { ema15 = indicators.ma(instrument,Period.FIFTEEN_MINS,OfferSide.BID,IIndicators.AppliedPrice.CLOSE, 50,IIndicators.MaType.EMA,1); return; //remove this? } if (period != Period.FIVE_MINS) return;
.... other code below
|
|
|
|
 |
[SunSun]
|
Post subject: Re: Capturing Multi Time Frame indicators |
Post rating: 0
|
Posted: Tue 18 Jan, 2011, 22:52
|
|
User rating: 0
Joined: Thu 02 Dec, 2010, 16:55 Posts: 15
|
I learned java years ago and I'm sure things have changed. But java didn't have operator overloading when I used it... so when comparing primitives, you would use == but when comparing objects you'd use the equals() method of the object.
So in my code, I write:
if( period.equals(Period.ONE_HOUR) ){ // DO SOMETHING }
if( period.equals(Period.TEN_MINS) ){ // DO SOMETHING }
if( !period.equals(Period.FIVE_MINS) ) return;
The return statements are fine if that is all you want to do on that time period. It doesn't make much sense about your error message, but I'm not quite sure if the == compiles the same as the equals() method.
|
|
|
|
 |
API Support
|
Post subject: Re: Capturing Multi Time Frame indicators |
Post rating: 0
|
Posted: Wed 19 Jan, 2011, 09:16
|
|
User rating: ∞
Joined: Fri 31 Aug, 2007, 09:17 Posts: 6139
|
Hi, Try to compare a Period object using the equals() method and if problem persist please reply full error message from the Messages tab.
|
|
|
|
 |
|
Pages: [
1
]
|
|
|
|
|