Dukascopy
 
 
Wiki JStore Search Login

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.

Problem with history.getBar and indicator.fractal
 Post subject: Problem with history.getBar and indicator.fractal Post rating: 0   New post Posted: Fri 17 Feb, 2012, 12:26 

User rating: 3
Joined: Thu 28 Jul, 2011, 19:40
Posts: 72
Location: PolandPoland
I have a strange problem. Sometimes happens to me a mistake and crashes strategy.
I'm getting this error in java console:

Quote:
16.02.2012 14:51:35.672 SEVERE a.c ] Uncaught exception in [Thread-376] thread: -1
java.lang.ArrayIndexOutOfBoundsException: -1
at com.dukascopy.dds2.greed.agent.strategy.tester.r.a(Unknown Source)
at com.dukascopy.dds2.greed.agent.strategy.tester.ai.getBars(Unknown Source)
at com.dukascopy.dds2.greed.agent.strategy.tester.ai.getBars(Unknown Source)
at com.dukascopy.api.impl.h.a(Unknown Source)
at com.dukascopy.api.impl.h.getBar(Unknown Source)
at jforex.TriangleV10Rel02.FindFirstFractalFrom(TriangleV10Rel02.java:1145)
at jforex.TriangleV10Rel02.GetFractalsAndCheckValidity(TriangleV10Rel02.java:808)
at jforex.TriangleV10Rel02$onBarThread.run(TriangleV10Rel02.java:284)
at java.lang.Thread.run(Unknown Source)
16.02.2012 14:51:36.172 SEVERE actions.c ] -1
java.lang.ArrayIndexOutOfBoundsException: -1
at com.dukascopy.dds2.greed.agent.strategy.tester.r.a(Unknown Source)
at com.dukascopy.dds2.greed.agent.strategy.tester.r.aq(Unknown Source)
at com.dukascopy.dds2.greed.agent.strategy.tester.r.run(Unknown Source)
at com.dukascopy.dds2.greed.agent.strategy.tester.b.Bb(Unknown Source)
at com.dukascopy.dds2.greed.actions.StrategyTesterAction.yV(Unknown Source)
at com.dukascopy.dds2.greed.actions.StrategyTesterAction.yu(Unknown Source)
at com.dukascopy.dds2.greed.actions.c.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)


or

Quote:
16.02.2012 14:58:28.031 SEVERE a.c ] Uncaught exception in [Thread-1072] thread: -1
java.lang.ArrayIndexOutOfBoundsException: -1
at com.dukascopy.dds2.greed.agent.strategy.tester.r.a(Unknown Source)
at com.dukascopy.dds2.greed.agent.strategy.tester.as.calculateIndicator(Unknown Source)
at com.dukascopy.api.impl.bu.fractal(Unknown Source)
at jforex.TriangleV10Rel02.FindFirstFractalFrom(TriangleV10Rel02.java:1067)
at jforex.TriangleV10Rel02.GetFractalsAndCheckValidity(TriangleV10Rel02.java:808)
at jforex.TriangleV10Rel02$onBarThread.run(TriangleV10Rel02.java:284)
at java.lang.Thread.run(Unknown Source)


Where in line 1145 I have a code:
bartmp=history.getBar(instrument, period, OfferSide.BID, i+RightStrength+j);

and i>=0, RightStrength>=0 and j>=0

In line 1067 I have code:
double[] fractalPrice = indicators.fractal(instrument, period, OfferSide.ASK, fs, i);

and i>0, fs >1

In general, everything works fine. Sometimes it crashes.
It may be important that it uses multithreading. And this function can be called many times in different threads that may be intertwined.
I wonder why I get an exception: java.lang.ArrayIndexOutOfBoundsException: -1
if I do not refer to the table in this case.

Please help


 
 Post subject: Re: Problem with history.getBar and indicator.fractal Post rating: 0   New post Posted: Mon 20 Feb, 2012, 09:53 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
From the given snippets it is not possible to detect where the problem is. Consider adding exception handling and on such ArrayIndexOutOfBoundsException, besides printing exception message, also print the parameters that you pass to the methods.


 
 Post subject: Re: Problem with history.getBar and indicator.fractal Post rating: 0   New post Posted: Mon 20 Feb, 2012, 15:56 

User rating: 3
Joined: Thu 28 Jul, 2011, 19:40
Posts: 72
Location: PolandPoland
Thank you. I do this, and now I receive exceptions in java console without refer to my strategy code and strategy crash also.

It seems that this is caused by producing a large number of threads running at the same time and have a lot to count. Is this error can be caused by an overload of threads?
Error appears during historical tester on speed 8x (sometime 7x).

Below is the complete Java console output:

Quote:
Java Web Start 1.6.0_23
Using JRE version 1.6.0_23-b05 Java HotSpot(TM) Client VM
User home directory = C:\Documents and Settings\RobertB
----------------------------------------------------
c: clear console window
f: finalize objects on finalization queue
g: garbage collect
h: display this help message
m: print memory usage
o: trigger logging
p: reload proxy configuration
q: hide console
r: reload policy configuration
s: dump system and deployment properties
t: dump thread list
v: dump thread stack
0-5: set trace level to <n>
----------------------------------------------------
20.02.2012 14:52:22.750 WARNING l10n.LocalizationManager ] Can't find resource for bundle com.dukascopy.dds2.greed.gui.l10n.a.a, key Variable
20.02.2012 14:52:22.765 WARNING l10n.LocalizationManager ] Can't find resource for bundle com.dukascopy.dds2.greed.gui.l10n.a.a, key Value
20.02.2012 14:52:22.843 WARNING l10n.LocalizationManager ] Can't find resource for bundle com.dukascopy.dds2.greed.gui.l10n.a.a, key Set
20.02.2012 14:52:22.843 WARNING l10n.LocalizationManager ] Can't find resource for bundle com.dukascopy.dds2.greed.gui.l10n.a.a, key Cancel
20.02.2012 14:52:48.421 WARNING l10n.LocalizationManager ] Can't find resource for bundle com.dukascopy.dds2.greed.gui.l10n.a.a, key Variable
20.02.2012 14:52:48.421 WARNING l10n.LocalizationManager ] Can't find resource for bundle com.dukascopy.dds2.greed.gui.l10n.a.a, key Value
20.02.2012 14:52:48.515 WARNING l10n.LocalizationManager ] Can't find resource for bundle com.dukascopy.dds2.greed.gui.l10n.a.a, key Set
20.02.2012 14:52:48.515 WARNING l10n.LocalizationManager ] Can't find resource for bundle com.dukascopy.dds2.greed.gui.l10n.a.a, key Cancel
20.02.2012 14:53:33.859 SEVERE a.c ] Uncaught exception in [AWT-EventQueue-0] thread: null
java.lang.NullPointerException
at org.fife.rsta.ac.java.rjc.parser.ASTFactory.printTypeDeclaration(ASTFactory.java:933)
at org.fife.rsta.ac.java.rjc.parser.ASTFactory.printTypeDeclaration(ASTFactory.java:951)
at org.fife.rsta.ac.java.rjc.parser.ASTFactory.printDebug(ASTFactory.java:896)
at org.fife.rsta.ac.java.rjc.parser.ASTFactory.getCompilationUnit(ASTFactory.java:885)
at org.fife.rsta.ac.java.JavaParser.parse(JavaParser.java:142)
at org.fife.ui.rsyntaxtextarea.ParserManager.actionPerformed(ParserManager.java:154)
at javax.swing.Timer.fireActionPerformed(Unknown Source)
at javax.swing.Timer$DoPostEvent.run(Unknown Source)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
20.02.2012 15:03:35.437 SEVERE actions.c ] -1
java.lang.ArrayIndexOutOfBoundsException: -1
at com.dukascopy.dds2.greed.agent.strategy.tester.r.a(Unknown Source)
at com.dukascopy.dds2.greed.agent.strategy.tester.r.run(Unknown Source)
at com.dukascopy.dds2.greed.agent.strategy.tester.b.Bc(Unknown Source)
at com.dukascopy.dds2.greed.actions.StrategyTesterAction.yX(Unknown Source)
at com.dukascopy.dds2.greed.actions.StrategyTesterAction.yw(Unknown Source)
at com.dukascopy.dds2.greed.actions.c.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
20.02.2012 15:07:09.437 SEVERE actions.c ] -1
java.lang.ArrayIndexOutOfBoundsException: -1
at com.dukascopy.dds2.greed.agent.strategy.tester.r.a(Unknown Source)
at com.dukascopy.dds2.greed.agent.strategy.tester.r.run(Unknown Source)
at com.dukascopy.dds2.greed.agent.strategy.tester.b.Bc(Unknown Source)
at com.dukascopy.dds2.greed.actions.StrategyTesterAction.yX(Unknown Source)
at com.dukascopy.dds2.greed.actions.StrategyTesterAction.yw(Unknown Source)
at com.dukascopy.dds2.greed.actions.c.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)


 
 Post subject: Re: Problem with history.getBar and indicator.fractal Post rating: 0   New post Posted: Tue 21 Feb, 2012, 13:35 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Could you please provide a sample strategy which causes such behavior?


 

Jump to:  

  © 1998-2025 Dukascopy® Bank SA
On-line Currency forex trading with Swiss Forex Broker - ECN Forex Brokerage,
Managed Forex Accounts, introducing forex brokers, Currency Forex Data Feed and News
Currency Forex Trading Platform provided on-line by Dukascopy.com