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.

Run multiple times onTick method for one tick
 Post subject: Run multiple times onTick method for one tick Post rating: 0   New post Posted: Tue 01 May, 2012, 22:25 
User avatar

User rating: 1
Joined: Tue 01 May, 2012, 22:05
Posts: 17
Location: United Kingdom, London
Hello,

I am looking for a way to make the onTick method run multiple times (every 10th of a second instead of every second when a new tick comes).
If the end of the onTick method is reached, I want it to start over with the same tick, until there is a new tick.
My onTick methode doesn't take very long to run.

Kind Regards Stephane


 
 Post subject: Re: Run multiple times onTick method for one tick Post rating: 0   New post Posted: Wed 02 May, 2012, 09:35 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Consider implementing your onTick logic in another method and then call it from the onTick method on the same tick 10 times.


 
 Post subject: Re: Run multiple times onTick method for one tick Post rating: 2   New post Posted: Wed 02 May, 2012, 17:51 

User rating: 4
Joined: Mon 19 Sep, 2011, 09:55
Posts: 29
Location: Germany,
Does this actually make any sense? What is the purpose of this seemingly odd logic? Because likely there is a better way to accomplish whatever you want to accomplish..


 
 Post subject: Re: Run multiple times onTick method for one tick Post rating: 0   New post Posted: Wed 02 May, 2012, 22:44 
User avatar

User rating: 1
Joined: Tue 01 May, 2012, 22:05
Posts: 17
Location: United Kingdom, London
I am making a strategy, where you need to draw 3 ray lines. These lines represent the order(buy, sell, limit or stop), take profit and the stop loss.
In my money management I calculate the width between those lines, this shows me what my risk ratio is.
Because onTick runs only when a new tick comes, I have to wait on a tick when I move my lines to see my new risk ratio.
The program can also automatically draw a buffer(ray)line, like 10 pips from the order line where the program will submit an pending order.
If I move the order line, the buffer line will only be redrawn after a tick. It would be nice if this happens instantly.

A solution for this is nice to have, but I can live with the "wait".

This isn't exactly a automated strategy, but now I just need to place 3 lines and the program does the rest.
It automatically changes the order settings, when you think the market is going up, I draw my ray lines in that direction and every tick will than increase the take profit and stop loss.
This way I stay in the trade until there is a breach of a ray line.


 
 Post subject: Re: Run multiple times onTick method for one tick Post rating: 0   New post Posted: Thu 03 May, 2012, 09:36 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
You can follow the order price change in onMessage callback method (in your case you would need to implement line moving logic on ORDER_CHANGED_OK message and compare the IOrder.getOpenPrice with the previous open price):
https://www.dukascopy.com/wiki/#Manage_Order_State/Use_onMessage
https://www.dukascopy.com/wiki/#Order_state

Alternatively you can schedule a task to be executed at a fixed time interval:
https://www.dukascopy.com/wiki/#Threading/Scheduled_asynchronous_execution


 
 Post subject: Re: Run multiple times onTick method for one tick Post rating: 2   New post Posted: Thu 03 May, 2012, 10:25 

User rating: 4
Joined: Mon 19 Sep, 2011, 09:55
Posts: 29
Location: Germany,
I think you can implement event listeners for chart objects (IChartObject.setChartObjectListener); there you would racalculate what ever is necessary on demand (when you access a chart object - like move)?


 
 Post subject: Re: Run multiple times onTick method for one tick Post rating: 0   New post Posted: Thu 03 May, 2012, 17:37 
User avatar

User rating: 1
Joined: Tue 01 May, 2012, 22:05
Posts: 17
Location: United Kingdom, London
Thanks the event listener was just the thing I needed.


 

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