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.

Advice on daily target
 Post subject: Advice on daily target Post rating: 0   New post Posted: Fri 22 Oct, 2010, 11:04 

User rating: 0
Joined: Wed 07 Jul, 2010, 17:54
Posts: 10
Hi,

could someone advice any way how to write a code for a daily target? For example:

1. start trading at 6 am
2. if current equity (during the day) is higher 0.1% than yesterday at 5pm, close all positions and stop trading until 6 am next day.
3. if equity does not reach 0.1% daily target, just stop trading at 5 pm.

Thank you!


 
 Post subject: Re: Advice on daily target Post rating: 0   New post Posted: Fri 22 Oct, 2010, 13:07 

User rating: 0
Joined: Tue 27 Jul, 2010, 20:57
Posts: 49
I could think of a straight forward method:

In onTick method of your strategy you would check for the tick's time (is it past 6am and not past 5pm?) and equity vs equity of yesterday at 5pm (save equity value at 5pm for comparison at the next day) - and, accordingly, trade or not trade.

For handling date/time you could look here: https://javatechniques.com/blog/dateform ... -examples/

Also of course you could implement a separate thread that will monitor date / time / equity and set/clear e.g. trade_permit flag. Then, in your trading code, you only would need to check trade_permit flag.


 

Jump to:  

cron
  © 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