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.

DOM Ladder Interface order problems
 Post subject: DOM Ladder Interface order problems Post rating: 0   New post Posted: Mon 20 Jul, 2015, 14:27 
User avatar

User rating: 0
Joined: Sat 02 Mar, 2013, 09:43
Posts: 12
Location: Canada, Vancouver
So Im building a DOM ladder style interface for JForex and I have everything working perfectly data wise.
The ladder updates fast, and displays how I want.

Image

Now Im just trying to get the orders to fire off and am finding it extremely challenging.

I can fire an order from inside the onStart, onTick, onBar methods just fine.

But I have buttons, and JTables, that when I click, I want to fire certain methods.
I have all the methods wired up, and they are firing just fine.
However...when I put an IOrder submit order inside any of the methods, I just get unhandled exceptions. No explanations.

I made the IOrder and IContext public, thinking that it was because I didn't have access to them inside other methods.
But still no luck.

Any idea how to put the IOrder inside my own buyMarket(), or closeAll() methods?


Attachments:
LadderInterface-Dukascopy.jpg [187.07 KiB]
Downloaded 334 times
DISCLAIMER: Dukascopy Bank SA's waiver of responsability - Documents, data or information available on this webpage may be posted by third parties without Dukascopy Bank SA being obliged to make any control on their content. Anyone accessing this webpage and downloading or otherwise making use of any document, data or information found on this webpage shall do it on his/her own risks without any recourse against Dukascopy Bank SA in relation thereto or for any consequences arising to him/her or any third party from the use and/or reliance on any document, data or information found on this webpage.
 
 Post subject: Re: DOM Ladder Interface order problems Post rating: 0   New post Posted: Tue 21 Jul, 2015, 01:17 
User avatar

User rating: 70
Joined: Sat 22 Sep, 2012, 17:43
Posts: 118
Location: Brazil, Fortaleza, Ceará
You have an issue with multiple threads of execution.

Java Swing callbacks for your widgets (e.g. Buttons) are happening in a thread of execution completely separate to the thread responsible for issuing orders to the Server.

This second thread is the one you see making calls to onStart, onTick and onBar, etc.

If you insist on placing orders from your own widget callback methods you have the option to use mechanisms provided to publish order requests into this second thread via the the IContext instance.

Take a look at <this> for some guidance on the approach.


 
 Post subject: Re: DOM Ladder Interface order problems Post rating: 0   New post Posted: Tue 21 Jul, 2015, 03:04 
User avatar

User rating: 0
Joined: Sat 02 Mar, 2013, 09:43
Posts: 12
Location: Canada, Vancouver
Thanks, that helps quite a bit.
Im still very new to Java and am still learning
Coming from a javascript background, the strictness of Java is quite confusing at first.

Anyway...you said..

Quote:
If you insist on placing orders from your own widget callback methods ...


Were you implying that theres other/better ways to do it??

Also..should I be developing this as a standalone in Netbeans as a plugin, instead of building it inside of JForex as an IStrategy
Since it really isnt a strategy and more of a manual order entry widget.

Are there any plugin tutorials apart from the ones in the wiki??
I can't find much on how to implement a standalone widget


 
 Post subject: Re: DOM Ladder Interface order problems Post rating: 0   New post Posted: Tue 21 Jul, 2015, 05:01 
User avatar

User rating: 0
Joined: Sat 02 Mar, 2013, 09:43
Posts: 12
Location: Canada, Vancouver
So I tried implementing a new thread and I get this error...

2015-07-21 03:59:05 Syntax error on token "start", Identifier expected after this token
2015-07-21 03:59:05 ^^^^^
2015-07-21 03:59:05 thread.start();

My code is straight from your example link.

final IContext finalContext = context;
Thread thread = new Thread(new Runnable() {
@Override
public void run() {
try {
finalContext.executeTask(buyOrder);
} catch (Exception e) {
console.getErr().println(Thread.currentThread().getName() + " " + e);
}
}
});
thread.start();


 
 Post subject: Re: DOM Ladder Interface order problems Post rating: 0   New post Posted: Thu 30 Jul, 2015, 09:38 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
We could not reproduce the error. Please provide full code example.


 

Jump to:  

cron
  © 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