• Home
  • Forums
  • Trades
  • News
  • Calendar
  • Market
  • Brokers
  • Login
  • Join
  • User/Email: Password:
  • 7:43am
Menu
  • Forums
  • Trades
  • News
  • Calendar
  • Market
  • Brokers
  • Login
  • Join
  • 7:43am
Sister Sites
  • Metals Mine
  • Energy EXCH
  • Crypto Craft

Options

Bookmark Thread

First Page First Unread Last Page Last Post

Print Thread

Similar Threads

Seeking Script to draw line X pips above + below current price 2 replies

Draw horizontal line X pips from current period open price 0 replies

Indicator that plots a line x pips above and below current price 3 replies

need help w/simple indicator to subtract bear candles from bulls 0 replies

EA Builder won't add/subtract indicator values 0 replies

  • Platform Tech
  • /
  • Reply to Thread
  • Subscribe
Tags: FX Math - How to add or subtract pips from current price
Cancel

FX Math - How to add or subtract pips from current price

  • Post #1
  • Quote
  • First Post: Dec 15, 2010 1:50pm Dec 15, 2010 1:50pm
  •  skozyuk
  • | Joined Feb 2009 | Status: Member | 147 Posts
Hi Guys,

I'm writing a function that takes as parameters pair, current price, pips and returns price by adding or subtracting specified pip amount to/from quote price.

I understand the special cases like JPY need separate handling, however what is the general formula to find new price based on current price +/- pips?

I'm making a custom order entry calculator, that will help me adjust SL and TP based on PIP amount by constantly recalculating TP and SL prices.
  • Post #2
  • Quote
  • Dec 15, 2010 3:22pm Dec 15, 2010 3:22pm
  •  Aja
  • | Joined Nov 2009 | Status: Member | 316 Posts
xecn=1; if(Digits==5||Digits==3){xecn=10;} //ADJUST for 4/5 digit - I usually make this a global level var so I can use in entire EA

//To Add Pips
Bid=Bid+(pipadjust*Point*xecn); //Will Add Whole Pips NOT Pippetts

//To Subtract Pips
Bid=Bid-(pipadjust*Point*xecn); //Will Subtract Whole Pips NOT Pippetts
 
 
  • Post #3
  • Quote
  • Dec 15, 2010 3:27pm Dec 15, 2010 3:27pm
  •  skozyuk
  • | Joined Feb 2009 | Status: Member | 147 Posts
Quoting Aja
Disliked
xecn=1; if(Digits==5||Digits==3){xecn=10;} //ADJUST for 4/5 digit - I usually make this a global level var so I can use in entire EA

//To Add Pips
Bid=Bid+(pipadjust*Point*xecn); //Will Add Whole Pips NOT Pippetts

//To Subtract Pips
Bid=Bid-(pipadjust*Point*xecn); //Will Subtract Whole Pips NOT Pippetts
Ignored
Thanks Aja!. By "Pippetts" you mean the fraction of the PIP like 5.2 where 0.2 is a pippett of 5?
 
 
  • Post #4
  • Quote
  • Dec 15, 2010 4:15pm Dec 15, 2010 4:15pm
  •  Aja
  • | Joined Nov 2009 | Status: Member | 316 Posts
a Pippett is the 5th digit in 5 digit trading. Its a fraction of a pip - 1.3204X. If you add just 'Point' on a 5 digit system you'll only add 1/10th of a pip thats why on 5 digit systems you multiply Point*10 so you add/subtract a whole pip.
 
 
  • Post #5
  • Quote
  • Dec 15, 2010 4:52pm Dec 15, 2010 4:52pm
  •  skozyuk
  • | Joined Feb 2009 | Status: Member | 147 Posts
In your formula you have "pipadjust" variable, what is it? I apologize for noob questions, I'm just learning various algo principals.
 
 
  • Post #6
  • Quote
  • Dec 15, 2010 5:09pm Dec 15, 2010 5:09pm
  •  Aja
  • | Joined Nov 2009 | Status: Member | 316 Posts
Thats YOUR input for how much you want to add or subtract. Wanna add 5 pips? Make pipadjust=5 and do the addition code.
 
 
  • Post #7
  • Quote
  • Last Post: Dec 15, 2010 5:40pm Dec 15, 2010 5:40pm
  •  skozyuk
  • | Joined Feb 2009 | Status: Member | 147 Posts
Does this look right? Im writing this in VB.NET, just creating series of FXMath methods to calculate various things...

Inserted Code
    'Calculate TP price of pair by adding pips to the quoted price, capable of handling 4 and 5(default) digit
    Public Function PipsAbovePrice(ByVal Pair As String, ByVal Pips As Double, ByVal Price As Double, Optional ByVal QuoteDigits As Integer = 5) As Double
        Try
            Dim NewPrice As Long = 0

            'Calculate new price based on special conciderations for specific pairs
            Select Case Pair
                Case "USDJPY"
                    If QuoteDigits = 5 Then
                        NewPrice = Price + (Pips * 0.001 * 10)
                    Else
                        NewPrice = Price + (Pips * 0.01)
                    End If
                Case Else
                    If QuoteDigits = 5 Then
                        NewPrice = Price + (Pips * 0.0001 * 10)
                    Else
                        NewPrice = Price + (Pips * 0.0001)
                    End If

    End Select

            Return NewPrice
        Catch ex As Exception
            Call LogError(ex)
            Return 0
        End Try
    End Function
 
 
  • Platform Tech
  • /
  • FX Math - How to add or subtract pips from current price
  • Reply to Thread
0 traders viewing now
Top of Page
  • Facebook
  • Twitter
About FF
  • Mission
  • Products
  • User Guide
  • Media Kit
  • Blog
  • Contact
FF Products
  • Forums
  • Trades
  • Calendar
  • News
  • Market
  • Brokers
  • Trade Explorer
FF Website
  • Homepage
  • Search
  • Members
  • Report a Bug
Follow FF
  • Facebook
  • Twitter

FF Sister Sites:

  • Metals Mine
  • Energy EXCH
  • Crypto Craft

Forex Factory® is a brand of Fair Economy, Inc.

Terms of Service / ©2023