Hi oktar,
oktar wrote:
Is it possible?
I guess you're trying to code Tony's strategy from FF..
I also tried to implement that strategy... in this way below
atteched a code snippet with the core function
@Configurable("TIMEFRAME in seconds")
public int TIMEFRAME = 5 ;
@Configurable("Max Spread")
public double _maxSpread = 1.5 ;
@Configurable("Max Slippage")
public double _maxSlippage = 2 ;
@Configurable("Bar Height")
public double _barHeight = 8 ;
public void onTick(Instrument instrument, ITick tick) throws JFException {
double spread = (tick.getAsk() - tick.getBid()) / instrument.getPipValue() ;
Date d = new Date(tick.getTime());
Calendar calendar = Calendar.getInstance( TimeZone.getTimeZone("GMT") );
calendar.setTime(d);
calendar.add(Calendar.SECOND, -TIMEFRAME );
List<ITick> ticksList = history.getTicks(instrument,calendar.getTimeInMillis() ,tick.getTime() );
/*
//FOR DEBUGGING
for(int i=0;i<ticksList.size();i++)
{
print(" --- ticksList.size() " + ticksList.size() ) ;
print(" tick index " + i + " -- time " + (new Date( ((ITick)ticksList.get(i)).getTime() ) ).toString() );
}
*/
if(ticksList.size()>1)
{
ITick firstTick = (ITick)ticksList.get(0);
ITick lastTick = (ITick)ticksList.get(ticksList.size()-1);
double candleHeight = (lastTick.getBid()-firstTick.getBid()) / instrument.getPipValue();
if(spread<=_maxSpread && java.lang.Math.abs(candleHeight)>=_barHeight )
{
if(candleHeight>0)
{
this.console.getOut().println(" potential buy at time " + (new Date( firstTick.getTime() ) ).toGMTString() );
//openBuyOrder(instrument);
}else
{
this.console.getOut().println(" potential sell at time " + (new Date( firstTick.getTime() ) ).toGMTString() );
//openSellOrder(instrument);
}
}
}
}
hope that helps,
chriz [aka IndianaPips]