|
I can't create new strategy |
Peggy37
|
Post subject: I can't create new strategy |
Post rating: 0
|
Posted: Mon 22 Feb, 2016, 17:12
|
|
User rating: 0
Joined: Fri 04 Sep, 2015, 19:44 Posts: 34 Location: Slovakia, KE
|
Hi
Why i can't create a new strategy ? I want to write a code to it and it runs only in view mode.
Please help !
|
|
|
|
|
Peggy37
|
Post subject: Re: I can't create new strategy |
Post rating: 0
|
Posted: Sun 28 Feb, 2016, 21:34
|
|
User rating: 0
Joined: Fri 04 Sep, 2015, 19:44 Posts: 34 Location: Slovakia, KE
|
Al dcdemo helped, thanks Al dcdemo.
|
|
|
|
|
al_dcdemo
|
Post subject: Re: I can't create new strategy |
Post rating: 0
|
Posted: Tue 01 Mar, 2016, 10:22
|
|
User rating: 3
Joined: Wed 18 Sep, 2013, 23:40 Posts: 13 Location: SloveniaSlovenia
|
This was answered in Q&A, pasting it here just for convenience. al_dcdemo wrote: Strategy Contest platform is designed specifically for monitoring strategies during the contest in "View Mode".
Please use regular, non-contest JForex platform to develop and backtest your strategies.
|
|
|
|
|
vadim_berezhnoj
|
Post subject: Re: I can't create new strategy |
Post rating: 0
|
Posted: Tue 30 Aug, 2016, 14:46
|
|
Visual JForex expert at Dukascopy | |
User rating: ∞
Joined: Mon 22 Apr, 2013, 11:30 Posts: 604 Location: UkraineUkraine
|
Hello.
Please specify the error message when you can not upload the strategy.
|
|
|
|
|
Peggy37
|
Post subject: Re: I can't create new strategy |
Post rating: 0
|
Posted: Fri 02 Sep, 2016, 22:02
|
|
User rating: 0
Joined: Fri 04 Sep, 2015, 19:44 Posts: 34 Location: Slovakia, KE
|
it does not provide error messages.
only selling works, when comes on buying it stops.
Please help.
|
|
|
|
|
vadim_berezhnoj
|
Post subject: Re: I can't create new strategy |
Post rating: 0
|
Posted: Wed 07 Sep, 2016, 17:00
|
|
Visual JForex expert at Dukascopy | |
User rating: ∞
Joined: Mon 22 Apr, 2013, 11:30 Posts: 604 Location: UkraineUkraine
|
Hello.
To see the error log open Strategy Logs. Open your contest account in JForex platform -> Profile -> Strategy Log.
|
|
|
|
|
Peggy37
|
Post subject: Re: I can't create new strategy |
Post rating: 0
|
Posted: Sun 11 Sep, 2016, 20:12
|
|
User rating: 0
Joined: Fri 04 Sep, 2015, 19:44 Posts: 34 Location: Slovakia, KE
|
Sorry I can't upload files.
I found, that buying does not work.
Last Update : 11.09.2016 18:52:02 Level Date Message ERROR 09.09.2016 15:15:57 at java.lang.Thread.run(Thread.java:745) ERROR 09.09.2016 15:15:57 at com.dukascopy.api.impl.execution.ScienceThreadPoolExecutor$Worker.runTask(ScienceThreadPoolExecutor.java:904) ERROR 09.09.2016 15:15:57 at java.util.concurrent.FutureTask.run(FutureTask.java:266) ERROR 09.09.2016 15:15:57 at com.dukascopy.api.impl.execution.TaskCustom.call(TaskCustom.java:34) ERROR 09.09.2016 15:15:57 at com.dukascopy.api.impl.connect.JForexTaskManager$StopCallable.call(JForexTaskManager.java:1249) ERROR 09.09.2016 15:15:57 at com.dukascopy.api.impl.connect.JFRunnableProcessor.onStop(JFRunnableProcessor.java:149) ERROR 09.09.2016 15:15:57 at com.dukascopy.api.impl.execution.TaskStop.call(TaskStop.java:29) ERROR 09.09.2016 15:15:57 at jforex.Lenka_v_0.onStop(Lenka_v_0.java:69) ERROR 09.09.2016 15:15:57 java.lang.NullPointerException @ jforex.Lenka_v_0.onStop(Lenka_v_0.java:69)
|
|
|
|
|
vadim_berezhnoj
|
Post subject: Re: I can't create new strategy |
Post rating: 0
|
Posted: Wed 14 Sep, 2016, 11:13
|
|
Visual JForex expert at Dukascopy | |
User rating: ∞
Joined: Mon 22 Apr, 2013, 11:30 Posts: 604 Location: UkraineUkraine
|
Please test your strategies on demo real time run, before starting it on Contest.
Your strategy is locking in the dead-cycle after order sended and keeps spamming message: Order closed either from outside the strategy. Stopping the strategy.
public void onMessage(IMessage message) throws JFException { if (message.getReasons().contains(IMessage.Reason.ORDER_CLOSED_BY_TP)) { engine.submitOrder("order", Instrument.USDCAD, order.getOrderCommand(), 13); } else if (message.getReasons().contains(IMessage.Reason.ORDER_CLOSED_BY_SL)) { engine.submitOrder("order2",Instrument.USDCAD, order.isLong() ? OrderCommand.SELL : OrderCommand.BUY, 7); } else { console.getOut().println("Order closed either from outside the strategy. Stopping the strategy."); } }
|
|
|
|
|
Peggy37
|
Post subject: Re: I can't create new strategy |
Post rating: 0
|
Posted: Mon 19 Sep, 2016, 18:41
|
|
User rating: 0
Joined: Fri 04 Sep, 2015, 19:44 Posts: 34 Location: Slovakia, KE
|
Tested on demo and works GOOD !! I don't know why my strategy does not know buying. package jforex;
import com.dukascopy.api.*; import com.dukascopy.api.IEngine.OrderCommand; import com.dukascopy.api.IOrder.State; import com.dukascopy.api.IMessage.Type; import com.dukascopy.api.IAccount; import com.dukascopy.api.IBar; import com.dukascopy.api.IConsole; import com.dukascopy.api.IContext; import com.dukascopy.api.IMessage; import com.dukascopy.api.IStrategy; import com.dukascopy.api.ITick; import com.dukascopy.api.Instrument; import com.dukascopy.api.JFException; import com.dukascopy.api.Period; import com.dukascopy.api.OfferSide;
import java.util.Set; import java.util.HashSet; import java.util.Calendar; import java.util.TimeZone; import java.util.*; import java.text.*; import java.util.*;
/* * Simple bar scalping strategy. Pair: USD/CAD, take profit:12, stop loss 7, amount 1 mio, If green bar, buys, if red bar, sells. Period: one hour. * v_06 test */ public class Lenka_v_0 implements IStrategy {
private IAccount account; private IEngine engine; private IHistory history; private IConsole console; private IContext context; private IOrder order; // private IBar previosBar; @Override public void onStart(IContext context) throws JFException { this.engine = context.getEngine(); this.history = context.getHistory(); this.console = context.getConsole(); this.context = context; //subscribe an instrument: Set instruments = new HashSet(); instruments.add(Instrument.USDCAD); context.setSubscribedInstruments(instruments, true); // init. order = buy. IBar initBar = history.getBar(Instrument.USDCAD, Period.ONE_HOUR, OfferSide.ASK, 1); OrderCommand makeOrder = initBar.getClose()>initBar.getOpen() ? OrderCommand.BUY : OrderCommand.SELL; engine.submitOrder("initorder", Instrument.USDCAD, OrderCommand.BUY, 1,0,1, history.getLastTick(Instrument.USDCAD).getBid() - 13 * Instrument.USDCAD.getPipValue(), history.getLastTick(Instrument.USDCAD).getBid() + 7 * Instrument.USDCAD.getPipValue()); order.waitForUpdate(3000, IOrder.State.FILLED); } public void onAccount(IAccount account) throws JFException { // this.account = account;
}
public void onMessage(IMessage message) throws JFException { if (message.getReasons().contains(IMessage.Reason.ORDER_CLOSED_BY_TP)) { // on close by TP we keep the order direction engine.submitOrder("initorder", Instrument.USDCAD, OrderCommand.BUY, 1,0,1, history.getLastTick(Instrument.USDCAD).getBid() - 13 * Instrument.USDCAD.getPipValue(), history.getLastTick(Instrument.USDCAD).getBid() + 7 * Instrument.USDCAD.getPipValue()); order.waitForUpdate(3000, IOrder.State.FILLED);
} else { // "Order closed by SL". --> SELL. OrderCommand orderCmd = order.isLong() ? OrderCommand.SELL : OrderCommand.BUY; engine.submitOrder("redbar", Instrument.USDCAD, OrderCommand.SELL, 1, 0, 1, history.getLastTick(Instrument.USDCAD).getAsk() + 7 * Instrument.USDCAD.getPipValue(), history.getLastTick(Instrument.USDCAD).getAsk() - 13 * Instrument.USDCAD.getPipValue()); order.waitForUpdate(3000, IOrder.State.FILLED); } } public void onStop() throws JFException { // if(order.getState() == IOrder.State.FILLED || order.getState() == IOrder.State.OPENED){ // order.close(); // context.stop(); // } }
public void onTick(Instrument instrument, ITick tick) throws JFException { } @Override public void onBar(Instrument instrument, Period period, IBar askBar, IBar bidBar) throws JFException { if(engine.getOrders().size()==0 && instrument.equals("USDCAD") && period.equals("ONE_HOUR")) { if(((history.getBar(Instrument.USDCAD, Period.ONE_HOUR, OfferSide.BID, 1).getClose()))>history.getBar(Instrument.USDCAD, Period.ONE_HOUR, OfferSide.BID, 1).getOpen()) { engine.submitOrder("greenbar", Instrument.USDCAD, OrderCommand.BUY, 1,0,1, history.getLastTick(Instrument.USDCAD).getBid() - 13 * Instrument.USDCAD.getPipValue(), history.getLastTick(Instrument.USDCAD).getBid() + 7 * Instrument.USDCAD.getPipValue()); order.waitForUpdate(3000, IOrder.State.FILLED); } else { engine.submitOrder("redbar", Instrument.USDCAD, OrderCommand.SELL, 1, 0, 1, history.getLastTick(Instrument.USDCAD).getAsk() + 7 * Instrument.USDCAD.getPipValue(), history.getLastTick(Instrument.USDCAD).getAsk() - 13 * Instrument.USDCAD.getPipValue()); order.waitForUpdate(3000, IOrder.State.FILLED); } } else { ; } } }
Please check.
|
|
|
|
|
vadim_berezhnoj
|
Post subject: Re: I can't create new strategy |
Post rating: 0
|
Posted: Tue 20 Sep, 2016, 14:41
|
|
Visual JForex expert at Dukascopy | |
User rating: ∞
Joined: Mon 22 Apr, 2013, 11:30 Posts: 604 Location: UkraineUkraine
|
Your currently running strategy contains that code: public void onMessage(IMessage message) throws JFException { if (message.getReasons().contains(IMessage.Reason.ORDER_CLOSED_BY_TP)) { engine.submitOrder("order", Instrument.USDCAD, order.getOrderCommand(), 13); } else if (message.getReasons().contains(IMessage.Reason.ORDER_CLOSED_BY_SL)) { engine.submitOrder("order2",Instrument.USDCAD, order.isLong() ? OrderCommand.SELL : OrderCommand.BUY, 7); } else { console.getOut().println("Order closed either from outside the strategy. Stopping the strategy."); } } So if it reads message that does not include "ORDER_CLOSED_BY_TP" or "ORDER_CLOSED_BY_SL" it wrights the message "Order closed either from outside the strategy. Stopping the strategy." Then it reads the previous message and sends it again and again and again... enles cycle... then NPO. If it trades on regular Demo account it acts the same.
|
|
|
|
|
Peggy37
|
Post subject: Re: I can't create new strategy |
Post rating: 0
|
Posted: Tue 20 Sep, 2016, 16:51
|
|
User rating: 0
Joined: Fri 04 Sep, 2015, 19:44 Posts: 34 Location: Slovakia, KE
|
Thank you much .
That looks like the strategy still executing old version ?? It didn't take new - actual version ?? I completed, onBbar, initiall order... On stop has to be empty ??( i don't understand this strategy "loop".)
How to change it to new version ?
|
|
|
|
|
vadim_berezhnoj
|
Post subject: Re: I can't create new strategy |
Post rating: 0
|
Posted: Mon 26 Sep, 2016, 13:48
|
|
Visual JForex expert at Dukascopy | |
User rating: ∞
Joined: Mon 22 Apr, 2013, 11:30 Posts: 604 Location: UkraineUkraine
|
vadim_berezhnoj wrote: How to change it to new version ? You can upload new version of the strategy from your Contest Profile. Only one version update per month is allowed. vadim_berezhnoj wrote: On stop has to be empty ? It is not limited by the Rules. vadim_berezhnoj wrote: i don't understand this strategy "loop" You can google by "Infinite loop".
|
|
|
|
|
Peggy37
|
Post subject: Re: I can't create new strategy |
Post rating: 0
|
Posted: Mon 26 Sep, 2016, 20:59
|
|
User rating: 0
Joined: Fri 04 Sep, 2015, 19:44 Posts: 34 Location: Slovakia, KE
|
Thanks, so its not working properly, because of oldest version.
I understand the (main() function an user defined functions) loop, but not the "jforex strategy" loop - (1order, then close, then open next order and so on.... ) - how jforex "reads" it and how to do it. - example: if(myOrder.getPipValue()=takeprofit) { ... *submit_Order...
|
|
|
|
|
vadim_berezhnoj
|
Post subject: Re: I can't create new strategy |
Post rating: 0
|
Posted: Tue 27 Sep, 2016, 15:31
|
|
Visual JForex expert at Dukascopy | |
User rating: ∞
Joined: Mon 22 Apr, 2013, 11:30 Posts: 604 Location: UkraineUkraine
|
|
|
|
|
Peggy37
|
Post subject: Re: I can't create new strategy |
Post rating: 0
|
Posted: Thu 29 Sep, 2016, 23:15
|
|
User rating: 0
Joined: Fri 04 Sep, 2015, 19:44 Posts: 34 Location: Slovakia, KE
|
vadim_berezhnoj wrote: https://en.wikipedia.org/wiki/Infinite_loop Sorry ? And in jforex? Im trying with "drawing" a sreategy in Visual j forex - i think it has "looping" but im not sure .
|
|
|
|
|
vadim_berezhnoj
|
Post subject: Re: I can't create new strategy |
Post rating: 0
|
Posted: Fri 30 Sep, 2016, 16:12
|
|
Visual JForex expert at Dukascopy | |
User rating: ∞
Joined: Mon 22 Apr, 2013, 11:30 Posts: 604 Location: UkraineUkraine
|
There is Infinite-loop in your strategy code. As it was explained earlier, it is locking in the loop after order sent and it keeps spamming message: "Order closed either from outside the strategy. Stopping the strategy." That triggers the condition to send the same message again and again. That condition is in the following part:
public void onMessage(IMessage message) throws JFException {
if (message.getReasons().contains(IMessage.Reason.ORDER_CLOSED_BY_TP)) { engine.submitOrder("order", Instrument.USDCAD, order.getOrderCommand(), 13); } else if (message.getReasons().contains(IMessage.Reason.ORDER_CLOSED_BY_SL)) {
engine.submitOrder("order2",Instrument.USDCAD, order.isLong() ? OrderCommand.SELL : OrderCommand.BUY, 7); } else { console.getOut().println("Order closed either from outside the strategy. Stopping the strategy.");
} }
|
|
|
|
|
|
Pages: [
1
]
|
|
|
|
|