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.

Please provide example of MA indicator
 Post subject: Please provide example of MA indicator Post rating: 0   New post Posted: Mon 16 Feb, 2009, 07:18 

User rating: 0
Joined: Mon 22 Dec, 2008, 13:00
Posts: 17
Can someone please provide an example of how to correctly use the MA indicator in Dukascopy? I just want to be able to calculate the result. Does this look right?

public IIndicators indicators = null;
......
......
double smaresult = indicators.ma(instrument, Period.FIFTEEN_MINS , OfferSide.BID, IIndicators.AppliedPrice.MEDIAN_PRICE, 10, IIndicators.MaType.SMA, 0);


 
 Post subject: Re: Please provide example of MA indicator Post rating: 0   New post Posted: Mon 16 Feb, 2009, 16:03 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Yes, it does look right


 
 Post subject: Re: Please provide example of MA indicator Post rating: 0   New post Posted: Tue 17 Feb, 2009, 01:07 

User rating: 0
Joined: Mon 22 Dec, 2008, 13:00
Posts: 17
Yup, I managed to get it to work. Just had to include a line inside OnStart():

//declared at the top
public IIndicators indicators = null;

public void onStart(IContext context) throws JFException {
...
this.indicators = context.getIndicators();
...
...
}

public void onTick(Instrument instrument, ITick tick) throws JFException { // or wherever else
...
double smaresult = indicators.ma(instrument, Period.FIFTEEN_MINS , OfferSide.BID, IIndicators.AppliedPrice.MEDIAN_PRICE, 10, IIndicators.MaType.SMA, 0);
...
}


 
 Post subject: Re: Please provide example of MA indicator Post rating: 0   New post Posted: Fri 20 Feb, 2009, 14:33 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
absolutely right. Think about onstart as initialising function where you setup all required variables.


 

Jump to:  

cron
  © 1998-2024 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