Dukascopy
 
 
Wiki JStore Search Login

Attention! Read the forum rules carefully before posting a topic.

    Submit JForex API bug reports in this forum only.
    Submit Converter issues in Converter Issues.
    Off topics are strictly forbidden.

Any topics which do not satisfy these rules will be deleted.

Alligator Indicator in Historical Tester
 Post subject: Alligator Indicator in Historical Tester Post rating: 0   New post Posted: Sun 02 Feb, 2014, 17:36 

User rating: 0
Joined: Tue 22 Nov, 2011, 12:47
Posts: 130
Location: United States,
hi,

I'm trying to run a simple Strategy using the alligator indicator in the historical tester. For some reason the values I get are not identical to the chart's alligator indicator.

I'm using for the Alligator the following params: Jaw:13, Teeth:8, Lips:5
Historical Tester values:
Bid Side
4ticks at OHLC
1Min Bars
EURUSD
date range 2014.01.30 - 2014.01.31

Here is my code:

package jforex;



import java.text.SimpleDateFormat;
import java.util.TimeZone;

import com.dukascopy.api.Configurable;
import com.dukascopy.api.Filter;
import com.dukascopy.api.IAccount;
import com.dukascopy.api.IBar;
import com.dukascopy.api.IConsole;
import com.dukascopy.api.IContext;
import com.dukascopy.api.IEngine;
import com.dukascopy.api.IHistory;
import com.dukascopy.api.IIndicators;
import com.dukascopy.api.IIndicators.AppliedPrice;
import com.dukascopy.api.IMessage;
import com.dukascopy.api.IOrder;
import com.dukascopy.api.IStrategy;
import com.dukascopy.api.ITick;
import com.dukascopy.api.Instrument;
import com.dukascopy.api.JFException;
import com.dukascopy.api.OfferSide;
import com.dukascopy.api.Period;

public class AlligatorStrategy implements IStrategy {
   private IEngine engine;
   private IConsole console;
   private IHistory history;
   private IIndicators indicators;
   private int counter =0;
   private double [] alligator;
   
   private IOrder order = null;

   @Configurable("Instrument")
   public Instrument selectedInstrument = Instrument.EURUSD;
   @Configurable("Period")
   public Period selectedPeriod = Period.ONE_MIN;
   
   public Filter indicatorFilter = Filter.NO_FILTER;
   
   private SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss.SSS");
   

   public void onStart(IContext context) throws JFException {
      this.engine = context.getEngine();
      this.console = context.getConsole();
      this.history = context.getHistory();
      this.indicators = context.getIndicators();
      sdf.setTimeZone(TimeZone.getTimeZone("GMT"));
   }

   public void onAccount(IAccount account) throws JFException {
   }

   public void onMessage(IMessage message) throws JFException {
   }

   public void onStop() throws JFException {
      for (IOrder order : engine.getOrders()) {
         engine.getOrder(order.getLabel()).close();
      }
   }

   public void onTick(Instrument instrument, ITick tick) throws JFException {
   
      if (!instrument.equals(selectedInstrument)) {
         return;
      }
      
   }   

   public void onBar(Instrument instrument, Period period, IBar askBar, IBar bidBar) throws JFException {
      if (!instrument.equals(selectedInstrument) || !Period.ONE_MIN.equals(period)) {
         return;
      }
      
      alligator = indicators.alligator(instrument, Period.ONE_MIN, OfferSide.BID, AppliedPrice.CLOSE , 13, 8, 5, 1);

      print("Period:%s, Time:%s, alligator[%f,%f,%f]",period,sdf.format(bidBar.getTime()),alligator[0],alligator[1],alligator[2]);
    }

   private void print (String format, Object...args){
      print(String.format(format, args));
   }

   public void print(String message) {
      console.getOut().println(message);
   }

}


Please note the below screen shot - you can see that the numbers are not accurate. Can you please advice how to fix that.
Image


Attachments:
File comment: alligator_historical_tester
Alligator_Historical_Tester.png [80.44 KiB]
Downloaded 201 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: Alligator Indicator in Historical Tester Post rating: 1   New post Posted: Mon 03 Feb, 2014, 12:52 
User avatar

User rating: 164
Joined: Mon 08 Oct, 2012, 10:35
Posts: 676
Location: NetherlandsNetherlands
Hi,

There is a wiki page that contains the most common mistakes about indicator data on chart vs. strategy. Take look on it:
https://www.dukascopy.com/wiki/#Indicato ... _checklist
It is very often the Filter difference, or the OfferSide.


 

Jump to:  

  © 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