Dukascopy
 
 
Wiki JStore Search Login

Delay code
 Post subject: Delay code Post rating: 0   New post Posted: Mon 09 Jul, 2012, 03:30 
User avatar

User rating: 2
Joined: Fri 02 Mar, 2012, 22:08
Posts: 200
Location: New Zealand, Dunedin
Hi all

What is the easiest way to check that:-

1) the last trade was a loss (i.e. stopped out at the SL level)
2) no more trades are to be opened for the hour bar on which the loss trade was opened
3) maybe even no more trades until x hour bars have passed ?

If you could show me some simple code that would be great :)

Thanks


 
 Post subject: Re: Delay code Post rating: 1   New post Posted: Mon 09 Jul, 2012, 09:35 
User avatar

User rating: 94
Joined: Mon 06 Feb, 2012, 12:22
Posts: 357
Location: Portugal, Castelo Branco
Hi us_copiosus:

In my strategy this month i have something similar to what you want for liimit number of trades in a bar and time control. It's a starting point.
For loss control you can get the order profit or loss with order.getprofitinpips() or order.getprofitinvalue() (or something like that see javadoc).

I hope that helps

Trade well and prospers in your way

JL


 
 Post subject: Re: Delay code Post rating: 0   New post Posted: Tue 10 Jul, 2012, 00:30 
User avatar

User rating: 2
Joined: Fri 02 Mar, 2012, 22:08
Posts: 200
Location: New Zealand, Dunedin
Hi jlongo

thank you for your advice..................

I have utilized a boolean variable which is switched to false, once an order is submitted
In the OnBar method I switch it back to true providing it is my instrument and the period is one hour

However, on the historic tester - I still have multiple orders opening on the same hourly bar
Not sure what is wrong :)


 
 Post subject: Re: Delay code Post rating: 1   New post Posted: Tue 10 Jul, 2012, 01:17 
User avatar

User rating: 94
Joined: Mon 06 Feb, 2012, 12:22
Posts: 357
Location: Portugal, Castelo Branco
Hi us_copiosus:

Have you done the filter correctly ?
The variable is only set to true in onBar method ? or anywhere else?
On order trigger are you validating this variable if true before submiting the order?

This are the only problems i see in this approach.

Try to debug printing out the variable value at all stages with console.getOut().println("stagexxx:" + variable) for example and see when and where the variable turns true.

I hope that helps.

Trade well and prospers in your way.

JL


 
 Post subject: Re: Delay code Post rating: 0   New post Posted: Tue 10 Jul, 2012, 05:30 
User avatar

User rating: 2
Joined: Fri 02 Mar, 2012, 22:08
Posts: 200
Location: New Zealand, Dunedin
Hi

The variable is only set to true in OnBar method providing the instrument is my instrument and the period is 1 hour.
On order trigger - I am validating this variable is true before submitting order
Immediately on next line I switch variable to false

However, it still opens multiple orders on the same hour bar
for example.............

us_copiosus10 4.0 SELL 0.96807 0.97009 -8330.58 -20.2 2011-08-04 09:07:03 2011-08-04 09:33:33
us_copiosus11 4.0 SELL 0.96993 0.97196 -8355.54 -20.3 2011-08-04 09:33:34 2011-08-04 09:48:40
us_copiosus12 4.0 SELL 0.97181 0.97384 -8339.41 -20.3 2011-08-04 09:48:40 2011-08-04 10:08:25

so I am still confused ???


 
 Post subject: Re: Delay code Post rating: 1   New post Posted: Tue 10 Jul, 2012, 09:29 
User avatar

User rating: 94
Joined: Mon 06 Feb, 2012, 12:22
Posts: 357
Location: Portugal, Castelo Branco
Hi us_copiosus:

Have you debuged when the variable becomes true ?

I assume you have the trigger in onTick()

Do something like:

onTick() {

if (variable){

//trigger code here

variable = false
//debug output here
}

}

onBar(){
//filter here
variable = true;
//debug output here
}

To help you more i have to see the code.

JL


 
 Post subject: Re: Delay code Post rating: 0   New post Posted: Tue 10 Jul, 2012, 21:52 
User avatar

User rating: 2
Joined: Fri 02 Mar, 2012, 22:08
Posts: 200
Location: New Zealand, Dunedin
Hi again

I have it working now :)

problem was code

many thanks again


 

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