|
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.
ichimoku indicator |
[brainstom]
|
Post subject: ichimoku indicator |
Post rating: 0
|
Posted: Sun 14 Feb, 2010, 17:05
|
|
User rating: 0
Joined: Tue 10 Nov, 2009, 16:58 Posts: 65
|
I am trying to write a strategy using the ichimoku indicator, but I have the following problems - setting a 1 hour period, running in the tester, onBar() is called way too often it seems. I would expect onBar() to be called on every new completed bar, so for every hour. but my log shows it is called every 10 seconds ! - the values I get out of the ichimoku indicator do not seem to make any sense. For one, they are all the same even though the indicator should provide 5 values. Could someone point out how to use that indiciator correctly ? Thanks ! See below the ichimoku test code: import java.util.*;
import com.dukascopy.api.*;
public class Strategy implements IStrategy { private IEngine engine; private IConsole console; private IHistory history; private IContext context; private IIndicators indicators; private IUserInterface userInterface; private OfferSide[] mOfferSide; private final static String indicatorName = "ICHIMOKU"; private IIndicators.AppliedPrice[] mAppliedPrice; private Object[] mInputParams; public void onStart(IContext context) throws JFException { this.engine = context.getEngine(); this.console = context.getConsole(); this.history = context.getHistory(); this.context = context; this.indicators = context.getIndicators(); this.userInterface = context.getUserInterface(); mOfferSide = new OfferSide[]{OfferSide.BID}; mAppliedPrice = new IIndicators.AppliedPrice[] {IIndicators.AppliedPrice.CLOSE}; mInputParams = new Object[]{9,26,52}; }
public void onAccount(IAccount account) throws JFException { }
public void onMessage(IMessage message) throws JFException { }
public void onStop() throws JFException { }
public void onTick(Instrument instrument, ITick tick) throws JFException { } public void onBar(Instrument instrument, Period period, IBar askBar, IBar bidBar) throws JFException { Object[] outputs = indicators.calculateIndicator(instrument, period, mOfferSide, indicatorName, mAppliedPrice, mInputParams, 1); for (int i=0;i<outputs.length;i++){ this.console.getOut().print("output: "+outputs[i].toString() +", "); } this.console.getOut().print("bar: " + bidBar.toString() ); this.console.getOut().println(); } }
log: 2010-02-14 15:52:08 output: 1.3789500000000001, output: 1.378925, output: 1.37835, output: 1.3789375000000001, output: 1.379025, output: [D@133994d, bar: {T:1265765580000(2010-02-10 01:33:00.000+0000)E:falseO:1.37835C:1.3785L:1.3783H:1.3786V1.87E-4} 2010-02-14 15:52:08 output: 1.3785, output: 1.378825, output: 1.37845, output: 1.3786625, output: 1.3789500000000001, output: [D@1882f01, bar: {T:1265765620000(2010-02-10 01:33:40.000+0000)E:falseO:1.3785C:1.3785L:1.37845H:1.3785V1.2E-5} 2010-02-14 15:52:07 output: 1.3785, output: 1.378825, output: 1.37845, output: 1.3786625, output: 1.3789500000000001, output: [D@6bf49c, bar: {T:1265765610000(2010-02-10 01:33:30.000+0000)E:falseO:1.3785C:1.37845L:1.37845H:1.37855V5.7E-5} 2010-02-14 15:52:07 output: 1.3785500000000002, output: 1.378825, output: 1.3785, output: 1.3786875, output: 1.3789500000000001, output: [D@1a4a57a, bar: {T:1265765600000(2010-02-10 01:33:20.000+0000)E:falseO:1.37855C:1.37845L:1.37845H:1.3786V4.5E-5} 2010-02-14 15:52:07 output: 1.378575, output: 1.378825, output: 1.3784, output: 1.3787, output: 1.3789500000000001, output: [D@155eab7, bar: {T:1265765590000(2010-02-10 01:33:10.000+0000)E:falseO:1.3784C:1.3785L:1.3784H:1.37855V2.6E-5} 2010-02-14 15:52:07 output: 1.3786, output: 1.378825, output: 1.37835, output: 1.3787125, output: 1.3789500000000001, output: [D@aa7e7b, bar: {T:1265765580000(2010-02-10 01:33:00.000+0000)E:falseO:1.37835C:1.3784L:1.3783H:1.3784V3.2E-5} 2010-02-14 15:52:07 output: 1.3787, output: 1.378825, output: 1.37835, output: 1.3787625000000001, output: 1.3789500000000001, output: [D@623976, bar: {T:1265765570000(2010-02-10 01:32:50.000+0000)E:falseO:1.37835C:1.37835L:1.3783H:1.37835V4.1E-5} 2010-02-14 15:52:07 output: 1.3789500000000001, output: 1.378925, output: 1.3788, output: 1.3789375000000001, output: 1.3790749999999998, output: [D@ac7d7b, bar: {T:1265765520000(2010-02-10 01:32:00.000+0000)E:falseO:1.3788C:1.37835L:1.3783H:1.3788V2.8E-4} 2010-02-14 15:52:07 output: 1.3787500000000001, output: 1.37885, output: 1.3785, output: 1.3788, output: 1.378975, output: [D@651690, bar: {T:1265765560000(2010-02-10 01:32:40.000+0000)E:falseO:1.37855C:1.37835L:1.37835H:1.37855V6.0E-5} 2010-02-14 15:52:07 output: 1.3789, output: 1.3789500000000001, output: 1.3787, output: 1.3789250000000002, output: 1.3790499999999999, output: [D@d8c8c5, bar: {T:1265765550000(2010-02-10 01:32:30.000+0000)E:falseO:1.3787C:1.3785L:1.3785H:1.3787V5.9E-5} 2010-02-14 15:52:07 output: 1.378975, output: 1.379125, output: 1.3787, output: 1.3790499999999999, output: 1.379125, output: [D@128166e, bar: {T:1265765540000(2010-02-10 01:32:20.000+0000)E:falseO:1.3787C:1.3787L:1.3787H:1.3787V0.0} 2010-02-14 15:52:07 output: 1.378975, output: 1.379125, output: 1.3787, output: 1.3790499999999999, output: 1.379125, output: [D@1624712, bar: {T:1265765530000(2010-02-10 01:32:10.000+0000)E:falseO:1.3787C:1.3787L:1.37865H:1.3787V5.9E-5}
|
|
|
|
 |
API Support
|
Post subject: Re: ichimoku indicator |
Post rating: 0
|
Posted: Mon 15 Feb, 2010, 09:56
|
|
User rating: ∞
Joined: Fri 31 Aug, 2007, 09:17 Posts: 6139
|
|
|
|
 |
[brainstom]
|
Post subject: Re: ichimoku indicator |
Post rating: 0
|
Posted: Mon 15 Feb, 2010, 10:07
|
|
User rating: 0
Joined: Tue 10 Nov, 2009, 16:58 Posts: 65
|
ok, I'll try that. It does seem illogical however that onBar() is called more frequently than on each bar however.
What about the issue with getting the ichimoku values ? Am I using it in the correct way ?
|
|
|
|
 |
[brainstom]
|
Post subject: Re: ichimoku indicator |
Post rating: 0
|
Posted: Mon 15 Feb, 2010, 10:56
|
|
User rating: 0
Joined: Tue 10 Nov, 2009, 16:58 Posts: 65
|
ok, it looks like I am getting the right ichimoku values. I was confused because the chikou and tekan span values are not time shifted 26 periods. So it's all working fine now, thanks.
|
|
|
|
 |
API Support
|
Post subject: Re: ichimoku indicator |
Post rating: 0
|
Posted: Mon 15 Feb, 2010, 10:58
|
|
User rating: ∞
Joined: Fri 31 Aug, 2007, 09:17 Posts: 6139
|
|
|
|
 |
[brainstom]
|
Post subject: Re: ichimoku indicator |
Post rating: 0
|
Posted: Sun 21 Feb, 2010, 21:36
|
|
User rating: 0
Joined: Tue 10 Nov, 2009, 16:58 Posts: 65
|
update: finally got it. must use the base type double, not Double... I spoke too fast. When using higher timeframes in my strategy, the indicator returns values that are completely different from what I see on the graph. I figure it might be due to the flats (on week-ends, etc.) not being suppressed. So I want to use indicators.calculateIndicator() that allows to specify a filter, but I can't figure how to use the returned object array... I get an error when trying to access its values. The Double case causes a class cast exception. Is there an example of using a multivalued indicator, wth filter, through indicators.calculateIndicator() ? I guess what I don't get is that calculateIndicators() supposedly returns an array of arrays. I never get that, just a simple array... Here is example code package jforex;
import java.util.*;
import com.dukascopy.api.*; import com.dukascopy.api.indicators.*;
public class testStrategy implements IStrategy { private IEngine engine; private IConsole console; private IHistory history; private IContext context; private IIndicators indicators; private IUserInterface userInterface; private OfferSide[] mOfferSide; private final static String indicatorName = "ICHIMOKU"; private IIndicators.AppliedPrice[] mAppliedPrice; private Object[] mInputParams;
public void onStart(IContext context) throws JFException { this.engine = context.getEngine(); this.console = context.getConsole(); this.history = context.getHistory(); this.context = context; this.indicators = context.getIndicators(); this.userInterface = context.getUserInterface();
mOfferSide = new OfferSide[]{OfferSide.BID}; mAppliedPrice = new IIndicators.AppliedPrice[] {IIndicators.AppliedPrice.CLOSE}; mInputParams = new Object[]{9,26,52}; IIndicator ichimoku = indicators.getIndicator(indicatorName); IndicatorInfo ichiinfo = ichimoku.getIndicatorInfo(); int numOutputs = ichiinfo.getNumberOfOutputs(); this.console.getOut().println("ichimoku outputs: " + numOutputs); for(int i = 0; i < numOutputs; i++) { OutputParameterInfo outInfo = ichimoku.getOutputParameterInfo(i); String paramType = ""; OutputParameterInfo.Type outType = outInfo.getType(); if(outType == OutputParameterInfo.Type.DOUBLE) paramType = "DOUBLE"; if(outType == OutputParameterInfo.Type.INT) paramType = "INT"; if(outType == OutputParameterInfo.Type.OBJECT) paramType = "OBJECT"; this.console.getOut().println("param(" + i + "): " + paramType + "param name: " + outInfo.getName()); } }
public void onAccount(IAccount account) throws JFException { }
public void onMessage(IMessage message) throws JFException { }
public void onStop() throws JFException { }
public void onTick(Instrument instrument, ITick tick) throws JFException { } public void onBar(Instrument instrument, Period period, IBar askBar, IBar bidBar) throws JFException { if(period == Period.ONE_HOUR){ Object[] kumo_1_hour = indicators.calculateIndicator(instrument, Period.ONE_HOUR, mOfferSide, indicatorName, null,//mAppliedPrice, mInputParams, Filter.ALL_FLATS, 52, askBar.getTime(), 0); Double tenkan = (Double)kumo_1_hour[0]; Double kijun = (Double)kumo_1_hour[1]; Double chiku = (Double)kumo_1_hour[2]; Double senkan_a = (Double)kumo_1_hour[3]; Double senkan_b = (Double)kumo_1_hour[4];
ITick currentTick = history.getLastTick(instrument);
this.console.getOut().println("ask: " + currentTick.getAsk() + " tenkan: " + tenkan + " kijun: " + kijun + "chiku: " + chiku + " senkan_b: " + senkan_b + " senkan_a: " + senkan_a + " " + askBar.toString()); } } }
Help ! Thanks
|
|
|
|
 |
API Support
|
Post subject: Re: ichimoku indicator |
Post rating: 0
|
Posted: Mon 22 Feb, 2010, 10:57
|
|
User rating: ∞
Joined: Fri 31 Aug, 2007, 09:17 Posts: 6139
|
For ichimoku - you should use the ".calculateIndicator" method, but not the ichimoku method. "Ichimoku" method will be removed from the api in the next releases, becouse Ichimoku usses the custom output params. Here the example of using Ichimoku indicator: Integer[] optParams = new Integer[3]; optParams[0] = 9; optParams[1] = 26; optParams[2] = 52; Object [] test = indicators.calculateIndicator(instrument, Period.ONE_MIN, new OfferSide[] {OfferSide.ASK}, "ICHIMOKU", new IIndicators.AppliedPrice[] {IIndicators.AppliedPrice.OPEN}, optParams, 0); double[] point = (double[])test[5]; System.out.println("Tenkan Sen " + test[0]); System.out.println("Kijun Sen " + test[1]); System.out.println("Chinkou Span " + test[2]); System.out.println("A " + test[3]); System.out.println("b " + test[4]); System.out.println("Cloud A " + point[0]); System.out.println("Cloud B " + point[1]);
|
|
|
|
 |
[brainstom]
|
Post subject: Re: ichimoku indicator |
Post rating: 0
|
Posted: Wed 24 Feb, 2010, 09:47
|
|
User rating: 0
Joined: Tue 10 Nov, 2009, 16:58 Posts: 65
|
thanks, I figured it out eventually ! now I know that we get 5 arrays back, with the ichimoku values. the 6th array is called (according to the param info) "cloud" and is of type OBJECT. How do I use that ? what kind of object can it be cast to ?
|
|
|
|
 |
API Support
|
Post subject: Re: ichimoku indicator |
Post rating: 0
|
Posted: Wed 24 Feb, 2010, 10:35
|
|
User rating: ∞
Joined: Fri 31 Aug, 2007, 09:17 Posts: 6139
|
brainstom wrote: thanks, I figured it out eventually ! now I know that we get 5 arrays back, with the ichimoku values. the 6th array is called (according to the param info) "cloud" and is of type OBJECT. How do I use that ? what kind of object can it be cast to ? The 6th array is double[], which have two values for 0 index and 1 index, you can see this in the example.
|
|
|
|
 |
[brainstom]
|
Post subject: Re: ichimoku indicator |
Post rating: 0
|
Posted: Fri 26 Feb, 2010, 00:20
|
|
User rating: 0
Joined: Tue 10 Nov, 2009, 16:58 Posts: 65
|
ok I ran the code below to figure there was an object arraz, but in general how do I know what the object class is ? now that you said it, sure I can cast...
Other question: How are those Cloud values different from the Senkou A and Senkou B span ?
|
|
|
|
 |
API Support
|
Post subject: Re: ichimoku indicator |
Post rating: 0
|
Posted: Fri 26 Feb, 2010, 08:29
|
|
User rating: ∞
Joined: Fri 31 Aug, 2007, 09:17 Posts: 6139
|
Cloud values is build from Senkou A and Senkou B, it is the same, the object Cloud - mostly done for ichimoku visualization.
|
|
|
|
 |
Guest
|
Post subject: Re: ichimoku indicator |
Post rating: 0
|
Posted: Wed 14 Jul, 2010, 09:09
|
|
User rating: -
|
Hello there, Am running the code below, but the values am getting are not the same ones on the chart. Why is this? I also have a problem that when I use the history tester with the visual checkbox on, the chart that opens is a 10 sec chart that is eventually overwritten by the real 10 secs chart instead of showing the 1 hour history which is what I have selected. Please explain how the returned values for ICHIMOKU map with the values in the chart. public void onBar(Instrument instrument, Period period, IBar askBar, IBar bidBar) throws JFException { if (period == Period.ONE_HOUR) { Object [] ichiResult = indicators.calculateIndicator(instrument, period, new OfferSide[] {OfferSide.BID}, "ICHIMOKU", /*new IIndicators.AppliedPrice[] {IIndicators.AppliedPrice.OPEN}*/null, ichimokuParams, Filter.WEEKENDS, 1, bidBar.getTime(), 0); int count = 0; print("TIME = " + new Date(bidBar.getTime())); for(Object o : ichiResult){ if(count == 5) continue; double[] vals = (double[]) o; print("ITEM # " + count++); for(Double d : vals) print(d); } total++; print(total); } Here is some output... 2010.07.14 07:18:12 TIME = Mon Jul 05 03:00:00 EAT 2010 2010.07.14 07:18:12 ITEM # 0 2010.07.14 07:18:12 1.254875 2010.07.14 07:18:12 ITEM # 1 2010.07.14 07:18:12 1.254625 2010.07.14 07:18:12 ITEM # 2 2010.07.14 07:18:12 1.2546 2010.07.14 07:18:12 ITEM # 3 2010.07.14 07:18:12 1.25475 2010.07.14 07:18:12 ITEM # 4 2010.07.14 07:18:12 1.2402 2010.07.14 07:18:12 1 2010.07.14 07:18:12 TIME = Mon Jul 05 04:00:00 EAT 2010 2010.07.14 07:18:12 ITEM # 0 2010.07.14 07:18:12 1.25445 2010.07.14 07:18:12 ITEM # 1 2010.07.14 07:18:12 1.254625 2010.07.14 07:18:12 ITEM # 2 2010.07.14 07:18:12 1.25255 2010.07.14 07:18:12 ITEM # 3 2010.07.14 07:18:12 1.2545375 2010.07.14 07:18:12 ITEM # 4 2010.07.14 07:18:12 1.2402 2010.07.14 07:18:12 2 2010.07.14 07:18:12 TIME = Mon Jul 05 05:00:00 EAT 2010 2010.07.14 07:18:12 ITEM # 0 2010.07.14 07:18:12 1.25445 2010.07.14 07:18:12 ITEM # 1 2010.07.14 07:18:12 1.254625 2010.07.14 07:18:12 ITEM # 2 2010.07.14 07:18:12 1.25305 2010.07.14 07:18:12 ITEM # 3 2010.07.14 07:18:12 1.2545375 2010.07.14 07:18:12 ITEM # 4 2010.07.14 07:18:12 1.2402 2010.07.14 07:18:12 3 2010.07.14 07:18:12 TIME = Mon Jul 05 06:00:00 EAT 2010 2010.07.14 07:18:12 ITEM # 0 2010.07.14 07:18:12 1.25445 2010.07.14 07:18:12 ITEM # 1 2010.07.14 07:18:12 1.254625 2010.07.14 07:18:12 ITEM # 2 2010.07.14 07:18:12 1.2538 2010.07.14 07:18:12 ITEM # 3 2010.07.14 07:18:12 1.2545375 2010.07.14 07:18:12 ITEM # 4 2010.07.14 07:18:12 1.2402 2010.07.14 07:18:12 4 2010.07.14 07:18:12 TIME = Mon Jul 05 07:00:00 EAT 2010 2010.07.14 07:18:12 ITEM # 0 2010.07.14 07:18:12 1.25445 2010.07.14 07:18:12 ITEM # 1 2010.07.14 07:18:12 1.254625 2010.07.14 07:18:12 ITEM # 2 2010.07.14 07:18:12 1.25385 2010.07.14 07:18:12 ITEM # 3 2010.07.14 07:18:12 1.2545375 2010.07.14 07:18:12 ITEM # 4 2010.07.14 07:18:12 1.2402 2010.07.14 07:18:12 5 2010.07.14 07:18:12 TIME = Mon Jul 05 08:00:00 EAT 2010 2010.07.14 07:18:12 ITEM # 0 2010.07.14 07:18:12 1.2543 2010.07.14 07:18:12 ITEM # 1 2010.07.14 07:18:12 1.254625 2010.07.14 07:18:12 ITEM # 2 2010.07.14 07:18:12 1.2543 2010.07.14 07:18:12 ITEM # 3 2010.07.14 07:18:12 1.2544625 2010.07.14 07:18:12 ITEM # 4 2010.07.14 07:18:12 1.24035 2010.07.14 07:18:12 6 2010.07.14 07:18:12 TIME = Mon Jul 05 09:00:00 EAT 2010 2010.07.14 07:18:12 ITEM # 0 2010.07.14 07:18:12 1.254175 2010.07.14 07:18:12 ITEM # 1 2010.07.14 07:18:12 1.254625 2010.07.14 07:18:12 ITEM # 2 2010.07.14 07:18:12 1.25385 2010.07.14 07:18:12 ITEM # 3 2010.07.14 07:18:12 1.2544 2010.07.14 07:18:12 ITEM # 4 2010.07.14 07:18:12 1.24035 2010.07.14 07:18:12 7 2010.07.14 07:18:12 TIME = Mon Jul 05 10:00:00 EAT 2010 2010.07.14 07:18:12 ITEM # 0 2010.07.14 07:18:12 1.253975 2010.07.14 07:18:12 ITEM # 1 2010.07.14 07:18:12 1.254625 2010.07.14 07:18:12 ITEM # 2 2010.07.14 07:18:12 1.2543 2010.07.14 07:18:12 ITEM # 3 2010.07.14 07:18:12 1.2543 2010.07.14 07:18:12 ITEM # 4 2010.07.14 07:18:12 1.24035 2010.07.14 07:18:12 8
Regards.
|
|
|
|
 |
API Support
|
Post subject: Re: ichimoku indicator |
Post rating: 0
|
Posted: Thu 15 Jul, 2010, 10:35
|
|
User rating: ∞
Joined: Fri 31 Aug, 2007, 09:17 Posts: 6139
|
Hi Quote: Am running the code below, but the values am getting are not the same ones on the chart. Why is this? We corrected a little bit your code. Here it is: public void onBar(Instrument instrument, Period period, IBar askBar, IBar bidBar) throws JFException { if (period == Period.TEN_SECS && instrument == Instrument.EURUSD) { Object [] ichiResult = indicators.calculateIndicator(instrument, period, new OfferSide[] {OfferSide.BID}, "ICHIMOKU", new AppliedPrice[]{AppliedPrice.CLOSE}, new Object[]{9, 26, 52}, Filter.WEEKENDS, 1, bidBar.getTime(), 0); int count = 0; console.getOut().println("TIME = " + new Date(bidBar.getTime())); for(Object o : ichiResult){ double[] vals = (double[]) o; console.getOut().println("ITEM # " + count++); for(Double d : vals) console.getOut().println(d); } total++; console.getOut().println(total); } } We tested this code in a real time mode it works. We used 10 second candles and added check on instrument(just to be sure). The key is hidden in given OptInputParameters 9, 26, 52, which affects indicator. Here 26 is used as shift for cloud output parameters and Senkou line output. It means that a correct value, you will find after 26 candles from cuurent candle. In a cloud case +26 candles from current candle, but for a Senkou line it will be -26. This is because of specifics of ichimoku indicator. Please consider this link on ichimoku https://www.kumotrader.com/ichimoku_wiki/index.php?title=IntroductionQuote: I also have a problem that when I use the history tester with the visual checkbox on, the chart that opens is a 10 sec chart that is eventually overwritten by the real 10 secs chart instead of showing the 1 hour history which is what I have selected. In a tester mode, when you select specific period, it means that that type of candles will be downloaded and used for testing. What you see on chart, is used to visualize the testing process. The system by it self determines which candles so that testing would look better. For example, if you use ONE_HOUR candles and test your strategy for last day. Its likely that a system will choose the TEN_MIN period to show on chart. Its because 10 min candles will fill you all chart space, but hour will fill you just part of it.
|
|
|
|
 |
[Kirilla]
|
Post subject: Re: ichimoku indicator |
Post rating: 0
|
Posted: Tue 21 Dec, 2010, 12:00
|
|
User rating: 5
Joined: Fri 22 Oct, 2010, 09:54 Posts: 24
|
Hi! I've tried the example code you mentioned above, but I got the following exception for the 6th element of ichiResult. cannot be cast to [D @ jforex.IchiStrategy.onBar(IchiStrategy.java:46)2010.12.21 10:50:25,TIME = Mon Nov 01 05:00:00 CET 2010 Is there any detailed documentation about Ichimoku indicator, which explains how can I get the current and future Senkou span values? I found out that ichiResult 6th element is an Object[] type and has 1 element a double[] type, which has two elements. The working code is here: public void onBar(Instrument instrument, Period period, IBar askBar, IBar bidBar) throws JFException { if (period == Period.FOUR_HOURS && instrument == Instrument.EURUSD) { Object [] ichiResult = indicators.calculateIndicator(instrument, period, new OfferSide[] {OfferSide.BID}, "ICHIMOKU", new IIndicators.AppliedPrice[]{IIndicators.AppliedPrice.CLOSE}, new Object[]{9, 26, 52}, Filter.WEEKENDS, 1, bidBar.getTime(), 0); int count = 0; console.getOut().println("TIME = " + new Date(bidBar.getTime())); /*for(Object o : ichiResult){ double[] vals = (double[]) o; console.getOut().println("ITEM # " + count++); for(Double d : vals) console.getOut().println(d); }*/ console.getOut().println("Price: " + bidBar.getClose()); console.getOut().println("Tenkan sen: " + ((double[])ichiResult[0])[0]); console.getOut().println("Kijun sen: " + ((double[])ichiResult[1])[0]); console.getOut().println("Chikou span: " + ((double[])ichiResult[2])[0]); console.getOut().println("Senkou span A: " + ((double[])ichiResult[3])[0]); console.getOut().println("Senkou span B: " + ((double[])ichiResult[4])[0]); console.getOut().println("Cloud A: " + ((double[])((Object[])ichiResult[5])[0])[0]); console.getOut().println("Cloud B: " + ((double[])((Object[])ichiResult[5])[0])[1]); total++; console.getOut().println(total); } } By the way, Senkou Span A = Cloud A and Senkou Span B = Cloud B. It will be more useful if Senkou or Cloud value would be the current cloud value note the 26 periods forward shifted. How can I get the current "cloud" values? Do I have to store Senkou Span values for 26 periods? Best regards, Kirilla
|
|
|
|
 |
API Support
|
Post subject: Re: ichimoku indicator |
Post rating: 0
|
Posted: Wed 29 Dec, 2010, 09:22
|
|
User rating: ∞
Joined: Fri 31 Aug, 2007, 09:17 Posts: 6139
|
|
|
|
 |
aero
|
Post subject: Re: ichimoku indicator |
Post rating: 0
|
Posted: Wed 22 Jun, 2011, 08:52
|
|
User rating: -
|
Hello,
Can you guys tell me how to get Tenkan Sen value from present and previous bar at one time to compare them?
Thanks
|
|
|
|
 |
API Support
|
Post subject: Re: ichimoku indicator |
Post rating: 0
|
Posted: Mon 27 Jun, 2011, 12:53
|
|
User rating: ∞
Joined: Fri 31 Aug, 2007, 09:17 Posts: 6139
|
Consider changing candlesBefore parameter from 1 to 2 in order to select values over the last 2 candles: Object [] ichiResult = indicators.calculateIndicator(instrument, period, new OfferSide[] {OfferSide.BID}, "ICHIMOKU", new IIndicators.AppliedPrice[]{IIndicators.AppliedPrice.CLOSE}, new Object[]{9, 26, 52}, Filter.WEEKENDS, 2, bidBar.getTime(), 0); console.getOut().println("Tenkan sen - previous " + ((double[])ichiResult[0])[0] + " current: " + ((double[])ichiResult[0])[1]);
|
|
|
|
 |
Guest
|
Post subject: Re: ichimoku indicator |
Post rating: 0
|
Posted: Wed 29 Jun, 2011, 10:12
|
|
User rating: -
|
Support wrote: Consider changing candlesBefore parameter from 1 to 2 in order to select values over the last 2 candles: Object [] ichiResult = indicators.calculateIndicator(instrument, period, new OfferSide[] {OfferSide.BID}, "ICHIMOKU", new IIndicators.AppliedPrice[]{IIndicators.AppliedPrice.CLOSE}, new Object[]{9, 26, 52}, Filter.WEEKENDS, 2, bidBar.getTime(), 0); console.getOut().println("Tenkan sen - previous " + ((double[])ichiResult[0])[0] + " current: " + ((double[])ichiResult[0])[1]); Hi I figured it out using shift parameter. But I'm still looking for help how to put here Weekends filter. Can you also advise why this method is incorrect for currency pairs with JPY? Out parameters are different from those form graph. Integer[] optParamsEurUsd = new Integer[3]; optParamsEurUsd[0] = 9; optParamsEurUsd[1] = 26; optParamsEurUsd[2] = 52; Object [] ichieurusd = indicators.calculateIndicator(Instrument.EURUSD, Period.FIFTEEN_MINS, new OfferSide[] {OfferSide.BID}, "ICHIMOKU", new IIndicators.AppliedPrice[] {IIndicators.AppliedPrice.CLOSE}, optParamsEurUsd, [size=150]0[/size]);
|
|
|
|
 |
API Support
|
Post subject: Re: ichimoku indicator |
Post rating: 0
|
Posted: Wed 29 Jun, 2011, 14:58
|
|
User rating: ∞
Joined: Fri 31 Aug, 2007, 09:17 Posts: 6139
|
Guest wrote: I figured it out using shift parameter. But I'm still looking for help how to put here Weekends filter. Can you also advise why this method is incorrect for currency pairs with JPY? Out parameters are different from those form graph. Integer[] optParamsEurUsd = new Integer[3]; optParamsEurUsd[0] = 9; optParamsEurUsd[1] = 26; optParamsEurUsd[2] = 52; Object [] ichieurusd = indicators.calculateIndicator(Instrument.EURUSD, Period.FIFTEEN_MINS, new OfferSide[] {OfferSide.BID}, "ICHIMOKU", new IIndicators.AppliedPrice[] {IIndicators.AppliedPrice.CLOSE}, optParamsEurUsd, [size=150]0[/size]); You have to change the instrument parameter.
|
|
|
|
 |
deMoroz
|
Post subject: Re: ichimoku indicator |
Post rating: 0
|
Posted: Wed 17 Aug, 2011, 20:44
|
|
User rating: 0
Joined: Wed 17 Aug, 2011, 20:08 Posts: 1 Location: BY
|
Hi Support, I've also trying to find out how calculateIndicator method works for Ichimoku indicator and still have no clear vision on it. Lets see the code: @Override public void onTick(Instrument instrument, ITick tick) throws JFException { currentTime = tick.getTime(); }
@Override public void onBar(Instrument instrument, Period period, IBar askBar, IBar bidBar) throws JFException {
if (!this.context.getSubscribedInstruments().contains(instrument) || period != Period.ONE_HOUR) return;
System.out.println("onBar event: " + dateFormat.format(new Date(currentTime))); System.out.println("askBar.getClose(): " + askBar.getClose());
Object[] ichimokuAsk1 = indicators.calculateIndicator(instrument, period, new OfferSide[] {OfferSide.ASK}, "ICHIMOKU", new IIndicators.AppliedPrice[] {IIndicators.AppliedPrice.CLOSE}, new Object[] {9, 26, 52}, 1); System.out.println("[01] Tenkan Sen " + ichimokuAsk1[0]);
Object[] ichimokuAsk2 = indicators.calculateIndicator(instrument, period, new OfferSide[] {OfferSide.ASK}, "ICHIMOKU", new IIndicators.AppliedPrice[] {IIndicators.AppliedPrice.CLOSE}, new Object[] {9, 26, 52}, 1); System.out.println("[01] Senkou Span A " + ichimokuAsk2[3]); System.out.println("[01] Senkou Span B " + ichimokuAsk2[4]);
Object[] ichimokuAsk3 = indicators.calculateIndicator(instrument, period, new OfferSide[] {OfferSide.ASK}, "ICHIMOKU", new IIndicators.AppliedPrice[] {IIndicators.AppliedPrice.CLOSE}, new Object[] {9, 26, 52}, 27); System.out.println("[27] Senkou Span A " + ichimokuAsk3[3]); System.out.println("[27] Senkou Span B " + ichimokuAsk3[4]); }
Subscribed Instruments is: Set<Instrument> subscribedInstruments = new HashSet<Instrument>(); subscribedInstruments.add(Instrument.EURUSD); context.setSubscribedInstruments(subscribedInstruments);
Code output: onBar event: 2011.08.16 05:59:58 743 askBar.getClose(): 1.44096 [01] Tenkan Sen 1.44306 [01] Senkou Span A 1.4400825 [01] Senkou Span B 1.4365199999999998 [27] Senkou Span A 1.42855 [27] Senkou Span B 1.42855 onBar event: 2011.08.16 06:59:59 963 askBar.getClose(): 1.43902 [01] Tenkan Sen 1.44122 [01] Senkou Span A 1.4391625 [01] Senkou Span B 1.4365199999999998 [27] Senkou Span A 1.42855 [27] Senkou Span B 1.42855
So let's analyze code output and current chart for EURUSD, 1 hour, ask: 1. First time period selected on a chart - 2011.08.16 06:00:00 2. askBar.getClose(): 1.44096 seems correct for the 2011.08.16 05:59:58 3. Tenkan Sen seems also correct for the previous bar [01] Tenkan Sen 1.44306 But I cant figure our how to calculate Senkou Span lines correctly? I've trying to calculate it for the period 1, but early you've said that by the calculateIndicator method this lines is calculated 26 bars ahead and it's ok with an Ichimoku formula and I've trying to calculate it for the period 27 (27 bars back) but as you can see from the output and image attached still without any success and a chance to see correct values In case of period 1 even if Senkou Span A 1.4400825 value seems near the correct value, Senkou Span B 1.436519 seems located located not in a correct place. Could you please clarify how to calculate Senkou Span lines correctly and whats wrong with my code?
Attachments: |
12345.jpg [123.49 KiB]
Downloaded 716 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.
|
|
|
|
|
 |
|
Pages: [
1, 2
»
]
|
|
|
|
|