|
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.
Why "incorrect thread"? |
Guest
|
Post subject: Why "incorrect thread"? |
Post rating: 0
|
Posted: Tue 04 Aug, 2009, 09:40
|
|
User rating: -
|
Hi ,i use a new thread to process with some extra dynamic datas, but when i submit a new order in this thread ,there's an "incorrect thread" exception, why?
|
|
|
|
 |
API Support
|
Post subject: Re: why "incorrect thread"? |
Post rating: 0
|
Posted: Tue 18 Aug, 2009, 13:02
|
|
User rating: ∞
Joined: Fri 31 Aug, 2007, 09:17 Posts: 6139
|
Hello, JForex API was designed so that most of the methods (mostly orders manipulation) can be run only from strategy thread. Pretty much like Swing in java. To submit order from another thread you need to run task through the IContext.executeTask(Callable<T> callable) method
|
|
|
|
 |
AbsoluteReturner
|
Post subject: Re: why "incorrect thread"? |
Post rating: 0
|
Posted: Fri 13 Jan, 2012, 18:27
|
|
User rating: 1
Joined: Tue 12 Jul, 2011, 20:43 Posts: 51 Location: Germany,
|
Hello support,
I also have this problem.
My scalping strategy creates a bottom tab with an "open" and a "close" button with ActionListeners onStart. I want to open and close an order manually (only one order at the same time). Also the strategy creates an unlocked HorizontalLineChartObject on a TickBar chart onStart. With this line I can determine the StopLoss level manually per mouse in the chart. The advantage of using custom "open" and "close" buttons in conjunction with horizontal StopLoss line should be a fast trading with precise money management which is important for scalping. That is, the strategy calculates an exact trade amount (based on the distance between current price and horizontal line StopLoss level) before opening the trade. Also the trade direction (long or short) can be determined automatically - if I drag the StopLoss line below current bid price then the trade direction is long automatically, and if I move the StopLoss line above current ask price then the trade direction is short automatically.
Therefore I want to use custom buttons instead of standard JForex order functionality. But when I'm clicking on "open" button, only "Incorrect thread" is printed out on console.
I assume that I have not only two but three different threads: a main strategy thread, a thread when I'm clicking on "open" button and a thread when I'm clicking on "close" button. If there is a possibility to realise this strategy anyway - especially to open and close an order instantly by button click before next tick arrives - please describe a solution.
Thanks in advance and regards AbsoluteReturner
|
|
|
|
 |
API Support
|
Post subject: Re: why "incorrect thread"? |
Post rating: 0
|
Posted: Mon 16 Jan, 2012, 09:48
|
|
User rating: ∞
Joined: Fri 31 Aug, 2007, 09:17 Posts: 6139
|
AbsoluteReturner wrote: If there is a possibility to realise this strategy anyway - especially to open and close an order instantly by button click before next tick arrives - please describe a solution. If you ask about creating an order from a different thread than that of strategy, then in the current implementation it is forbidden, the closest that you can get is using a queue of order requests and process them in onTick. If your inquiry was about something else, please specify its details.
|
|
|
|
 |
AbsoluteReturner
|
Post subject: Re: why "incorrect thread"? |
Post rating: 0
|
Posted: Tue 17 Jan, 2012, 13:27
|
|
User rating: 1
Joined: Tue 12 Jul, 2011, 20:43 Posts: 51 Location: Germany,
|
Yes, my intention was to create an order from a different thread than strategy thread (inside a button click ActionListener). I also known about the workaround you suggested (register button click[s] in global / class variable[s] and execute appropriated task[s] inside next onTick event). But for a strategy which is created to support manual scalping this means at least one more tick slippage.
Therefore I want to ask again if and when it will possible in the future to avoid this workaround and manage orders inside different threads (open an order in one thread, and close the same order in another thread).
|
|
|
|
 |
API Support
|
Post subject: Re: JFOREX-3449 why "incorrect thread"? |
Post rating: 0
|
Posted: Tue 17 Jan, 2012, 13:57
|
|
User rating: ∞
Joined: Fri 31 Aug, 2007, 09:17 Posts: 6139
|
The issue is under investigation.
|
|
|
|
 |
AbsoluteReturner
|
Post subject: Why "incorrect thread"? |
Post rating: 0
|
Posted: Tue 17 Jan, 2012, 17:13
|
|
User rating: 1
Joined: Tue 12 Jul, 2011, 20:43 Posts: 51 Location: Germany,
|
Quote: The issue is under investigation.
Please consider also the possibility to manage one order over more than two threads. For example, having a strategy with a bottom tab containing several graphical objects: - one button to open a trade, or respectively one button for long and short trades (means creating a long / short order) - one button to cancel the trade (means closing the order before filled) - one button to close the order - one checkbox to add / delete a take profit to the order and so on ...
|
|
|
|
 |
API Support
|
Post subject: Re: Why "incorrect thread"? |
Post rating: 0
|
Posted: Mon 27 Feb, 2012, 10:48
|
|
User rating: ∞
Joined: Fri 31 Aug, 2007, 09:17 Posts: 6139
|
|
|
|
 |
|
Pages: [
1
]
|
|
|
|
|