Monte Carlo based EA

 

I just finished backtesting my Monte Carlo based EA, and the results are encouraging enough to start forward testing. I've put this up on a blog and I'm broadcasting the forward test live. Granted, it may be days or weeks before any trading, but there it is nonetheless.

This is not a scalper or some curve-fitted EA. Feel free to take a look and let me know what you think. Questions, comments, suggestions for improvement?

Check it out at GatorNuke's Lab

 
not needing $475575 to start it off would help some of us none-millionaires ;-)
 

I cannot find the link to the EA source code (maybe it is because blogs (as opposed to old-school websites) are always confusing and completely without structure).

Is there something I could read to understand

  1. what is monte-carlo
  2. how to apply it to trading (maybe a simple to understand example or some example code)


Especially this sentence: "The EA will be collecting historic data from the trading chart to assemble the statistics that define the sampling functions powering the EA’s predictive abilities."

Could you give a minimal example how such a statistic looks like and how it "defines a sampling function"? What is a sampling function in this context (samples of what?) and how is it used for predicting (what exactly are you predicting)?

 
brewmanz:
not needing $475575 to start it off would help some of us none-millionaires ;-)

I had to start with such a high balance to allow for finer granularity of the variable position sizing based on a risk-adjusted MM scheme, although it would work sufficiently well one order of magnitude less. If your broker allows 0.01 lots you can get away with two orders of magnitude less ($5,000).
 

hello nuke..

i want see the result from 2007-2010 result.. can your ea pass it?

2007 is difficult situation... hehe..

why not using in h1 timeframe, maybe more accurate since your ea is longterm?

 
7bit:

I cannot find the link to the EA source code (maybe it is because blogs (as opposed to old-school websites) are always confusing and completely without structure).

Is there something I could read to understand

  1. what is monte-carlo
  2. how to apply it to trading (maybe a simple to understand example or some example code)


Especially this sentence: "The EA will be collecting historic data from the trading chart to assemble the statistics that define the sampling functions powering the EA’s predictive abilities."

Could you give a minimal example how such a statistic looks like and how it "defines a sampling function"? What is a sampling function in this context (samples of what?) and how is it used for predicting (what exactly are you predicting)?


The monte carlo method is the method of producing random samples from a known Cumulative Distribution Function (CDF). The CDF is in turn the integral of a Probability Distribution Function. Taking the integral of the PDF and inverting it to obtain the indepenent variable as a function of a random number to produce random variables is refered to as the fundamental formulation of monte carlo (FFMC) and is how you obtain a sampling function that generates your random samples. There is no way i can condense a graduate course into a message post, but suffice it to say that you generate random samples, and if you generated sufficient random samples from a given sampling function using the same CDF, you'd wind up with a distribution that corresponds to your original PDF. You produce a string of these samples to see where the price would end up at the end of your history, and then you repeat the process to produce n-histories. You then combine information from all your histories and wind up with a set of statistics (like the mean and standard deviation for your end price).

In this case, the delta prices in the chart are recorded and assembled as the PDF. This is why the EA doesn't even start to trade in the backtest until it reached a sufficient amount of bars in the backtest.

I tried looking for some information on the web on Monte Carlo, but most of it is either very simplistic or very advanced, but this should help:

http://www.nre.ufl.edu/documents/Day3-HybridMonteCarlo.pdf

Slide 6 shows two histories being sampled (one particle scattered all the way through the medium and one was absorbed). In our case, we're only sampling the next delta price (roughly equivalent to scattering angle, although in our case we're not doing isotropic scattering). There is no equivalent to sampling interaction type or path-length, since the next bar will always be 1 period in the future, and the currency will not cease to exist.

 
hardyyanto:

hello nuke..

i want see the result from 2007-2010 result.. can your ea pass it?

2007 is difficult situation... hehe..

why not using in h1 timeframe, maybe more accurate since your ea is longterm?


Good question. That is part of the path forward, but results from this longer test will take a few weeks to a month before they complete, even though I'd only run the test to the beginning of the one I have posted. I'm moving this month, and as such the only way I could run this uninterrupted would be in my laptop. I'm still considering it, but I might just do it after I'm done with the move.

1h timeframe would sure seem less noisy, but there is very little data at that high a timeframe. In addition, you start to lose the disctinction between the behaviour in different market sessions.

 
If you had started the EA after step 16 you would have lost your shirt. Starting it between 66 and 70 you would have lost the house and starting it after 89 you would have lost everything and be busking to eat. I would suggest you check why it has such long down periods.
 
Ruptor:
If you had started the EA after step 16 you would have lost your shirt. Starting it between 66 and 70 you would have lost the house and starting it after 89 you would have lost everything and be busking to eat. I would suggest you check why it has such long down periods.

I disagree. At no point did it violate betting more than the specified 10% risk of principal. You could argue this is too high, but that's a different discussion. The reason for the seemingly long string of losses is that the positions opened are a sort of "compound position." The settings as tested allowed for 10 concurrent positions with 1% risk in each (10% max total at any one time). What sometimes happens is that the EA sees a confluence of good statistics that may persist for a few hours or so. In this case, you'll have what's essentially the same position opening on every bar 10 consecutive times. If the EA is wrong or something happens in the market (news release, etc), the prices could go the other way and you'll then see this "compound position" lose. It'll show up as 10 different trades, but they're really all wiped out at pretty much the same time, or close to it.
 

By the way, in case anyone is interested. I'm documenting additional experiments at http://www.gatornuke.com.

 

gatornuke:



The monte carlo method is the method of producing random samples from a known Cumulative Distribution Function (CDF). The CDF is in turn the integral of a Probability Distribution Function. Taking the integral of the PDF and inverting it to obtain the indepenent variable as a function of a random number to produce random variables is refered to as the fundamental formulation of monte carlo (FFMC) and is how you obtain a sampling function that generates your random samples. There is no way i can condense a graduate course into a message post, but suffice it to say that you generate random samples, and if you generated sufficient random samples from a given sampling function using the same CDF, you'd wind up with a distribution that corresponds to your original PDF. You produce a string of these samples to see where the price would end up at the end of your history, and then you repeat the process to produce n-histories. You then combine information from all your histories and wind up with a set of statistics (like the mean and standard deviation for your end price).

In this case, the delta prices in the chart are recorded and assembled as the PDF. This is why the EA doesn't even start to trade in the backtest until it reached a sufficient amount of bars in the backtest.

I tried looking for some information on the web on Monte Carlo, but most of it is either very simplistic or very advanced, but this should help:

https://www.mql4.com/go?http://www.nre.ufl.edu/documents/Day3-HybridMonteCarlo.pdf

Slide 6 shows two histories being sampled (one particle scattered all the way through the medium and one was absorbed). In our case, we're only sampling the next delta price (roughly equivalent to scattering angle, although in our case we're not doing isotropic scattering). There is no equivalent to sampling interaction type or path-length, since the next bar will always be 1 period in the future, and the currency will not cease to exist.


Can you pust the EA in mq4 ?
Reason: