|
帮改一下这个程序 |
beinong
|
Post subject: 帮改一下这个程序 |
Post rating: 0
|
Posted: Tue 30 Dec, 2014, 15:44
|
|
User rating: 0
Joined: Thu 18 Sep, 2014, 16:50 Posts: 6 Location: China, nanning
|
你好客服。我自己编了个小程序(如下),主要功能是想给每个单子设置30点的止损。该程序已经编译成功,但试运行的时候,我交易了几个单子,发现只有第一个单子被程序设置了止损,其他的都没有止损。我自己不知道哪个地方错了,麻烦帮改一下。我知道在jforex平台上可以设置让每笔交易在下单时自动止损的,但我这个小程序仅仅是个开始,往后还要增加其他功能的,所以麻烦帮改一下啊。先谢谢了。
package jforex.orders.sl; import com.dukascopy.api.*; import com.dukascopy.api.IEngine; import com.dukascopy.api.IOrder.State; public class MYSL implements IStrategy { private IEngine engine; private long lastTickTime=0; private Instrument selectedInstrument = Instrument.EURUSD;
public void onStart(IContext context) throws JFException { this.engine = context.getEngine(); } public void onAccount(IAccount account) throws JFException { } public void onMessage(IMessage message) throws JFException { } public void onStop() throws JFException { } public void onBar(Instrument instrument, Period period, IBar askBar, IBar bidBar) throws JFException { } public void onTick(Instrument instrument, ITick tick) throws JFException { if (engine.getOrders(selectedInstrument).isEmpty()||!instrument.equals(selectedInstrument)) return; for (IOrder Lastorder2 : engine.getOrders()){ if(Lastorder2.getState()==IOrder.State.FILLED&&tick.getTime()-lastTickTime>1000){ if(Lastorder2.isLong()){ Lastorder2.setStopLossPrice(Lastorder2.getOpenPrice()-0.003); Lastorder2.waitForUpdate(888); } else { Lastorder2.setStopLossPrice(Lastorder2.getOpenPrice()+0.003); Lastorder2.waitForUpdate(888); } } lastTickTime = tick.getTime(); } } }
|
|
|
|
|
MarkLi
|
Post subject: Re: 帮改一下这个程序 |
Post rating: 0
|
Posted: Wed 07 Jan, 2015, 14:25
|
|
Visual JForex expert at Dukascopy | |
User rating: 1
Joined: Thu 29 Aug, 2013, 13:07 Posts: 88 Location: Ukraine, Kiev
|
您好,
您需要把这个问题写成英文然后发到我们的策略交易论坛:https://www.dukascopy.com/swiss/english/forex/jforex/forum/viewforum.php?f=65。
|
|
|
|
|
zzping115
|
Post subject: Re: 帮改一下这个程序 |
Post rating: 0
|
Posted: Fri 13 Mar, 2015, 13:58
|
|
User rating: 0
Joined: Wed 28 Mar, 2012, 06:41 Posts: 25 Location: China, Beijing
|
|
|
|
|
|
Pages: [
1
]
|
|
|
|
|