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.

Create Order with button click
 Post subject: Create Order with button click Post rating: 0   New post Posted: Tue 16 Sep, 2014, 01:35 

User rating: 0
Joined: Tue 16 Sep, 2014, 01:25
Posts: 1
Hey,

I created an JFrame GUI for my Strategy and want to create an Order when I press a button. But for some reason the order creation wont work when I put it into my ActionListener. My ActionListener works fine and the Order creation also works when i put it somewhere else, as for example directly into my onStart method. I only get problems when I put the Order creation into my Action Listener. The program will start but when I press the button I get this error message:

com.dukascopy.api.JFException: Incorrect thread
   at com.dukascopy.api.impl.connect.validation.OrderValidator.validateOrderParameters(OrderValidator.java:115)
   at com.dukascopy.api.impl.connect.JForexEngineImpl.submitOrder(JForexEngineImpl.java:116)
   at com.dukascopy.api.impl.connect.JForexEngineImpl.submitOrder(JForexEngineImpl.java:262)
   at com.dukascopy.api.impl.connect.JForexEngineImpl.submitOrder(JForexEngineImpl.java:267)
   at com.dukascopy.api.impl.connect.JForexEngineImpl.submitOrder(JForexEngineImpl.java:272)
   at com.dukascopy.api.impl.connect.JForexEngineImpl.submitOrder(JForexEngineImpl.java:282)
   at com.dukascopy.api.impl.connect.JForexEngineImpl.submitOrder(JForexEngineImpl.java:287)
   at singlejartest.Strategy$MeinHandler.actionPerformed(Strategy.java:70)
   at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
   at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
   at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
   at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
   at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
   at java.awt.Component.processMouseEvent(Unknown Source)
   at javax.swing.JComponent.processMouseEvent(Unknown Source)
   at java.awt.Component.processEvent(Unknown Source)
   at java.awt.Container.processEvent(Unknown Source)
   at java.awt.Component.dispatchEventImpl(Unknown Source)
   at java.awt.Container.dispatchEventImpl(Unknown Source)
   at java.awt.Component.dispatchEvent(Unknown Source)
   at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
   at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
   at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
   at java.awt.Container.dispatchEventImpl(Unknown Source)
   at java.awt.Window.dispatchEventImpl(Unknown Source)
   at java.awt.Component.dispatchEvent(Unknown Source)
   at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
   at java.awt.EventQueue.access$400(Unknown Source)
   at java.awt.EventQueue$3.run(Unknown Source)
   at java.awt.EventQueue$3.run(Unknown Source)
   at java.security.AccessController.doPrivileged(Native Method)
   at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
   at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
   at java.awt.EventQueue$4.run(Unknown Source)
   at java.awt.EventQueue$4.run(Unknown Source)
   at java.security.AccessController.doPrivileged(Native Method)
   at java.security.ProtectionDomain$1.doIntersectionPrivilege(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)


Here is my ActionListener:

   private class MeinHandler implements ActionListener{

      @Override
      public void actionPerformed(ActionEvent event){
         if(event.getSource()==buybtn)
         {
            try {
               order = engine.submitOrder("Order" + System.currentTimeMillis(), Instrument.EURUSD, OrderCommand.BUY, 0.001);
            } catch (Exception e) {
               e.printStackTrace();
            }
         }
      }
   }


Can somebody tell me what the problem is and how to fix it?


 
 Post subject: Re: Create Order with button click Post rating: 0   New post Posted: Tue 16 Sep, 2014, 08:19 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
See:
https://www.dukascopy.com/wiki/#Threading


 

Jump to:  

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