Log in

Method Monte Carlo based EA

By jaguar1637 4607 days ago Comments (13)

Hi

I heard With athe Monte Carlo algoritm, it's possible to  build a function and obtain a time-serie as result. Now, the idea is to reverse the processing.

From a time-series, us the Monte Carlo to retrieve the primary and main function and guess the forecast value

 This approcach based on an EA, is shown here :  http://forum.mql4.com/37182

Something has been made in : http://mcfx.collective2.com/

This arbitrage strategy uses Monte Carlo statistical sampling methods derived from those commonly used to approximate a solution to the transport equation in nuclear systems.

System Description

Methodology

This EA produces Monte Carlo simulations of the Forex market every minute for a number of periods into the future. A mean and standard deviation are obtained from this projection, and are fed into a trade decision subroutine. This information is then used to enter the market when conditions are favorable and exit when they are not.

This system centers around a very robust risk management strategy using the Monte Carlo method. Instead of seeking a high win rate by having an SL thousands of pips away (which can result in margin calls and losses to subscribers), we use sound statistical methodology. Take-Profit (TP) and Stop-Loss (SL) levels are set dynamically based on the projected means and standard deviation upon execution. Stop-Loss levels are tight, sometimes set as low as 15 pips away from the entry, so while we may not have an artificially high win rate, what you see in our equity curve is representative of the drawdown percentage you should expect in your account. It is very important to scale your account properly, however. Please see the discussion below on risk management.

This instance of the MCFX system uses multiple positions per traded pair executed within a probability cloud. Because of the multiple position strategy, this system is intended to be used in larger accounts.

Risk Management

The TP and SL are set using Monte Carlo standard deviation data when an entry is executed. The lot size is calculated such that 3% of the account will be lost if the SL is hit on all possible positions at any given time. This risk is divided by however many instruments are being traded and the maximum number of open positions in each instrument. For example, if we're trading the USDCAD and GBPUSD and a maximum of 30 positions in each, every position opened risks 0.05% of the principal in the account, such that if the maximum number of positions are entered in both pairs simultaneously, 3% of the account will be at risk. Note that even though this is a conservative and bounding scenario, it is possible to have a string of losing transactions causing the user to lose more than 3% of their account within any given period.

Please note that the risk percentage is approximate since C2 does not allow fractional lots. To allow for the most granularity in position sizing, the maximum account size was selected for broadcast.

If you have a $1,000,000 account and would like to trade with a 3% risk, your scaling factor will be 1. Otherwise, please calculate your scaling factor as follow:

sf = AB / rAB * R / rR

where:
sf = scaling factor
AB = account balance (yours)
rAB = reference account balance (mine)
R = desired risk (yours)
rR = reference risk (3%)

For example, a $10,000 account at 6% risk would use a scaling factor of 0.02 (10k/1M * 6/3)
 

 

Comments

  • jaguar1637 4607 days ago

    Yep Take a look on this : http://gatornuke.wordpress.com/ 

  • JohnLast 4607 days ago

    The guy says:

    'I'll be happy to discuss methodology and the scientific principles behind it, but I'd like to use this EA someday to help pay for my son's college, so I'd prefer to keep the code private.'

    The guys is selling signals on collective2 .

    The results are not very sexy by now, but you would always prefer an average strategy that is performing life. 

    It is too early to give a conclusion based on the results. 

    I would compare the results from this strategy with the results from similar strategies from Barcleyshedge indexes. 

     

  • JohnLast 4607 days ago

    I think that this is not an easy task to make this kind of methodology for MT.

    And I doubt if MT4 IS ADEQUATE, BUT MT5 is completely up to the task.

    Maybe it would be easier to implement this into Matlab and make a connection with MT5 or MT4.

    Anyway do dot count me within it, my level is not high enough.

     

     

  • fxez 4606 days ago

    John,

    I would never try this type of a method in a pre-built scripting language like MQL4. Too many variables that you need to have low level control over and so building it in a real programming language is probably the only answer. It is hard enough to get right when you control the environment. But this part has me worried

    This EA produces Monte Carlo simulations of the Forex market every minute for a number of periods into the future. A mean and standard deviation are obtained from this projection, and are fed into a trade decision subroutine. This information is then used to enter the market when conditions are favorable and exit when they are not. 

    Reoptimizing every minute most likely introduces a sort of selection bias that produces sub-standard returns due to optimization. By changing tragectory so often, an unstable equity curve is produced which is hurt by the natural churning effect of the markets when seen on too short a timeframe, and which likely may be worse than the average equity curve of all possible future outcomes. This is a hard obstacle to overcome. The lure of a constantly reoptimizing strategy that always stays optimal is hard to resist, though not so pleasant in practice.

    After making many attempts with this type of optimization strategy, I've found that reoptimizing on a longer term basis is more optimal in terms of producing consistent results. It is likely that the underlying strategy in this case produces unstable returns over time, which has lead to this design choice. The optimization of the underlying system must be based on the actual underlying price data, not only on the strategy goals. My current belief after doing many rounds of optimization on shorter lengths is that weeky is about optimal though there may be shifts that occur intra-week, though no more than 2-3 IMO, and detecting those shifts and implementing a new strategy may lead to more inconsistent returns than simply sticking it out with "good enough" systems on a weekly basis.

  • fxez 4606 days ago

    As a clarification, when I said 2-3 shifts per week, I meant including the initial state.

    So really on a weekly basis there are 1-2 additional shifts at most, and many times there is no shift, which would indicate that the optimal strategy is to not reoptimize initra-week. Usually when there is a shift, there is only 1 during the whole week, and the shift often occurs as the transition from the early week slow trend to the end of week quicker trend.

    To me this indicates that the "optimal" reoptimization should allow the initial state of the system to run as is for much more extended periods than it appears is being done in the monte-carlo based EA. When strategies are unable to maintain stable returns over the period when no breaks have occurred, then this indicates that the underlying strategy is unstable and needs to be addressed, rather than masking over with more frequent optimization which will generally churn away an account over time.

  • fxez 4603 days ago

    As evidence of the churning effect, note how the equity curves between the without and with costs has gotten markedly wider, particularly since January. High turnover systems need to maintain a consistent upward amplitude to the equity curve to be viable. It's interesting to note that the system is profitable without trading costs, but in loss with costs. Churn... http://mcfx.collective2.com/

     

  • JohnLast 4603 days ago

    fxez, what you say it is very important, really. 

    For example in the mods of actrend based on neural net, the genetic optimizer detects some profitable settings with a lot of trades, unusually high. And I am always sure that this is not going to perform out of sample, so I go next and I choose a group with a viable number of trades. Using the genetic optimizer with the percetrone the results are grouped by number of trades, and each group has almost identical equity curve.

    How to make the distinction:

    I use two methods with the ASCtrend expert:

    -I have a benchmark with the original ASCtrend buy sell expert, and I want the neural net to give me approximately the same amount of trades.

    -I look visually on the chart, here this is much  more discretionary but I do not want to see too much trades.

    This is also true for other platforms, for example the Neuroshell day trader, the genetic optimizer with the default settings tends also to make too much, you need manually to do some things in order to limit the number of trades, something like, increase the costs per trade or set a limit of bars of the smallest time span between trades. Doing so you are more likely to end with system that will be profitable out of sample.

    And on thecontrary of what you may think, when the number of trades is too high the system is less robust. Here I tell you my practical observations not a scientific fact. Those systems may make some very good first trades then they crash.

    My explanation is that they orverfit a specific set of market conditions and as the market is chaotic it moves away from those overfitted market states.

    Inversely, you may think that as you have more trades, the results are more statistically significant, but it is not that simple, because you have more spread to beat.

    Between the lines as for HFT (High Frequency Systems) they are different. As there are some different types their concerns are different. But still this is a major issue and they have to be tuned constantly.

    In some types of predatory strategies their edge is to play smart money versus dumb money.

    For example a big investor wants to enter into the market and buy a big amount of shares. 

    They will detect him (for example setting many limit orders at different levels that last for very, very, very short time, this is called High frequency spam) and front run him, buying before he buys (rude explication of course but there is a very interestingvideo on you tube).

    But still as there come more and more HFT, they will have to compete agianst them selfs and their advantage will eventually erode.

  • fxez 4603 days ago

    John - yes thanks for your comments. I think this is true also - that the really high trade systems are less robust. I theorize that the reason is that the parameter lengths tend to be shorter on the high trade systems. They perform well for a shorter period, then the performance tends to degrade rapidly due to a slight underlying change in the market. The longer lengths are less prone to falling off the curve with small market changes as they are not as precise to begin with. So slow and steady still seems to be more of a robust solution even though those high trade small win systems have a certain lure and look so good while they are on a winning streak. At the end of the period examined, consistency seems to come from the longer lengths, and perhaps the "free lunch" of the diversification effect can be put into play by combining multiple longer length systems together rather than the shorter length systems. In this way they effectively trade more as higher frequency systems but without the problems of quickly degrading performance.

  • fxez 4565 days ago

    I wanted to update this one because now the system posted on collective without trading costs has also gone below zero, while the difference between actual returns and no cost returns continues to get wider due to the churning of constant reoptimization. It's an easy trap to fall into but in the long run just ends up churning the account away. In other words, the opposite of the BeattheSpread philosophy! ;)

  • JohnLast 4563 days ago

    No trading idea will last forever. Maybe the trading idea has to be reconsidered. If we watch the banchmark at Barleys hedge index the professional  strategies are making money right now. Well overall.

    However actually the currency traders face some  problems but they are profitable +0.012 %.

     

     

  • fxez 4559 days ago

    Perhaps not forever, but one would think that at least 6 months for a short shelf life system would be required to consider a system worth trading. But I suppose there are many of these types of systems that show some early promise but quickly fade on collective2 or zulu.

  • jaguar1637 4308 days ago

    John, I am looking for the C code put inside on of the MonteCarlo documentations.

    I do not remember which one is it. But sure, you posted a link about this code , here, on this forum 

  • JohnLast 4308 days ago

    I just made a search for monte carlo in the site and looked for bookmarks

    http://beathespread.com/bookmarks/view/16439/monte-carlo-permutation-evaluation-of-trading-systems