|
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.
| something wrong when calculate indicators in ONBAR method |
|
Danniel23261
|
| Post subject: something wrong when calculate indicators in ONBAR method |
Post rating: 0
|
Posted: Fri 28 Jun, 2013, 07:38
|
|
User rating: 0
Joined: Tue 28 May, 2013, 09:39 Posts: 9 Location: ChinaChina
|
|
Hi ,
I want to calculate indicators every day, so I put the code in ONBAR method. trouble is that the code is ok when it was ran in ONSTART method, but when in ONBAR method it feed back out of memory.
double[][] frac = indicators.fractal(instrument, period, side, barsOnSides, Filter.WEEKENDS,weeklyPrev.getTime(), currBar.getTime()); console.getOut().println(String.format("start3 at %s",sdf.format(history.getBar(instrument, period,side,0).getTime()))); double[] zigzagArray = indicators.zigzag(instrument, period, side, extDepth, extDeviation, extBackstep,Filter.WEEKENDS, weeklyPrev.getTime(), currBar.getTime() ); console.getOut().println(String.format("start3 at %s",sdf.format(history.getBar(instrument, period,side,0).getTime())));
when it is in ONSTART it can print two start, but when it is in ONBAR it only print start2 then system halted. Is there any limit in ONBAR?
these two array's length is about 200+.
Thank you advance
|
|
|
|
|
 |
|
API Support
|
| Post subject: Re: something wrong when calculate indicators in ONBAR method |
Post rating: 0
|
Posted: Fri 28 Jun, 2013, 07:41
|
|
User rating: ∞
Joined: Fri 31 Aug, 2007, 09:17 Posts: 6139
|
|
Please provide a full example strategy which replicates the case. Please describe how you launch the strategy.
|
|
|
|
|
 |
|
Danniel23261
|
| Post subject: Re: something wrong when calculate indicators in ONBAR method |
Post rating: 0
|
Posted: Fri 28 Jun, 2013, 07:58
|
|
User rating: 0
Joined: Tue 28 May, 2013, 09:39 Posts: 9 Location: ChinaChina
|
|
As following:
| Attachments: |
FracZZV.java [3.21 KiB]
Downloaded 395 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.
|
|
|
|
|
|
 |
|
API Support
|
| Post subject: Re: something wrong when calculate indicators in ONBAR method |
Post rating: 0
|
Posted: Fri 28 Jun, 2013, 08:36
|
|
User rating: ∞
Joined: Fri 31 Aug, 2007, 09:17 Posts: 6139
|
|
The onBar method executes only once per day. Please provide a precise launch case.
|
|
|
|
|
 |
|
Danniel23261
|
| Post subject: Re: something wrong when calculate indicators in ONBAR method |
Post rating: 0
|
Posted: Fri 28 Jun, 2013, 08:53
|
|
User rating: 0
Joined: Tue 28 May, 2013, 09:39 Posts: 9 Location: ChinaChina
|
|
Yes, I want to calculate it once a day , and then use it's result in ontick method to open order. Is it workable?
The problem is that are there some memory limitation in onBar method. and how i fix it.
|
|
|
|
|
 |
|
API Support
|
| Post subject: Re: something wrong when calculate indicators in ONBAR method |
Post rating: 0
|
Posted: Fri 28 Jun, 2013, 09:06
|
|
User rating: ∞
Joined: Fri 31 Aug, 2007, 09:17 Posts: 6139
|
|
Please provide replication steps for getting the exception you reported.
|
|
|
|
|
 |
|
Danniel23261
|
| Post subject: Re: something wrong when calculate indicators in ONBAR method |
Post rating: 0
|
Posted: Fri 28 Jun, 2013, 09:13
|
|
User rating: 0
Joined: Tue 28 May, 2013, 09:39 Posts: 9 Location: ChinaChina
|
|
when I delete two lines, it run normally.
package singlejartest;
import java.text.SimpleDateFormat; import java.util.TimeZone; import com.dukascopy.api.Filter; import com.dukascopy.api.*; import java.util.List; import com.dukascopy.api.IEngine.OrderCommand;
public class FracZZV implements IStrategy {
IIndicators indicators; IConsole console; IHistory history; IEngine engine; @Configurable("") public Instrument instrument = Instrument.EURUSD; @Configurable("") public Period period = Period.DAILY; @Configurable("") public OfferSide side = OfferSide.BID; @Configurable("") public int barsOnSides = 10; @Configurable("") public int LookbackWeek =50; //@Configurable("") public int extDepth = 12; //@Configurable("") public int extDeviation = 5; //@Configurable("") public int extBackstep = 3;
private static int MAX = 0; private static int MIN = 1;
public double amount = 0.02;
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyy HH:mm:ss");
@Override public void onStart(IContext context) throws JFException { indicators = context.getIndicators(); console = context.getConsole(); history = context.getHistory(); engine = context.getEngine();
}
@Override public void onBar(Instrument instrument, Period period, IBar askBar, IBar bidBar) throws JFException { if(instrument != this.instrument || period != this.period){ return; }
sdf.setTimeZone(TimeZone.getTimeZone("GMT")); console.getOut().println(String.format("start at %s",sdf.format(history.getBar(instrument, period,side,0).getTime())));
IBar currBar = history.getBar(instrument, period, side, 1); IBar prevBar = history.getBar(instrument, period, side, 1); IBar prev2Bar = history.getBar(instrument, period, side, 2); IBar prev3Bar = history.getBar(instrument, period, side, 3); IBar weeklyCurr = history.getBar(Instrument.EURUSD, Period.WEEKLY, OfferSide.BID, 0); IBar weeklyPrev = history.getBar(Instrument.EURUSD, Period.WEEKLY, OfferSide.BID, LookbackWeek); console.getOut().println(String.format("start2 at %s",sdf.format(history.getBar(instrument, period,side,0).getTime())));
double[][] frac = indicators.fractal(instrument, period, side, barsOnSides, Filter.WEEKENDS,weeklyPrev.getTime(), currBar.getTime()); console.getOut().println(String.format("start3 at %s",sdf.format(history.getBar(instrument, period,side,0).getTime()))); // double[] zigzagArray = indicators.zigzag(instrument, period, side, extDepth, extDeviation, extBackstep,Filter.WEEKENDS, weeklyPrev.getTime(), currBar.getTime() ); // console.getOut().println(String.format("start3 at %s",sdf.format(history.getBar(instrument, period,side,0).getTime()))); }
@Override public void onTick(Instrument instrument, ITick tick) throws JFException { }
@Override public void onMessage(IMessage message) throws JFException {}
@Override public void onAccount(IAccount account) throws JFException {}
@Override public void onStop() throws JFException { for (IOrder order : engine.getOrders()) { engine.getOrder(order.getLabel()).close(); } } }
| Attachments: |
QQ图片20130628161010.jpg [139.52 KiB]
Downloaded 521 times
|
FracZZV.java [3.23 KiB]
Downloaded 393 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.
|
|
|
|
|
|
 |
|
API Support
|
| Post subject: Re: something wrong when calculate indicators in ONBAR method |
Post rating: 0
|
Posted: Fri 28 Jun, 2013, 09:15
|
|
User rating: ∞
Joined: Fri 31 Aug, 2007, 09:17 Posts: 6139
|
|
Please provide Historical Tester settings (in English) that you use.
|
|
|
|
|
 |
|
Danniel23261
|
| Post subject: Re: something wrong when calculate indicators in ONBAR method |
Post rating: 0
|
Posted: Fri 28 Jun, 2013, 09:20
|
|
User rating: 0
Joined: Tue 28 May, 2013, 09:39 Posts: 9 Location: ChinaChina
|
|
what's matter? It run OK now when I add last two line. sorry for bothering.
|
|
|
|
|
 |
|
Pages: [
1
]
|
|
|
|
|