Calculate difference in pips between 2 prices

Created at 27 Mar 2018, 14:31
How’s your experience with the cTrader Platform?
Your feedback is crucial to cTrader's development. Please take a few seconds to share your opinion and help us improve your trading experience. Thanks!
CT

ctid442355

Joined 27.03.2018

Calculate difference in pips between 2 prices
27 Mar 2018, 14:31


Hi,

What code do I need to use to get the difference in pips between 2 different prices?  I searched for an answer but couldn't find one.

Thanks in advance


@ctid442355
Replies

PanagiotisCharalampous
27 Mar 2018, 14:34

Dear Trader,

Thanks for posting in our forum. What you need to do is to divide the difference by Symbol.PipSize. See below

var differenceInPips = Math.Abs((Price1 - Price2) / Symbol.PipSize);

Let me know if this helps you.

Best Regards,

Panagiotis


@PanagiotisCharalampous

ctid442355
27 Mar 2018, 16:48

Wow, thanks that was a quick answer!  Does that work for brokers that use 4 decimal places as well as 5?

 

Dave


@ctid442355

PanagiotisCharalampous
28 Mar 2018, 09:35

Hi Dave,

Yes it does.

Best Regards

Panagiotis


@PanagiotisCharalampous