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.

Some technical questions
 Post subject: Some technical questions Post rating: 0   New post Posted: Sat 09 Jun, 2018, 04:30 

User rating: 3
Joined: Sat 09 Jun, 2018, 03:18
Posts: 24
Location: China,
Please help:
1.indicatorResult = indicators.calculateIndicator(selectedInstrument, Period.TEN_MINS, new OfferSide[] {OfferSide.BID},
"SMA", new IIndicators.AppliedPrice[] {IIndicators.AppliedPrice.CLOSE}, new Object[] {30}, 0);

Does it mean Jforex use 30 candles to calculate SMA based on candle's closed price(every hour )?


2.How to execute my strategy OnCandle instead of Ontick?(please show me the code or give me specified API URL)

3.How to get the closed price of previous Candles?(code or API)

Thanks a lot!


 
The Best Answer  Post subject: Re: Some technical questions Post rating: 0   New post Posted: Mon 11 Jun, 2018, 13:04 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Bletherfeng wrote:
Please help:
1.indicatorResult = indicators.calculateIndicator(selectedInstrument, Period.TEN_MINS, new OfferSide[] {OfferSide.BID},
"SMA", new IIndicators.AppliedPrice[] {IIndicators.AppliedPrice.CLOSE}, new Object[] {30}, 0);

Does it mean Jforex use 30 candles to calculate SMA based on candle's closed price(every hour )?


2.How to execute my strategy OnCandle instead of Ontick?(please show me the code or give me specified API URL)

3.How to get the closed price of previous Candles?(code or API)

Thanks a lot!


1. Yes, SMA will be calculated based on last 30 candles closed price at your specified period.(Period.TEN_MINS in your code sample).
2. Here is a good example of how to use onBar method: https://www.dukascopy.com/wiki/en/development/get-started-api/use-in-jforex/strategy-tutorial#create-the-logic-in-the-onbar-method
3. https://www.dukascopy.com/wiki/en/development/strategy-api/historical-data/history-bars For example, if you use Bar by Shift method, shift with 0 value will always refer to current candle, 1 - previous fully formed candle, etc.
IHistory history = context.getHistory();
double firstHistoryBarClosePrice = history.getBar(myInstrument, myPeriod, OfferSide.BID, 1).getClose();
double secondHistoryBarClosePrice = history.getBar(myInstrument, myPeriod, OfferSide.BID, 2).getClose();


 
 Post subject: Re: Some technical questions Post rating: 0   New post Posted: Mon 11 Jun, 2018, 14:04 

User rating: 3
Joined: Sat 09 Jun, 2018, 03:18
Posts: 24
Location: China,
Thanks a lot,It is really useful!


 

Jump to:  

  © 1998-2025 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