Help with a formula - you help me - I'll give you something nice!

Hi folks,

I don’t know if any of you are familiar with Bill Williams’ Profunity Trading System (Trading Chaos) BUT I am trying to program a calculator that I can use to ease my order entry and stop order placement (yes - in a previous life - or business - I used to write software).

I have been wracking my brain for the past three days and I just cannot get a calculation to work FOR EVERYTHING i.e. commodities, forex, indices, etc. etc.

One part of the system requires that you enter a buy stop order one tick above the last valid up fractal and a sell stop order one tick below the last valid down fractal (don’t worry - if you don’t know about this - help me with the calculator and I’ll give you a system that will knock your socks off).

Regardless of the system used the calculation still remains the same.

Here is the problem:

Let’s use the Dow Jones Industrial Average as an example:

I need to place a buy stop order one tick above the value of let’s say 13700.

So the calculation is 13700 - SPREAD + PIP VALUE

which is 13700 - 6 + 1 which equals 13695. Easy right!

But check this out:

With Silver for example:

I need to place a buy stop order one tick above the value of let’s say 13.84.

So the calculation is 13.84 - SPREAD + PIP VALUE

which is 13.84 - 0.03 + 10 which equals 23.81. Right? WRONG!

23.81 IS NOT one tick above 13.84 it’s more like 100 ticks!

What am I missing here?

There must be a formula that can be applied to any forex pair, commodity, etc. etc. that will give you the value of one tick (PIP) - I just cannot seem work it out.

Help me with this and I will upload the calculator, explain the system (and provide links to the original system by Bill Williams, and give you my take on it and a variation that I have been working on that is by no means ‘get rich quick’ but more like ‘eventually get rich for sure’).



Do you mean by “pip value” that the next uptick would make the price 13.94?

If so then your value would be 0.1 not 10…i’d guess. With the Dow the next price would be 13701( not 137.01), a 1 pt move, but if silver moved 1pt it would be 14.84.

As i said just a guess, i’m sure some genius will come up with the proper technical reason in a second…


Question. Why is it “PIP VALUE” that you’re using? Wouldn’t it be more correct to use something like “Minimum Price Increment”?

If you were using the latter, then your calculation would work out. PIP VALUE in futures and forex is going to be based on the size of the contract or trade, not the size of the smallest permissible price change. I don’t have the specs in front of me, but I’m guess that a .01 change in the Silver contract is worth $10, which is what’s coming through in your calculation.


Yes John - you are quite correct (about Silver I mean) - an yes - it is the ‘Minimum Price Increment’ or ‘Tick’ value that I need to be able to work out (sorry - I may have indicated in my previous post that the ‘Tick’ value was the same as the PIP Value but that is not right).

Any help (or standard formula) would be appreciated - it is part of a much bigger project that calculates, amongst other things, stop losses based on ATR as well as stop losses based on a fixed number of PIPs (which can also be used as a Trailing Stop), and a TP amount (based on ‘I do not know yet - have not got there yet’ basis).

I HAVE looked on the internet but I don’t see what I’m looking for i.e. there are variations of something similar but the one’s that I have found are basically to calculate the PIP Value which I already know.



So you’re looking for a way to formulaically determine the minimum tick size?

Yup - that’s it.

If I take the case of Silver I know that by dividing the PIP Value by 100 I get to the 0.01 ‘Tick’ value BUT this only works for Silver i.e. if I had to apply the same thing to a forex pair like EUR/USD then I would be way off again. See my problem?

Edit 1:

I seem to have gotten stuck on the idea of ‘if the PIP Value is greater than 0 then you have to move the decimal point to the right by the same number of decimal points as found in the Spread Value and if there is a decimal involved in the PIP Value then you are fine’ but that just does not sound right or seem to be very robust.

Edit 2:

Yes - I need to calculate the [I]value[/I] of one ‘Tick’ for any given instrument. The given values that I have are the PIP Value and the value of the Spread and (obviously) the Bid and Ask prices.



I can’t think of a way you could do it in a way that would work across different types of markets. Commodities, in particular, are all over the place in terms of their minimum price change increment.

Have you considered hard coding a table of some kind?

There are only a finite number of different incrementing methods. If you were to give each instrument an attribute code that points to the type of incrementing (.01, .0001, .10, etc.) required, that could do the trick.

Thanks for that.

I seem to see a pattern - I just don’t know how to put it into words.

For example:


Buy - Sell = 7.2038 - 7.1938 = 100 therefore one tick above a certain value (let’s say the value is 7.3695) would be:

7.3695 - 0.0100 (spread) + 0.0100 (this 0.0100 being derived by saying that the first significant figure of the spread starts at the second decimal place so therefore one tick is 1 / 100).


Buy - Sell = 652.85 - 652.10 = 0.75 therefore one tick above a certain value (let’s say the value is 673.75) would be:

673.75 - 0.75 (spread) + 0.10 (this 0.10 being derived by saying that the first significant figure of the spread starts at the first decimal place so therefore one tick is 1 / 10).

Am I making any sense here at all?

What I don’t understand is this:

Taking Gold again:

The PIP value of Gold is 0.5 and the spread is 0.75 so therefore the spread is 1.5 in PIPs BUT

Taking Silver again:

The PIP value of Silver is 10 and the spread is 0.03 so therefore the spread is 0.003 in PIPs AND this does NOT make sense.

I’m tying myself in knots here!

I don’t see how I can hard code the table - I want to provide a download link here so anyone interested can use it if they decide to work with the Profunity (Chaos) System (and I hope it will be handy without the system as well).

I’ll tell you what I’m trying to accomplish here:

I have started following the Profunity (Chaos) System TO THE LETTER and I can tell you that although you get into trades very late so far I have failed to take a loss of any kind in the past couple of days which is not like me I can assure you (well - I lie - I have taken some losses BUT that’s only because I have not yet formualted a fixed TP strategy i.e. every single trade at some point or another has turned into a profit but then I’ve let it sit around hoping for more and then sometimes it has retraced and I’ve taken a small loss but that’s my fault not the system. Greed!).

In order to make up for the late trades I have started to work with as many commodites (or forex pairs) as may be giving a valid signal. The problem with this is that on a daily basis I may have to place entry stop orders WITH stop losses for (like today) twelve instruments at the start of the trading day and by the time you have entered the orders with their stop losses (buy and sell) half the trading day has already gone (only joking but you know what I mean) so I am looking for a way to speed up the calculation of these inputs.

I have already written the calculator and it works (well sort of) i.e. as long as I remember to do some fancy footwork for certain instruments when doing the calculations then I’m fine BUT it’s easy to make mistakes (and it certainly would not be nice to make this available to everyone knowing that it can give them false information).


Look at this (and pass comments please):

Take the USD/RMB:

The spread is 0.0025 and the PIP Value is 0.13 SO to add 1 ‘Tick’ to a certain price you sort of ‘match’ the PIP Value to the spread like:

Spread = 0.0025, PIP Value = 0.13, so one ‘Tick’ would be 0.0013.

Take the USD/ZAR:

The spread is 0.0100, PIP Value = 0.14, so one ‘Tick’ would be 0.014.

Take Crude Oil:

The spread is 0.05, PIP Value = 1, so one ‘Tick’ would be 0.01.

Take the EUR/USD:

The spread is 0.0003, PIP Value = 1, so one ‘Tick’ would be 0.0001.

Take the GBP/CHF:

The spread is 0.0012, PIP Value = 0.8, so one ‘Tick’ would be 0.0080.

If I’m right - do you see the pattern?



I think I get what you’re trying to do using the spread to determine the pricing increment. How about comparing the current to the last price to figure it out? Though I can see issues there when prices are moving violently and substantially more than a tick or so at a time.

I think the problem with using spread is that sometimes the increment isn’t at the same digit as is the spread. You have suggested that in such cases (USD/ZAR), the spread digit is more significant, but I don’t think you’d want to hard code that. Consider forex were sometimes spreads widen out. For example, EUR/USD might normally be 2 pips, but on a holiday it could go to 10 pips. The price increment for EUR/USD is definitely 1 pip (or maybe even a pipette), but the spread would suggest 10 pips.

Also, over time both spreads and pricing increments can change.

As for hard coding a table, an alternative would be setting an array. I don’t know what you’re using to code this stuff, though.


I suppose the best way of demonstrating is to put up what I have so far (for testing and comment).

Try it with EUR/USD for example - works like a charm.

Try it with something weird like USD/ZAR or Silver or Oil - not so good.

Anyway - have a look see - and you’ll see what I’m trying to do.

(Ignore the ‘Tick Value’ field - it does nothing - just experimenting).

(I’ll tidy the interface up and put a nice little help file with it and everything when I sort the calculations out).

(It is written with FiveWin and xHarbour sort of “MS Visual FoxPro’ish”)!


I have removed the attachment from this message and posted it on my latest post in this thread (to save space on the forum).

If you want to have a look at the latest ‘attempt’ then look for my latest message in this thread.


Hello - just an update.

After making my brain go numb it finally dawned on me (after some sleep anyway) that I cannot do what I am trying to do i.e. I am trying to add oranges to apples to get an answer in bananas!

I had a look at one of my dealers’ websites where they have the details of the spreads etc. etc. and basically the spread of currency pairs is quoted in PIP’s, for the indices it’s quoted in ticks, and for commodites it’s quoted in US cents SO rhodytrader - right again - I will have to put all of this stuff in a database first!

I did get it ‘sort of’ right by manipulating the decimal points in the software and it worked for ‘most’ instruments but there is no ‘one size fits all’ in this case.

As soon as I’m done I’ll continue the thread.



If I was trying to create something that is broad as your talking about, I would either do two things

Create the workbook and have a sheet for each commodity as each as a different multiply for each’s increment (tick)

Or you could have one sheet that does the calculation but you would need to specify in the sheet above all the calculations which commodity it is so it knows which kinda increment needs to be the multiple increment.


cell value: silver, forex, stocks, yada put a one next to which you are going to calculate then have the calculations below all this reference back up to which one has a one by it and insert that increment’s multiple. yada yada if 1 is by forex then insert .0001 or stock insert .01

It is the only way I see is possible to do it since it is so broad

just type this fast but this is the general idea

Hello - and thanks for the reply.

I’m not doing it as a spreadsheet (although it would be a lot easier as I can pull these values straight from one of my platforms via DDE). I am actually writing the software - that way nobody needs Excel to use it.

I have already tried most of what you suggested and it worked for MOST things but I just don’t like having a margin of error.

Basically I am setting up a database with the intrument type, and based on the type doing the calculations either by PIP value, tick value, or monetary value.

WHAT AM I DOING HERE ANYWAY - I promised myself that I would not go near a computer or trading this weekend - ADDICT)!!!



Yeah I posted about the spreadsheet, before I realized you was actually programming it in visual… oops

But feel regardless of program platform you create with, still need the indicator of which type is being traded, I would imagine there will always be a minimal room for error, but having to place a check mark next to a commodity is about minimal as it gets… ;oP

Looks really good what you’ve done thus far, makes me want to learn how to do that so my spreadsheet looks alot cooler. Pretty much just an excel nut, haven’t bothered to learn anything else. Keep up the good work

Hey - thanks for the encouragement!

Like I said - I used to write software in a previous life (business) but I just got soooo sick of it that I decided to look around for something else to do for a living - and - here I am - and loving every minute of it!

Working on this little calculator is enjoyable - I mean it’s not a pain for me to write this little bit of software (and it keeps me away from my other computers so that I don’t exit trades too early)!



You must convert everything into the same number of decimals. For example.

The script is written to handle a price in this format 1.9750

so when you enter a price of the yen, for example 123.70 you will have to enter it with 4 decimal places, like this: 1.2370

NOT like this 123.7000.

Otherwise it will just take more programming on your part to adapt to whatever market you are using.

This is a quick easy fix that I use.

Why don’t you set up an indicator of some sort showing what type of trade is being looked at and throw a few if statements in to sort your math according to the type of trade. If you already know the math for each trade, this should be simple to do. Most of the software I have seen is separated specifically by market for this reason. What language are you writing this in?

Hey folks,

Well - here it is - the latest ‘attempt’!

Thanks to all for your input here.

I did not put all of the instruments in a database (that would be a problem for anyone who wanted to use it and did not have an account with the same broker).

You also don’t have to worry about what type of instruments you are dealing with BECAUSE - thanks to professorfx’s input - I got an (the) idea!

Basically the ‘Tick Value’ input on the ‘Profitunity (Chaos) Trading System Calculator’ is the number of decimal places which you input yourself e.g.


Prices quoted as 653.53 i.e. 2 decimals
‘Tick Value’ is therefore 0.01


Prices (points) quoted as 7896 i.e. 0 decimals
‘Tick Value’ is therefore 1 (basically anything with 0 decimals is 1)


Prices quoted at 13.15 i.e. 2 decimals
‘Tick Value’ is therefore 0.01


Prices quoted as 1.3408 i.e. 4 decimals
‘Tick Value’ is therefore 0.0001

Get the picture?

Anyway - for those of you who know (or think you know) where I’m going with this and are interested then download and check it out for me.

For those of you who don’t know where I’m going with this - I believe I have found the ‘Holy Grail’ of Trading Systems and I have written this little utility to help enter the data (it’s just a hell of a lot easier to do it this way than sit with a calculator and when you are trading many intruments at a time it becomes really time consuming to enter all of this data especially if you decide to work on four hour charts)!

There are a couple of ‘niceties’ I want to add like help screens / prompts and a sort of ‘quick clear’ button and I’ll do this now but the most important thing is that the calculations check out. I have been using it today and so far it seems spot on - I just want to know I have not missed anything.

Anyway - the calculations are as follows (if you need to follow them through):

Spread = Current Buy Price - Current Sell Price
Tick Value (already described above)
Last Valid Fractal Up = as per Bill Williams’ Profitunity (Chaos) Trading System (which we are getting to)
Last Valid Fractal Down = as per Bill Wiliiams’ Profitunity (Chaos) Trading System (again - which we are getting to)
Current ATR Value = self explanatory
Alligator Lip Value = Value of Alligator’s Lip (normally green)

Buy Stop Order = Last Valid Fractal Up - Spread + Tick Value
ATR Buy Stop Loss = Buy Stop Order (above) - Spread - Current ATR Value
Alligator Buy Stop Loss = Alligator Lip Value - Spread

Sell Stop Order = Last Valid Fractal Down - Tick Value
ATR Sell Stop Loss = Sell Stop Order (above) + Current ATR Value
Alligator Sell Stop Loss = Alligator Lip Value

You may wonder why I take the spread into account. It is simply because my (main) broker only displays the Selling Price on the charts i.e. I don’t have the choice of displaying the Buying Price or the Selling Price - it’s always the Selling Price that is quoted on their charts.

If you have any other ideas or would find something like this useful but not necessarily to trade the Profitunity (Chaos) Trading System and maybe need a change or two then let me know (we could always have two versions you know)!



Profitunity (Chaos) Trading System (563 KB)