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

Options

Bookmark Thread

First Page First Unread Last Page Last Post

Print Thread

Similar Threads

Random Walk (The unbeatable!) 354 replies

Is random really random? 231 replies

Probabilities in a Random Walk (Question about one CP's post) 35 replies

Random Walk Theory applying in Expert Advisor 336 replies

Price action pattern, and random thoughts 6 replies

  • Trading Discussion
  • /
  • Reply to Thread
  • Subscribe
  • 7
Attachments: Random walk and Pascals triangle
Exit Attachments
Tags: Random walk and Pascals triangle
Cancel

Random walk and Pascals triangle

  • Last Post
  •  
  • Page 1 23 4
  • Page 1 23 4
  •  
  • Post #1
  • Quote
  • First Post: Jul 31, 2010 7:46am Jul 31, 2010 7:46am
  •  Scotty2Cues
  • | Joined Mar 2010 | Status: Member | 247 Posts
Hi,

Im trying to do a bit of theory using a 1 dimensional random walk. Im trying to count the number of paths on Pascals triangle to a node, if I eliminate some of the paths (stop loss). I know without restrictions its n!/(n-r)!r! but I cant workout the formula with resrictions on the number of paths. Im basically trying to work out the probability of getting to a node...
any ideas appreciated

thanks
  • Post #2
  • Quote
  • Jul 31, 2010 3:28pm Jul 31, 2010 3:28pm
  •  Craig
  • Joined Feb 2006 | Status: Blah blah blah | 1,410 Posts
http://mathworld.wolfram.com/RandomW...mensional.html
The breaking of a wave cannot explain the whole sea.
 
 
  • Post #3
  • Quote
  • Aug 1, 2010 2:52am Aug 1, 2010 2:52am
  •  Scotty2Cues
  • | Joined Mar 2010 | Status: Member | 247 Posts
Quoting Craig
Disliked
http://mathworld.wolfram.com/RandomW...mensional.html
Ignored
thanks. (love wolfram)

Think I need a modification though. Looking for proability of getting to a specifice node (or two) to simulate stop loss and take profit. So I can only visit that node once (provided the other has not been visited) and I cant travel past the nodes (enpoints/boundaries)

I was going to find the probability of reaching it in exactly N steps, N+1 steps, N+2 steps...... and then sum the probabilities using infinite series. I assign a probability to either direction. So Im really looking for the number of ways of getting to a node in exactly N steps with the restriction that I can only visit that node on the last step. I can do it using Pasacals triangle using a simple method but havent been able to get a formula....
 
 
  • Post #4
  • Quote
  • Aug 1, 2010 4:37am Aug 1, 2010 4:37am
  •  medici
  • Joined Nov 2008 | Status: Member | 3,069 Posts
Hi Scotty,

maybe I can help, but I am not sure what you are actually trying to achieve. Are you trying to calculate probabilities of hitting SL/TP levels or is it something else? If the answer is yes, then counting paths in Pascal's triangle might not be the most efficient method.
Homeruns and capital preservation.
 
 
  • Post #5
  • Quote
  • Aug 1, 2010 6:35am Aug 1, 2010 6:35am
  •  Scotty2Cues
  • | Joined Mar 2010 | Status: Member | 247 Posts
Quoting medici
Disliked
Hi Scotty,

maybe I can help, but I am not sure what you are actually trying to achieve. Are you trying to calculate probabilities of hitting SL/TP levels or is it something else? If the answer is yes, then counting paths in Pascal's triangle might not be the most efficient method.
Ignored

Hi,
Yes trying to calculate probabilities of hitting SL/TP. I was looking at a 1 dimensional lattice with the end points being the SL/TP given the probabilities for 'left' and 'right'
 
 
  • Post #6
  • Quote
  • Aug 1, 2010 6:37am Aug 1, 2010 6:37am
  •  Scotty2Cues
  • | Joined Mar 2010 | Status: Member | 247 Posts
and then use those probabilities to work out EV calculations.....

Adding the restriction that the end points can be touched only once is making it extremely difficult (for me anyway)
 
 
  • Post #7
  • Quote
  • Edited Aug 2, 2010 12:55pm Aug 1, 2010 3:15pm | Edited Aug 2, 2010 12:55pm
  •  medici
  • Joined Nov 2008 | Status: Member | 3,069 Posts
Yes, it's a bit tricky. In the academic literature this problem goes under the names of The Classical Ruin Problem and Random Walk With Absorbing Barriers.

The two standard methods of solving it are by homogeneous difference equations and moment-generating functions.

You can find a complete treatment of the problem in William Feller's An Introduction to Probability Theory and its Applications, 3rd Edition, pp. 344.

If p = probability of 'right' and q = 1- p, then the probability of being stopped out (if starting at i and the SL is a and TP is b) is

1 - (i - a)/(b - a) if p = 0.5

[e^(tb) - e^(ti)]/[e^(tb) - e^(ta)] if p <> 0.5

where t = ln(q/p)

Hope that helps.
Homeruns and capital preservation.
 
 
  • Post #8
  • Quote
  • Aug 2, 2010 4:19am Aug 2, 2010 4:19am
  •  Scotty2Cues
  • | Joined Mar 2010 | Status: Member | 247 Posts
Quoting medici
Disliked
Yes, it's a bit tricky. In the academic literature this problem goes under the names of The Classical Ruin Problem and Random Walk With Absorbing Barriers.

The two standard methods of solving it is by homogeneous difference equations and moment-generating functions.

You can find a complete treatment of the problem in William Feller's An Introduction to Probability Theory and its Applications, 3rd Edition, pp. 344.

If p = probability of 'right' and q = 1- p, then the probability of being stopped out (if starting...
Ignored
Thank you!

I will take a look (been a few years since I hit the books) aalthought was thinking about buying Fellers book a couple of days ago. Downloaded Grinstead and Snell's Intro to probability last week and it has moment-generating functions. Never heard of m-gfs them before (generating functions I have).

Would Wiener processes be the next area to look at?

Can I ask if you're professional in this area or is it from education?

Thanks again.
 
 
  • Post #9
  • Quote
  • Aug 2, 2010 4:42am Aug 2, 2010 4:42am
  •  medici
  • Joined Nov 2008 | Status: Member | 3,069 Posts
Quoting Scotty2Cues
Disliked
Thank you!
Ignored
You're welcome.

Quote
Disliked
I will take a look (been a few years since I hit the books) aalthought was thinking about buying Fellers book a couple of days ago. Downloaded Grinstead and Snell's Intro to probability last week and it has moment-generating functions. Never heard of m-gfs them before (generating functions I have).
Grinstead and Snell solve the Ruin Problem too. See pp. 486. Feller's book can be heavy going, in spite of being called "Introduction". Just so you know.

Quote
Disliked
Would Wiener processes be the next area to look at?
Depends entirely on your motivation. For intellectual amusement? Then, yes of course. For trading? Then, maybe not.

Quote
Disliked
Can I ask if you're professional in this area or is it from education?
Depends on what you mean by "professional" and "this area". I've got the degrees and I've been paid to do research in both maths and finance, even though I now specialise in staring at screens.
Homeruns and capital preservation.
 
 
  • Post #10
  • Quote
  • Aug 2, 2010 5:23am Aug 2, 2010 5:23am
  •  Craig
  • Joined Feb 2006 | Status: Blah blah blah | 1,410 Posts
I don't know if this is of any help, but this is the sort of thing which would be easy to do Monte-Carlo simulations on, this will not give you a closed form answer however.
The breaking of a wave cannot explain the whole sea.
 
 
  • Post #11
  • Quote
  • Aug 3, 2010 6:27pm Aug 3, 2010 6:27pm
  •  sqrt(-1)
  • | Joined Jul 2010 | Status: The limit does not exist. | 67 Posts
My view of this conundrum is from graph theory, so please intervene if what I say doesn't relate to what you may be getting at.


Assuming "randomness", the probabilities of a position hitting a SL or TP should be exactly the same barring they are exactly k steps from the entry. However, because there would be no reason to even consider this trading method otherwise, there must be some prior knowledge you're basing this on.

So you plan to integrate historical data to generate previous probabilities of walks given a vertex in a path has been hit?

Compiling data for when price n (-/+) is hit, for n equal to the number of pips deviated from the entry may be hard because of the infinite amount of data. However, focusing more vaguely on certain entry levels and let's say n=+/-25x when x is a positive integer over a certain pair over a period of 5 years or so may be very achievable.

@[email protected]@price [email protected]@[email protected]@price +25 @[email protected]@

Is this anyone near what you're trying to do?
 
 
  • Post #12
  • Quote
  • Aug 3, 2010 11:11pm Aug 3, 2010 11:11pm
  •  ForexQuant
  • Joined Jan 2010 | Status: Member | 519 Posts
With fixed TP and SL and assuming random walk, the winning probability is easy to calculate by using pascal triangle. The real challenge is trailing stop if it is taking into consideration.

Here is my excel sheet. Have a look!

Btw if anyone have an idea how to calculate the probability by taking trailing stop into consideration then pls let me.
Attached File(s)
File Type: xls Random walk and Pascals triangle.xls   43 KB | 478 downloads
 
 
  • Post #13
  • Quote
  • Aug 3, 2010 11:55pm Aug 3, 2010 11:55pm
  •  sqrt(-1)
  • | Joined Jul 2010 | Status: The limit does not exist. | 67 Posts
ForexQuant, extend your 'triangle' to include probabilities of -2R through to -6R, both sides should have the same probabilities.

Let's say that you enter a position at 1.000.

Think of the Excel cells with given probabilities as vertices and the edges which connect them complete the path in which your position may take. You now should have an idea of probability that your position will land on a certain vertex (+/- #R) and all of the possible paths it may take to reach that point.

To include a trailing stop you should focus on how much you want to dump when the price hits a certain vertex and at which step. If you think about it, when the position reaches that point, it realistically should restart the process all over and from there a new 'triangle' (and hence graph) should begin. Why? Because if you disregard the spread, it is basically like closing the position and opening a new one of smaller size. From that point the open position (now smaller in size and negative in value) has the same probability to move to any vertex away from it as if you were to enter a position where you were stopped out.

For this open position to move back to a positive value, it now has a farther way to go if we consider where it was actually opened at 1.000, and thus the probability is diminished.

What does this mean? If you use a trailing TP with equal preference to the SL, as n trades approach infinity, it should run against you as much as it runs with you, and should hit both you TP and SL equally.

And if you don't use a trailing TP, you'll close less positive positions, yet they will be valued more when you do close them, just enough to offset the cost of your trailing stops.

So, although it may appear that trailing stops would produce larger gains...it's because there are so few that it wouldn't matter. No profits and no loss (except spread) because random walks, after all, are random.
 
 
  • Post #14
  • Quote
  • Edited 11:55am Aug 4, 2010 12:33am | Edited 11:55am
  •  ForexQuant
  • Joined Jan 2010 | Status: Member | 519 Posts
Quoting sqrt(-1)
Disliked
ForexQuant, extend your 'triangle' to include probabilities of -2R through to -6R, both sides should have the same probabilities.
Ignored
I'm not sure whether I understand this. Did you mean the P(win) not equal to P(loss) when you extend the SL to -6R?

Thank you for your trailing stop idea. The new 'triangle' is a smart idea and i think that should work! I'll try to figure out the detail when i got time.
Attached Image (click to enlarge)
Click to Enlarge

Name: wrong calculation.PNG
Size: 4 KB
 
 
  • Post #15
  • Quote
  • Aug 4, 2010 2:55am Aug 4, 2010 2:55am
  •  Scotty2Cues
  • | Joined Mar 2010 | Status: Member | 247 Posts
Quoting Craig
Disliked
I don't know if this is of any help, but this is the sort of thing which would be easy to do Monte-Carlo simulations on, this will not give you a closed form answer however.
Ignored
thanks, Ill take a look. Im not bothered wheteher its a closed form answer or not.
 
 
  • Post #16
  • Quote
  • Aug 4, 2010 3:06am Aug 4, 2010 3:06am
  •  Scotty2Cues
  • | Joined Mar 2010 | Status: Member | 247 Posts
Quoting sqrt(-1)
Disliked
My view of this conundrum is from graph theory, so please intervene if what I say doesn't relate to what you may be getting at.


Assuming "randomness", the probabilities of a position hitting a SL or TP should be exactly the same barring they are exactly k steps from the entry. However, because there would be no reason to even consider this trading method otherwise, there must be some prior knowledge you're basing this on.

So you plan to integrate historical data to generate previous probabilities of walks given a vertex in a path has been...
Ignored
I am not basing the probabilities of a step to the 'left' or 'right' on historical data. Im making an assumption that if I get a signal to sell, eg because of a pinbar at a swing high, then Im assuming the probability of a step right is greater than a step left.

I wanted to do EV calculations so EV = -risk*P(stopped out) + reward*P(take profit) and wanted to see how SL and TP affected the EV calculations. I then wanted to see if/how including a move of the SL to breakeven affected the EV calculation. If I had the formula (thanks Medici) I can write an array formula with a range of probabilities, SLs and TP.

The problem is assuming each step to the right has the same probability but Im only using it over a relatively small number of steps.

Started out as a curiosity......
 
 
  • Post #17
  • Quote
  • Aug 4, 2010 12:08pm Aug 4, 2010 12:08pm
  •  ForexQuant
  • Joined Jan 2010 | Status: Member | 519 Posts
hi 1i (Guess who!),

The previous excel sheet is for that particular case (6R to -2R) because I only calculate the probability of 100 steps since the probability of every single node above 100 steps is too small for that case and can be ignored.

In fact the correct calculation should take infinite steps if you want to consider all kind of cases. Anyway I have revised my excel sheet for 2000 steps. I believe it is good enough to handle most cases that happened in forex trading.
Attached Image (click to enlarge)
Click to Enlarge

Name: 2000steps.PNG
Size: 3 KB
Attached File(s)
File Type: xls Random walk and Pascals triangle R1.xls   852 KB | 351 downloads
 
 
  • Post #18
  • Quote
  • Aug 4, 2010 4:53pm Aug 4, 2010 4:53pm
  •  Scotty2Cues
  • | Joined Mar 2010 | Status: Member | 247 Posts
Quoting ForexQuant
Disliked
hi 1i (Guess who!),

The previous excel sheet is for that particular case (6R to -2R) because I only calculate the probability of 100 steps since the probability of every single node above 100 steps is too small for that case and can be ignored.

In fact the correct calculation should take infinite steps if you want to consider all kind of cases. Anyway I have revised my excel sheet for 2000 steps. I believe it is good enough to handle most cases that happened in forex trading.
Ignored
can you give some theory plz?
 
 
  • Post #19
  • Quote
  • Aug 4, 2010 5:07pm Aug 4, 2010 5:07pm
  •  sqrt(-1)
  • | Joined Jul 2010 | Status: The limit does not exist. | 67 Posts
Quoting ForexQuant
Disliked
I'm not sure whether I understand this. Did you mean the P(win) not equal to P(loss) when you extend the SL to -6R?

Thank you for your trailing stop idea. The new 'triangle' is a smart idea and i think that should work! I'll try to figure out the detail when i got time.
Ignored
Check your sig figs. You may have lost some data in digits.

EDIT>You got it.
 
 
  • Post #20
  • Quote
  • Aug 4, 2010 5:25pm Aug 4, 2010 5:25pm
  •  sqrt(-1)
  • | Joined Jul 2010 | Status: The limit does not exist. | 67 Posts
Quoting Scotty2Cues
Disliked
I am not basing the probabilities of a step to the 'left' or 'right' on historical data. Im making an assumption that if I get a signal to sell, eg because of a pinbar at a swing high, then Im assuming the probability of a step right is greater than a step left.

I wanted to do EV calculations so EV = -risk*P(stopped out) + reward*P(take profit) and wanted to see how SL and TP affected the EV calculations. I then wanted to see if/how including a move of the SL to breakeven affected the EV calculation. If I had the formula (thanks Medici) I can...
Ignored
How will you be able to obtain P(stopped out) or P(take profit) without using historical data of walks for pinbars at a swing high? Mere deviation from a central price based on probabilities of random walks? I like the idea, but forex isn't random, it isn't like flipping a coin. GBP/USD has run up ~1500 pips from the low a few months ago. We can examine the random probability of it doing this, and the odds are very small by random (given p,q=50%), but as you know, historically the pair has moved this much and more in the past. This is how we know forex pairs aren't correlated by random patterns -there are forces which move them.
 
 
  • Trading Discussion
  • /
  • Random walk and Pascals triangle
  • Reply to Thread
    • Page 1 23 4
    • Page 1 23 4
0 traders viewing now
  • More
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