|
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.
Save the no. of times a market level has been breached in a variable |
JimmyHowl8
|
Post subject: Save the no. of times a market level has been breached in a variable |
Post rating: 0
|
Posted: Tue 16 Oct, 2012, 13:22
|
|
User rating: 0
Joined: Tue 16 Oct, 2012, 12:23 Posts: 40
|
To Dukascopy Support, Could you plz tell me how to save the no. of times a market level has been breached in a variable? For example, if the EURUSD goes above the value of 1.3200 once and then goes below it and then again goes above it, it means it has breached it twice. So the variable should store 2. Thanks. Jimmy.
|
|
|
|
 |
API Support
|
Post subject: Re: Save the no. of times a market level has been breached in a variable |
Post rating: 0
|
Posted: Tue 16 Oct, 2012, 13:36
|
|
User rating: ∞
Joined: Fri 31 Aug, 2007, 09:17 Posts: 6139
|
|
|
|
 |
JimmyHowl8
|
Post subject: Re: Save the no. of times a market level has been breached in a variable |
Post rating: 0
|
Posted: Tue 16 Oct, 2012, 13:49
|
|
User rating: 0
Joined: Tue 16 Oct, 2012, 12:23 Posts: 40
|
I don't want to retrieve the value of ticks by time interval but since the time a particular trade was opened. For example, if a EURUSD trade was opened at 1.3200, I want to check how many times the level of 1.3225 has been breached since then. Could you plz tell me how to do that?
|
|
|
|
 |
API Support
|
Post subject: Re: Save the no. of times a market level has been breached in a variable |
Post rating: 0
|
Posted: Tue 16 Oct, 2012, 13:54
|
|
User rating: ∞
Joined: Fri 31 Aug, 2007, 09:17 Posts: 6139
|
then you need to retrieve the ticks in a way similar to this: List<ITick> ticks = history.getTicks(Instrument.EURUSD, order.getFillTime(), lastTick.getTime());
|
|
|
|
 |
JimmyHowl8
|
Post subject: Re: Save the no. of times a market level has been breached in a variable |
Post rating: 0
|
Posted: Tue 16 Oct, 2012, 15:09
|
|
User rating: 0
Joined: Tue 16 Oct, 2012, 12:23 Posts: 40
|
When I try to define the value of ticks as
List<ITick> ticks = history.getTicks(Instrument.EURUSD, order.getFillTime(), lastTick.getTime());
it show the following errors :
List cannot be resolved to a type
and
lastTick cannot be resolved
Do I need to define something else before I define ticks?
|
|
|
|
 |
API Support
|
Post subject: Re: Save the no. of times a market level has been breached in a variable |
Post rating: 0
|
Posted: Tue 16 Oct, 2012, 15:17
|
|
User rating: ∞
Joined: Fri 31 Aug, 2007, 09:17 Posts: 6139
|
Download the strategy which is attached to the wiki article and run it to see how it works. Then adjust it to work with your selected interval.
|
|
|
|
 |
JimmyHowl8
|
Post subject: Re: Save the no. of times a market level has been breached in a variable |
Post rating: 0
|
Posted: Tue 16 Oct, 2012, 15:51
|
|
User rating: 0
Joined: Tue 16 Oct, 2012, 12:23 Posts: 40
|
I want to know how many times a particular level has been breached since the opening of a trade and not as per the time interval. After that I want to store that number in a variable. How should I change the following code to do that? private void getTicksByTimeInterval() throws JFException{ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS") {{setTimeZone(TimeZone.getTimeZone("GMT"));}}; ITick lastTick = history.getLastTick(Instrument.EURUSD); List<ITick> ticks = history.getTicks(Instrument.EURUSD, lastTick.getTime() - 10 * 1000, lastTick.getTime()); int last = ticks.size() - 1; console.getOut().println(String.format( "Tick count=%s; Latest bid price=%.5f, time=%s; Oldest bid price=%.5f, time=%s", ticks.size(), ticks.get(last).getBid(), sdf.format(ticks.get(last).getTime()), ticks.get(0).getBid(), sdf.format(ticks.get(last).getTime()))); }
|
|
|
|
 |
API Support
|
Post subject: Re: Save the no. of times a market level has been breached in a variable |
Post rating: 0
|
Posted: Tue 16 Oct, 2012, 16:40
|
|
User rating: ∞
Joined: Fri 31 Aug, 2007, 09:17 Posts: 6139
|
|
|
|
 |
JimmyHowl8
|
Post subject: Re: Save the no. of times a market level has been breached in a variable |
Post rating: 0
|
Posted: Thu 18 Oct, 2012, 13:42
|
|
User rating: 0
Joined: Tue 16 Oct, 2012, 12:23 Posts: 40
|
An error is generated for
package jforex.data;
that it expects 'import' instead of 'package' and when I write
import jforex.data;
again an error is generated. Plz tell me what should I write instead of it?
|
|
|
|
 |
API Support
|
Post subject: Re: Save the no. of times a market level has been breached in a variable |
Post rating: 0
|
Posted: Thu 18 Oct, 2012, 14:07
|
|
User rating: ∞
Joined: Fri 31 Aug, 2007, 09:17 Posts: 6139
|
|
|
|
 |
JimmyHowl8
|
Post subject: Re: Save the no. of times a market level has been breached in a variable |
Post rating: 0
|
Posted: Thu 18 Oct, 2012, 15:02
|
|
User rating: 0
Joined: Tue 16 Oct, 2012, 12:23 Posts: 40
|
In the example that you provided in your last to last reply - https://www.dukascopy.com/wiki/#History_ ... ce_dynamic, in the code it is package jforex.data; But when I write that in my strategy, an error is generated. Again, when I write import jforex.data; another error is generated. Here is the full error message. 2012-10-18 13:53:17 The import jforex.data cannot be resolved 2012-10-18 13:53:17 ^^^^^^^^^^^ 2012-10-18 13:53:17 import jforex.data; 2012-10-18 13:53:17 1. ERROR in C:\Users\Mankind\AppData\Local\Temp\jfxide\tmp\compile\Strategy1.java (at line 2) 2012-10-18 13:52:48 Syntax error on token "package", import expected 2012-10-18 13:52:48 ^^^^^^^ 2012-10-18 13:52:48 package jforex.data; 2012-10-18 13:52:48 1. ERROR in C:\Users\Mankind\AppData\Local\Temp\jfxide\tmp\compile\Strategy1.java (at line 2) Can I substitute package jforex.data with something else?
|
|
|
|
 |
API Support
|
Post subject: Re: Save the no. of times a market level has been breached in a variable |
Post rating: 0
|
Posted: Thu 18 Oct, 2012, 15:21
|
|
User rating: ∞
Joined: Fri 31 Aug, 2007, 09:17 Posts: 6139
|
|
|
|
 |
|
Pages: [
1
]
|
|
|
|
|