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.

How to get the difference between two prices in Pips?
 Post subject: How to get the difference between two prices in Pips? Post rating: 0   New post Posted: Tue 25 Jun, 2013, 22:59 
User avatar

User rating: 0
Joined: Tue 04 Sep, 2012, 06:35
Posts: 11
Location: Hungary,
I am having trouble determining the distance of two price levels in pips.

I tried to use the following line, which doesn't seem to work:

Math.abs(price1-price2)/Instrument.getPipValue

I have limited experience in programming, but I assume that the root of the problem is somewhere around the floating point values that are used. I have yet to find the solution though.

What I basically need can most likely found in the source code of the IOrder.getProfitLossInPips() method (the two prices being IOrder.getOpen and the price of the last tick), or the source code of the ruler gadget that can be activated in the trading platform by clicking the cross-shaped "Set Cursor Pointer" button.

Could somebody please provide a method for the task, or provide some guidelines for the implemetation?

Your help is very much appreciated.

Thank you!


 
 Post subject: Re: How to get the difference between two prices in Pips? Post rating: 0   New post Posted: Wed 26 Jun, 2013, 13:36 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
It is likely that the problem lies in formatting, see:
https://www.dukascopy.com/wiki/#IConsole/Print_formatted_numbers


 
 Post subject: Re: How to get the difference between two prices in Pips? Post rating: 0   New post Posted: Fri 28 Jun, 2013, 05:44 
User avatar

User rating: 0
Joined: Tue 04 Sep, 2012, 06:35
Posts: 11
Location: Hungary,
Thank you very much, formatting really did the trick.

However, it turned out that I would like to do a series of tasks to which the source code of IOrder.getProfitLossInPips and getProfitLossInUsd method would be of great help (I would like to be able to get the hypothetical profit/loss of an order or list of orders at a given price level. Basically, I would like to freely set the open price, amount and current price parameters, like: "If I had an order/group of orders here, what would be its/their profit/loss there?)

Of course the whole thing is doable without the mentioned source code, but it would save me from considerable amount of headache.

Thanks for your kind answer!


 
 Post subject: Re: How to get the difference between two prices in Pips? Post rating: 0   New post Posted: Fri 28 Jun, 2013, 06:49 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
rauschie wrote:
"If I had an order/group of orders here, what would be its/their profit/loss there?
See: https://www.dukascopy.com/wiki/#Order_Management/Position_aggregated_profit/loss


 

Jump to:  

  © 1998-2026 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