Guest wrote:
I guess the Jforex weekly pivot indicator is not correct due to the weekend candles issue. Why do you introduce the weekend candles in all JForex indicators by default??
Those filters don't affect the pivot values in this case, since in either case they are flat over the particular period. There are two factors why the prices do differ:
1) Majorly because Pivot points of your source take 21:00 as the day close time, whilst JForex takes 00:00. So effectively both show the same tendencies, but with a shift of 3 hours.
2) Difference in market scope contributes to minor fluctuations (usually around 1 to 2 pips) since the JForex price is bound to its Interbank market Marketplace scope.
Consider a simple strategy which shows why and how the pivot point values differ:
package jforex.strategies;
import java.text.DecimalFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.TimeZone;
import com.dukascopy.api.*;
public class PivotCalculationTest implements IStrategy {
private Instrument instrument = Instrument.EURUSD;
private IConsole console;
private IHistory history;
@SuppressWarnings("serial")
private final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss") {{setTimeZone(TimeZone.getTimeZone("GMT"));}};
public void onStart(IContext context) throws JFException {
this.console = context.getConsole();
this.history = context.getHistory();
print("start: " + this.getClass().getSimpleName());
getMarketHoursPivot("DAILY (day begins 21:00)","2011-06-26 21:00:00", "2011-06-27 21:00:00");
getMarketHoursPivot("WEEKLY (day begins 21:00)","2011-06-19 21:00:00", "2011-06-26 21:00:00");
getMarketHoursPivot("DAILY (day begins 00:00)","2011-06-27 00:00:00", "2011-06-28 00:00:00");
getMarketHoursPivot("WEEKLY (day begins 00:00)","2011-06-20 00:00:00", "2011-06-27 00:00:00");
}
private void getMarketHoursPivot(String comment, String marketOpenStr, String marketCloseStr) throws JFException{
try {
Date marketOpen = sdf.parse(marketOpenStr);
Date marketClose = sdf.parse(marketCloseStr);
List<ITick> ticks = history.getTicks(instrument, marketOpen.getTime(), marketClose.getTime());
double high = 0.0;
double low = 2.0;
double open = ticks.get(0).getBid();
double close = ticks.get(ticks.size() - 1).getBid();
for(ITick t: ticks){
if(t.getBid() > high)
high = t.getBid();
if(t.getAsk() < low)
low = t.getBid();
}
double pivot = (high + low + close) / 3;
print(comment + " Market hours " + sdf.format(marketOpen) + " - " + sdf.format(marketClose) + " pivot="
+ (new DecimalFormat("0.0000")).format( pivot) + " high=" + high + " low=" + low + " open=" + open + " close=" + close);
} catch (ParseException e) {
printErr(e);
}
}
public void onAccount(IAccount account) throws JFException {
}
public void onMessage(IMessage message) throws JFException {
}
public void onStop() throws JFException { }
public void onTick(Instrument instrument, ITick tick) throws JFException { }
public void onBar(Instrument instrument, Period period, IBar askBar, IBar bidBar) throws JFException { }
private void print(Object o){
console.getOut().println(o);
}
private void printErr(Object o){
console.getErr().println(o);
}
}