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.

History testing on custom Preriod like 5 seconds?
 Post subject: History testing on custom Preriod like 5 seconds? Post rating: 0   New post Posted: Tue 22 Feb, 2011, 20:23 

User rating: 0
Joined: Fri 15 Jan, 2010, 13:58
Posts: 8
Is it possible?


 
 Post subject: Re: History testing on custom Preriod like 5 seconds? Post rating: 0   New post Posted: Wed 23 Feb, 2011, 09:56 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Hi,
No, it is not possible.


 
 Post subject: Re: History testing on custom Preriod like 5 seconds? Post rating: 0   New post Posted: Wed 23 Feb, 2011, 22:50 
User avatar

User rating: 2
Joined: Tue 17 May, 2011, 16:35
Posts: 10
Location: ItalyItaly
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]


 

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