|
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.
Problem with AC and Awesome Indicators |
nick76
|
Post subject: Problem with AC and Awesome Indicators |
Post rating: 0
|
Posted: Sun 14 Aug, 2011, 23:53
|
|
User rating: 0
Joined: Sun 14 Aug, 2011, 23:46 Posts: 7 Location: Switzerland,
|
Hello, I'm trying to code a simple Caos strategy and I obtain really strange results between the graphic and the values I get: I've already checked the currencies, applied price, and time frame of both graphic and testing board. I use One Hour time frame with EUR/USD currency. there is something I do wrong? I attach a sample of the code. best regards btw... I also downloaded the testStrategy.java of ellisoid ( https://www.dukascopy.com/swiss/english/forex/jforex/forum/viewtopic.php?f=6&t=24217) and modifying it to EURUSD and ONE_HOUR I've non-sense values... Nicola ps. maybe do you have a comprehensive guide on indicators? for example I don't find anywhere documentations on AC indicators on your API docs.
Attachments: |
File comment: testStrategy modified
TestStrategy.java [4.43 KiB]
Downloaded 305 times
|
ChaosBase.java [7.2 KiB]
Downloaded 292 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: Problem with AC and Awesome Indicators |
Post rating: 0
|
Posted: Mon 15 Aug, 2011, 08:44
|
|
User rating: ∞
Joined: Fri 31 Aug, 2007, 09:17 Posts: 6139
|
onBar method receives bars with different periods and different instruments. Therefore, instrument and period needs to be checked in the beginning of the method. Please, consider changing onBar method to following code public void onBar(Instrument instrument, Period period, IBar askBar, IBar bidBar) throws JFException { // take only bars that correspond to selected instrument and period if (!instrument.equals(this.instrument) || !period.equals(this.period)) return; IBar CurrHourBar = history.getBar(instrument, period, OfferSide.BID, 0); IBar prev1HourBar = history.getBar(instrument, period, OfferSide.BID, 1); //Current double currHourOpen = CurrHourBar.getOpen(); double currHourClose = CurrHourBar.getClose(); double currHourHigh = CurrHourBar.getHigh(); double currHourLow = CurrHourBar.getLow(); long currHourTime = CurrHourBar.getTime(); //One Hour Ago double prevHourOpen = prev1HourBar.getOpen(); double prevHourClose = prev1HourBar.getClose(); double prevHourHigh = prev1HourBar.getHigh(); double prevHourLow = prev1HourBar.getLow(); long prevHourTime = prev1HourBar.getTime(); //Indicators //AWESOME(5,SMA,34,SMA) double[][] Awesome5 = indicators.awesome( instrument, //Instrument period, //Period One Hour OfferSide.BID, //Offerside BID IIndicators.AppliedPrice.MEDIAN_PRICE, //Applied Price MEDIAN PRICE 5, //FasterMA Time Period 5 IIndicators.MaType.SMA, //IIndicators.MaType SMA 34, //SlowerMA Time Period 34 IIndicators.MaType.SMA, //IIndicators.MaType SMA prevHourTime, //From 1 Hour Ago currHourTime //To Current Time ); double[][] ac5 = indicators.ac( instrument, //Instrument period, //Period One Hour OfferSide.BID, //Offerside BID IIndicators.AppliedPrice.MEDIAN_PRICE, //Applied Price MEDIAN PRICE 5, //fastPeriod 5 34, //slowPeriod 34 prevHourTime, //From 1 Hour Ago currHourTime //To Current Time ); //Set Long Position if (ac5[0][1] !=0 ) { console.getOut().println("AC Up: " + ac5[0][1]); if (!Double.isNaN(Awesome5[1][1])) { console.getOut().println("Awe Up: " + Awesome5[1][1]); goLong = true;
} } //Set Short Position if (ac5[1][1] !=0 ) { console.getOut().println("AC Down: " + ac5[1][1]); if (!Double.isNaN(Awesome5[2][1])) { console.getOut().println("Awe Down: " + Awesome5[2][1]); goShort = true; } } } Information concerning the use of indicators in strategies is available here: https://www.dukascopy.com/wiki/index.php?title=Strategy_API:_Indicators.
|
|
|
|
 |
nick76
|
Post subject: Re: Problem with AC and Awesome Indicators |
Post rating: 0
|
Posted: Mon 15 Aug, 2011, 09:59
|
|
User rating: 0
Joined: Sun 14 Aug, 2011, 23:46 Posts: 7 Location: Switzerland,
|
Hello, thank you very much for your answer. I tried to implement your modification but without success... as you can see in the images attached, the values I obtain with the indicator is completely different from what I see on the graphic.
Nicola
Attachments: |
File comment: history tester
hist-test.jpg [184.23 KiB]
Downloaded 367 times
|
File comment: Graphic EURUSD 1H
graphicEURUSD.jpg [143.34 KiB]
Downloaded 362 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.
|
|
|
|
|
 |
nick76
|
Post subject: Re: Problem with AC and Awesome Indicators |
Post rating: 0
|
Posted: Mon 15 Aug, 2011, 13:00
|
|
User rating: 0
Joined: Sun 14 Aug, 2011, 23:46 Posts: 7 Location: Switzerland,
|
look at the image below.. it quite seems that the Positive/negative value is given by relationship between the value and the Zero... Attachment:
File comment: Relationship between value and 0
ACrelationship.jpg [252.9 KiB]
Downloaded 359 times
Is something I do wrong? thank you a lot Nicola
|
|
|
|
 |
nick76
|
Post subject: Re: JFOREX-3152 Problem with AC and Awesome Indicators |
Post rating: 0
|
Posted: Wed 17 Aug, 2011, 09:37
|
|
User rating: 0
Joined: Sun 14 Aug, 2011, 23:46 Posts: 7 Location: Switzerland,
|
A question: could it be that's only a visual problem? there's someone who can confirm that the AC indicator works well (maybe could attach a file or a part of file which prove the indicator)?
thank you very much
Nicola
|
|
|
|
 |
API Support
|
Post subject: Re: JFOREX-3152 Problem with AC and Awesome Indicators |
Post rating: 0
|
Posted: Wed 17 Aug, 2011, 15:33
|
|
User rating: ∞
Joined: Fri 31 Aug, 2007, 09:17 Posts: 6139
|
The indicator is working as it should. 1. When the shift parameter is set to 0 the indicator method returns current unfinished bar. To get last complete bar shift parameter must be set to 1 (e.g. the last parameter in ac method call). 2. Indicator ac is green when the new indicator value is larger than the previous one and red when it is smaller than previous value. Here is an example: public void onBar(Instrument instrument, Period period, IBar askBar, IBar bidBar) throws JFException {
if (instrument.equals(strategyInstrument) && period.equals(strategyPeriod)) {
double[] ac1 = indicators.ac(strategyInstrument, strategyPeriod, OfferSide.BID, IIndicators.AppliedPrice.CLOSE, 5, 34, 1);
double x0 = ac1[0]; double x1 = ac1[1]; double x = x0 == 0 ? x1 : x0;
String color = "_____"; if (previousValue > x) { color = "__red"; } else if (previousValue < 0) { color = "green"; }
console.getOut().format("%s %5s % .7f % .7f \n", sdf.format(bidBar.getTime()), color, x0, x1); console.getOut().flush(); previousValue = x; } } }
Please, see the full strategy in the attachment
Attachments: |
TestStrategy.java [2.37 KiB]
Downloaded 308 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
]
|
|
|
|
|