Dukascopy
 
 
Wiki JStore Search Login

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.

Regarding Awesome Oscillator
 Post subject: Regarding Awesome Oscillator Post rating: 0   Post Posted: Tue 23 Apr, 2013, 21:07 
User avatar

User rating: 2
Joined: Mon 10 Dec, 2012, 22:04
Posts: 19
Location: India, Baroda
To Jforex Support,

I wanted to code a strategy using Awesome Oscillator. The basic strategy is like this -

If the color of the histogram is GREEN, a BUY position is opened.
If the color of the histogram is RED, a SELL position is opened.

I have coded the whole strategy except for this logical part coz I don't know how to code the condition for 'change of color'.

Please tell me how should I code this strategy.

B_Positive.


 
 Post subject: Re: Regarding Awesome Oscillator Post rating: 0   Post Posted: Wed 24 Apr, 2013, 09:26 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
See the part which detects the trend change:
https://www.dukascopy.com/wiki/#Create_Alert/Play_sound_on_indicator_trend_change
Here is another example for this:
https://www.dukascopy.com/wiki/#Strategy_Tutorial/Trade_According_to_SMA_Trend


 
 Post subject: Re: Regarding Awesome Oscillator Post rating: 0   Post Posted: Wed 24 Apr, 2013, 23:27 
User avatar

User rating: 2
Joined: Mon 10 Dec, 2012, 22:04
Posts: 19
Location: India, Baroda
To Jforex Support,

I referred to the links that you provided & tried to code the strategy. I used the awesome oscillator in the logic in the following way -

double[] awesome1 = indicators.awesome(instrument, selectedPeriod1, offerSide, appliedPrice, MAPeriod, MAType1, 1, MAType1, 0);

 if (awesome1[2] > awesome1[1] && awesome1[1] < awesome1[0]) {
            if (order == null || !order.isLong()) {
            closeOrder(order);
            order = submitOrder(OrderCommand.BUY, instrument);
            }
        }
       
        if (awesome1[2] < awesome1[1] && awesome1[1] > awesome1[0]) {
            if (order == null || order.isLong()) {
            closeOrder(order);
            order = submitOrder(OrderCommand.SELL, instrument);
            } 
         }

But I am not getting the expected result. I want to define the awesome oscillator with the time periods of 5 and 34. But in the definition for awesome oscillator, only one time period is included. How should I include the other one? Also, if there is any other mistake, please point it out.


B_Positive


 
 Post subject: Re: Regarding Awesome Oscillator Post rating: 0   Post Posted: Thu 25 Apr, 2013, 08:57 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Consider adding logging statements to see what execution paths get taken and why the strategy does not trade by your algorithm, see:
https://www.dukascopy.com/wiki/#IConsole/Logging_values


 
 Post subject: Re: Regarding Awesome Oscillator Post rating: 0   Post Posted: Thu 25 Apr, 2013, 20:22 
User avatar

User rating: 2
Joined: Mon 10 Dec, 2012, 22:04
Posts: 19
Location: India, Baroda
To Jforex Support,

I changed the definition of the awesome oscillator to the following :

double[] awesome1 = indicators.awesome(Instrument.EURUSD, Period.FIVE_MINS, OfferSide.BID, AppliedPrice.CLOSE, 5, MaType.SMA, 34, MaType.SMA, 0);


Also, I added logging statements to see what execution paths get taken as suggested by you and I got the following results :

Quote:
19:15:40 1-dimensional indicator result array: [0] 0.00000; [1] NaN; [2] -0.00015;


I do not understand what this means. Please explain. I have kept the rest of the logic same.

B_Positive.


 
 Post subject: Re: Regarding Awesome Oscillator Post rating: 0   Post Posted: Fri 26 Apr, 2013, 07:25 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Please provide full example strategy, explain what results you expect and what you receive instead.


 
 Post subject: Re: Regarding Awesome Oscillator Post rating: 0   Post Posted: Sat 27 Apr, 2013, 09:08 
User avatar

User rating: 2
Joined: Mon 10 Dec, 2012, 22:04
Posts: 19
Location: India, Baroda
To Jforex Support,

As asked by you, I am attaching the awesome oscillator strategy, its historical testing results, the logging values strategy, the diagram showing what I expect from the awesome oscillator strategy.

The historical testing results show no trade taken.

Image

B_Positive.


Attachments:
Awesome_Strategy.java [8.1 KiB]
Downloaded 341 times
LoggingValues.java [2.47 KiB]
Downloaded 336 times
Results.docx [190.31 KiB]
Downloaded 340 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.
 
 Post subject: Re: Regarding Awesome Oscillator Post rating: 0   Post Posted: Tue 30 Apr, 2013, 12:35 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
You should insert the logging statements inside your strategy such that you see which execution paths get taken and why they don't lead to submitting orders, for instance:
        double[] awesome1 = indicators.awesome(instrument, selectedPeriod, offerSide, appliedPrice, FasterMAPeriod, MAType1, SlowerMAPeriod, MAType1, 0);
       
        console.getOut().format("awesome=%s isBuy? %s isSell? %s is order null? %s is order long? %s",
                Arrays.toString(awesome1),
                awesome1[2] > awesome1[1] && awesome1[1] < awesome1[0],
                awesome1[2] < awesome1[1] && awesome1[1] > awesome1[0],
                order == null,
                order == null ? "-" : order.isLong()
                ).println();


 
 Post subject: Re: Regarding Awesome Oscillator Post rating: 0   Post Posted: Tue 30 Apr, 2013, 16:29 
User avatar

User rating: 2
Joined: Mon 10 Dec, 2012, 22:04
Posts: 19
Location: India, Baroda
To Dukascopy Support,

I inserted the logging statements in the loggingvalues strategy as suggested by you but while running the strategy it shows the following error :

2013-04-30 15:22:40 java.util.MissingFormatArgumentException: Format specifier 's' @ jforex.LoggingValues.onStart(LoggingValues.java:32)

Please tell me what this means.

Regards,

B_Positive.


 
 Post subject: Re: Regarding Awesome Oscillator Post rating: 0   Post Posted: Tue 30 Apr, 2013, 16:36 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
See:
https://www.google.lv/search?q=java.util.missingformatargumentexception+format+specifier+'s'
See more on formatting here:
https://docs.oracle.com/javase/tutorial/java/data/numberformat.html


 

Jump to:  

  © 1998-2026 Dukascopy® Bank SA
On-line Currency forex trading with Swiss Forex Broker - ECN Forex Brokerage,
Managed Forex Accounts, introducing forex brokers, Currency Forex Data Feed and News
Currency Forex Trading Platform provided on-line by Dukascopy.com