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.

Entry price is not ended on 0.5 or 0.1
 Post subject: Entry price is not ended on 0.5 or 0.1 Post rating: 0   New post Posted: Tue 10 Nov, 2009, 12:33 

User rating: 0
Joined: Fri 09 Oct, 2009, 11:09
Posts: 4
The last question, I hope, for this strategie.

I have problems when the entry price is not ended on 0.5 or 0. I wanted to use math.floor (x) in order to round the entry price and set a right stop loss price. But the compiler has problems with it. Is there any other function to round variables?

Thanks


 
 Post subject: Re: Entry price is not ended on 0.5 or 0.1 Post rating: 0   New post Posted: Wed 11 Nov, 2009, 13:19 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
A Dukascopy API doesn't provide any specific math methods, but Java does!
Please look at the java.lang.Math class which has all needed rounding functions.
Math must be written starting with capital letter.
Here is a function, that rounds the value till half pip
public static double round05Pips(double value) {
  int pipsMultiplier = value <= 20 ? 10000 : 100;
  int rounded = (int) (value * pipsMultiplier * 10 + 0.5);
  rounded *= 2;
  rounded = (int) (((double) rounded) / 10d + 0.5d);
  value = ((double) rounded) / 2d;
  value /= pipsMultiplier;
  return value;
 }


 

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