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.

wrong calculation MA on H1, H4, D
 Post subject: wrong calculation MA on H1, H4, D Post rating: 0   New post Posted: Fri 20 May, 2016, 15:24 
User avatar

User rating: 0
Joined: Tue 02 Jun, 2015, 07:37
Posts: 2
Location: Ukraine,
hello I'm cant understand why MA indicator calculating write normal value on timeframe smaller then H1, but on H1 and higer timeframe it gives wrong value.

@Configurable("defaultInstrument:")
public Instrument defaultInstrument = Instrument.EURUSD;
@Configurable("movingPeriod:")
public Period movingPeriod = Period.ONE_HOUR;
@Configurable("typeMA:")
public IIndicators.MaType typeMA = IIndicators.MaType.EMA;
@Configurable("typePriceMA:")
public IIndicators.AppliedPrice typePriceMA = IIndicators.AppliedPrice.CLOSE;
@Configurable("_MA_period:")
public int _MA_period = 40;
@Configurable("shiftMA:")
public int shiftMA = 0;

public double MA = 0;

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();
subscriptionInstrumentCheck(defaultInstrument);
}
public void onTick(Instrument Instrument, ITick tick) throws JFException {
if(Instrument == defaultInstrument){
MA = this.indicators.ma(defaultInstrument, movingPeriod, OfferSide.BID, typePriceMA, _MA_period, typeMA, shiftMA);
}
}


 
 Post subject: Re: wrong calculation MA on H1, H4, D Post rating: 0   New post Posted: Wed 25 May, 2016, 09:58 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
To test an indicator please open the request chart and run the attached strategy.


Attachments:
IndChartVsApi.java [16.18 KiB]
Downloaded 71 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: wrong calculation MA on H1, H4, D Post rating: 0   New post Posted: Fri 27 May, 2016, 12:01 
User avatar

User rating: 0
Joined: Tue 02 Jun, 2015, 07:37
Posts: 2
Location: Ukraine,
10:56:20 [0] 1.12147; [1] 1.12118; [2] 1.12103; [3] 1.12083; [4] 1.12065; [5] 1.12053; [6] 1.12045; [7] 1.12039; [8] 1.12031; [9] 1.12018; chart
10:56:20 [0] 1.12147; [1] 1.12118; [2] 1.12103; [3] 1.12083; [4] 1.12065; [5] 1.12053; [6] 1.12045; [7] 1.12039; [8] 1.12031; [9] 1.12018; API + extra inputs
10:56:20 [0] 1.12147; [1] 1.12118; [2] 1.12103; [3] 1.12083; [4] 1.12065; [5] 1.12053; [6] 1.12045; [7] 1.12039; [8] 1.12031; [9] 1.12018; API
10:56:20 EMA Line last 10 API values:
10:56:20 Chart vs API with long outputs - OK
10:56:20 Chart vs API outputs - OK
10:56:20 FeedDescriptor [dataType=TIME_PERIOD_AGGREGATION, instrument=EUR/USD, offerSide=Bid, period=4 Hours, filter=WEEKENDS] UTC
10:56:20 max difference between values: 0.0005
10:56:20 [0] 1.12147; [1] 1.12118; [2] 1.12103; [3] 1.12083; [4] 1.12065; [5] 1.12053; [6] 1.12045; [7] 1.12039; [8] 1.12031; [9] 1.12018; chart
10:56:20 [0] 1.12147; [1] 1.12118; [2] 1.12103; [3] 1.12083; [4] 1.12065; [5] 1.12053; [6] 1.12045; [7] 1.12039; [8] 1.12031; [9] 1.12018; API + extra inputs
10:56:20 [0] 1.12147; [1] 1.12118; [2] 1.12103; [3] 1.12083; [4] 1.12065; [5] 1.12053; [6] 1.12045; [7] 1.12039; [8] 1.12031; [9] 1.12018; API
10:56:20 EMA Line last 10 API values:
10:56:20 Chart vs API with long outputs - OK
10:56:20 Chart vs API outputs - OK
10:56:20 FeedDescriptor [dataType=TIME_PERIOD_AGGREGATION, instrument=EUR/USD, offerSide=Bid, period=4 Hours, filter=WEEKENDS] UTC
10:56:20 max difference between values: 0.0005
10:56:20 [0] 1.12147; [1] 1.12118; [2] 1.12103; [3] 1.12083; [4] 1.12065; [5] 1.12053; [6] 1.12045; [7] 1.12039; [8] 1.12031; [9] 1.12018; chart
10:56:20 [0] 1.12147; [1] 1.12118; [2] 1.12103; [3] 1.12083; [4] 1.12065; [5] 1.12053; [6] 1.12045; [7] 1.12039; [8] 1.12031; [9] 1.12018; API + extra inputs
10:56:20 [0] 1.12147; [1] 1.12118; [2] 1.12103; [3] 1.12083; [4] 1.12065; [5] 1.12053; [6] 1.12045; [7] 1.12039; [8] 1.12031; [9] 1.12018; API
10:56:20 EMA Line last 10 API values:
10:56:20 Chart vs API with long outputs - OK
10:56:20 Chart vs API outputs - OK
10:56:20 FeedDescriptor [dataType=TIME_PERIOD_AGGREGATION, instrument=EUR/USD, offerSide=Bid, period=4 Hours, filter=WEEKENDS] UTC
10:56:20 max difference between values: 0.0005
10:56:20 [0] 1.12147; [1] 1.12118; [2] 1.12103; [3] 1.12083; [4] 1.12065; [5] 1.12053; [6] 1.12045; [7] 1.12039; [8] 1.12031; [9] 1.12018; chart
10:56:20 [0] 1.11783; [1] 1.11761; [2] 1.11766; [3] 1.11759; [4] 1.11754; [5] 1.11762; [6] 1.11773; [7] 1.11787; [8] 1.11796; [9] 1.11792; API + extra inputs
10:56:20 [0] 1.11783; [1] 1.11761; [2] 1.11766; [3] 1.11759; [4] 1.11754; [5] 1.11762; [6] 1.11773; [7] 1.11787; [8] 1.11796; [9] 1.11792; API
10:56:20 EMA Line last 10 API values:
10:56:20 Chart vs API with long outputs - WARNING
10:56:20 Chart vs API outputs - ERROR
10:56:20 FeedDescriptor [dataType=TIME_PERIOD_AGGREGATION, instrument=EUR/USD, offerSide=Bid, period=4 Hours, filter=WEEKENDS] UTC
10:56:20 [0]1.1178317 [0]1.1214687
10:56:20 [0]1.1178317 [0]1.1214687
10:56:20 max difference between values: 0.0005
10:56:20 EMA Output Line DOUBLE
10:56:20 EMA Opt Input Time Period OTHER
10:56:20 EMA Input Price DOUBLE
10:56:20 FeedDescriptor [dataType=TIME_PERIOD_AGGREGATION, instrument=EUR/USD, offerSide=Bid, period=4 Hours, filter=WEEKENDS]

"this is what, strategy return;"


 
 Post subject: Re: wrong calculation MA on H1, H4, D Post rating: 0   New post Posted: Wed 15 Jun, 2016, 15:09 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
This is specific to EMA indicator because it is recursive - result depends on all of the previous input. The output of EMA indicator will be different depending on how many values are used to calculate it. Usually chart will have much more values and therefore resulting value can differ from the value computed by the strategy.


 

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