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.

buylimit selllimit and historical tester
 Post subject: buylimit selllimit and historical tester Post rating: 0   New post Posted: Mon 27 May, 2013, 19:22 
User avatar

User rating: 0
Joined: Wed 03 Apr, 2013, 13:03
Posts: 17
Location: United States, Jersey City
All I want to do is set a buylimit and a sell limit order 20 pips above and below the current price for eurusd at 4 am gmt time. But when I write the code and run it in the historical tester it doesn't behave correctly. It opens the orders regardless of the price I set. It opens both sides instead of setting the orders and if the price moves in that direction then it opens the orders. What am I doing wrong?

Basically, the question is how do I do this?
Thanks


 
 Post subject: Re: buylimit selllimit and historical tester Post rating: 0   New post Posted: Mon 27 May, 2013, 20:58 
User avatar

User rating: 98
Joined: Mon 23 Jul, 2012, 02:02
Posts: 656
Location: United States, Durham, NC
Hey, man.

Well, in the historical data tester you're working off "virtual time", so in onTick you want to keep track of the ITick.getTime() (inherited from the super interface ITimedData) so you know what "time" it is.

So you need to "schedule" the action and on every tick see whether you are at the right time to do what you need to do, and place the order(s).

But, remember you're working on a "virtual timeline" in the historical tester, so don't use System time in any way for this purpose.

// in onTick
// keep track of time
now = tick.getTime(); // now is defined at global scope as long type
bidPrice = tick getBid();
askPrice = tick.getAsk(); // also defined at global scope as double type
// so on each tick we have the most recent time, and the inside bid/ask prices


You'll need to use Java Calendar classes, I suppose to convert "time in milliseconds since 1970" to a meaningful GMT day time or whatever you need for that... :)

You could post your code or relevant code fragments and we can certainly give you some tips.

HyperScalper

(If you need help, let me know.)


 
 Post subject: Re: buylimit selllimit and historical tester Post rating: 0   New post Posted: Tue 28 May, 2013, 07:31 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
For setting price distance in pips see (you can also download from there ConditionalOrder.java):
https://www.dukascopy.com/wiki/#Set_Conditional_Order/Stop_Order
For working with date and time see:
https://www.dukascopy.com/wiki/#Customize_trading_hours


 

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