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.

only return positive value
 Post subject: only return positive value Post rating: 0   New post Posted: Fri 24 Aug, 2012, 13:28 

User rating: 1
Joined: Wed 07 Mar, 2012, 05:56
Posts: 101
Location: New CaledoniaNew Caledonia
hello support,

  
   double stopLossDiff = price - stopLossPrice;
   takeProfitPrice = price + stopLossDiff * takeProfitMult;

   double stopLossPips = stopLossDiff / instrument.getPipValue();


in this part of my code, i define my stopLossPips, but this double return positive or negative value(depend if it's the sell or buy order).

but i would like that double only return a positive value.
can you explain me how to make it?

thanks in advance.


 
 Post subject: Re: only return positive value Post rating: 0   New post Posted: Fri 24 Aug, 2012, 13:38 
User avatar

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

ou can use Math.abs(double) to return always the positive value.

Hope that helps

JL


 
 Post subject: Re: only return positive value Post rating: 0   New post Posted: Fri 24 Aug, 2012, 13:49 

User rating: 1
Joined: Wed 07 Mar, 2012, 05:56
Posts: 101
Location: New CaledoniaNew Caledonia
hi jl,

yes, it helps me :) .

thanks JL.


 

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