这是笔者在FF找到的比较好的关于反网的帖子。只是作者似乎并没有量化,而且ea也是用来半自动辅助交易的。

作者:7bit
链接:http://sites.google.com/site/prof7bit/snowball

http://en.wikipedia.org/wiki/Snow_roller —— "A snow roller is a rare meteorological phenomenon in which large snowballs are formed naturally as chunks of snow are blown along the ground by wind, picking up material along the way, in much the same way that the large snowballs used in snowmen are made."

snowball

Linear growth of losses vs. quadratic growth of profits

Imagine a grid of buy-stop orders above current price and sell-stop orders below current price, all orders having the same volume V and are placed in equal distances d and we have the simple rule that orders that have been triggered will be replaced with new stop-orders (buy above, sell below) as soon as price has moved away a distance > d in either direction: If price is moving up and triggering buy-orders the empty places below the price will now be filled with sell orders, if it moves down, triggering sell orders, then new buy-stop orders above the price will be placed.

A simple Metatrader 4 EA will be provided here to assist in placing the orders and calculating and plotting the profit in real time.

Limit orders and pyramiding losses

At a first glance this might look like yet another variant of the infamous grid system which is responsible for uncounted losses and margin calls. Theconventional grid trading systems make use of limit orders for market entry and exit, they immediately scale out a constant volume V as soon as price moves into trading direction a fixed grid distance d and they scale into the losing trade the same volume V every time price moves another dagainst the trading direction, hoping price will eventually return and allow to scale out again. This method will produce a constant stream of linear growing profits, only interrupted by occasional bankrupts due to the quadratic growth of accumulated losses if market price decides to NOTreturn to where it has been before.

Some people claim to be able to overcome this drawback by simply running the same grid into the opposite direction on the same instrument at the same time, applying what they falsely call "hedging", but it turns out that this is obviously a fatal fallacy. Naturally you can not hedge a quadratically growing loss on one side with an only linearly growing profit on the other side. Furthermore it turns out that these two superimposed grids on the same instrument, if all orders and market exposure is simply added together you will again end up with the very same grid of limit orders, only this time you have created a grid that will automatically switch net trading direction always to your disadvantage and will always pyramid up the losses, no matter where the market decides to go. Congratulations! You have just doubled your chances to receive margin call from 50% to 100%.

Stop orders and pyramiding profits

Back to the system proposed in the first paragraph. We will not take profit every d pips, instead we will let our profits run and even add to the winner the constant volume V every d pips, and we will not accumulate floating losses if market goes against us, instead we will have stop orders immediately scale out the same volume V every d pips if price reverses and goes against us.

I will refer to this system with only stop-orders as an anti-grid in contrast to what is commonly understood as a grid. This name is natural as it will express the same relationship that is found between martingale and anti-martingale and in the same way a conventional grid is related to a martingale-like bet progression, the anti-grid is related to anti-martingale.

If we start our anti-grid and price now goes up n * d pips and then returns n * d pips to where it started we will have made a loss proportional to n * d * V. It will have triggered our stop-loss¹ n times, each time giving us the same loss of V times our fixed distance d. The conventional Grid would instead have scaled into a (dangerously losing) sell n times and on the (lucky) way down taken profit n times the amount of V * d, which is the exact opposite of our system. The conventional gridder² may now laugh about us because he is making small profits while we are making small losses. But what if price, instead of being so friendly to always come back to the gridder's comfort-zone (more on this later), just one time decides to start trending? His laughter would soon die in his throat!
Parabolas in the chart
As time goes by and price is moving up and down in its daily range, day in and day out, trending or ranging, our anti-grid will produce a more or less constant stream of stop-loss hits¹ with always the same amount of loss, thus we can regard our losses as growing linearly with time. If we plot our account equity (realized + floating) into a chart we will see a more or less straight line pointing downwards, occasionally interrupted by impressivespikes pointing upwards.

A very similar line can be witnessed in a conventional grid. Here this line is going slowly upwards, occasionally interrupted by nasty downward spikes that have the potential to wipe out the entire account. The conventional gridder, blinded by some protective mechanisms in his brain, his hopes and greed and the ability of mainstream retail trading platforms like Metatrader to make an account statement still look positive even if it is on the brink of margin call, will see his upwards directed line of realized profits and completely ignore the scary drawdown-spikes in floating losses that often go far beyond his initial starting capital.

Now what has this all to do with parabolas in the chart? We already know that our losses are growing linearly with time. We can describe this simply as

loss ~ t

where the proportionality constant would depend on grid spacing, spread, lot size and certain (hopefully more or less constant) properties of the price series.

But what about the profits? Since we never close a winning trade we will end up with as many profitable trades as price has gone away from our starting price in multiples of our grid spacing d. This is clearly not a function of time, price may move anywhere or just keep ranging, but we might want to know how far price would have to move to compensate our losses. Let n be the number of levels we want price to move. We can easily see that the floating profit would have the following proportion:

profit ~ (1 + 2 + 3 + ... + n)
 
which can be written as
 
profit ~ n * (n +1) / 2

which is
a quadratic function, and for our needs and simplicity's sake we just may approximate this with the much simpler expression
profit ~ n²

and since n * d ≈ (p - p0) we can again make a little approximation and write this as

profit ~ (p - p0)²

Now we want to know where our break-even point is, our losses will grow and so will the needed break even price move away over time. Lets see how the function might look like. Break even is defined as:

profit = loss

and if we substitute profit and loss with the above equations and introduce some proportionality constant a we now can see that there is a simple function that will express the relationship between the elapsed time since our anti-grid started and the price move that is now needed to break even:

(p - p0)² = a * t

this is a quadratic equation and we can solve for p:

p = p0 ± √(a * t)

Now we have something that we can plot into the chart, or at least imagine how it would look like in a price chart: It is a horizontal parabola, having its vertex at the starting point of our anti-grid and opening to the right!

The same calculations apply to conventional grids also, only profit becomes loss and loss becomes profit here, the parabola remains (almost) the same. (almost because the spread is always working towards increasing the loss, so we might arrive at different values for a.)

The constant a is something that needs to be determined experimentally, it depends on our grid spacing, the spread and the "roughness" of the price curve, its fractal dimension. the term a * t expresses the linear growth of losses that have to be overcome by a price movement p - p0 and the pyramided (quadratic) profits (p - p0)² that come along with it.

This is an interesting finding! We can now come to the following conclusions:

  • A conventional grid system will stay profitable as long as price stays within an area on the chart which is roughly defined by the shape of a horizontal parabola, the parabola will mark the break-even line of the grid. Current break-even levels, when calculated and plotted into the price chart can easily visualize this and can be extrapolated into the future. If price moves beyond this line the grid trader will experience massive losses and eventually bankruptcy.
  • An anti-grid system as described above (and provided with the attached EA) will stay in the losing zone as long as price does not move outside of this parabolic area but once price decides to cross this line the anti-grid trader will experience massive profits. Break-even price levels can be calculated from a running anti-grid at any time and also extrapolated into the future to get an idea how this parabola looks like and whether it is still likely to be broken in the near future and/or to find the best Profit-targets where the anti-grid can be reset. The anti-grid trader will start his anti-grid whenever his chart and market analysis tells him that a relatively big move is likely to come and price will move outside of the parabolic area as soon and as far as possible, no matter into which direction!
  • The existence of parabolic support and resistance lines and pivots lining up on parabolas is not an esoteric theory at all, it might instead have a very simple explanation.

Snow rollers

And what has all this to do with snow rollers? The mass of a snow roller, the distance it must have been rolled is proportional to the square of the number of its layers and the energy you would need to unroll it back up the hill or the potential energy that is released when rolling downhill is proportional to the square of the distance it has rolled, just like the losses of the grid or the profits of the anti-grid are proportional to the square of the distance price has moved.

The Expert Advisor

Attached at the end of this page is an Expert-Advisor for Metatrader 4. Many people don't like to read instructions, but please read at least this part of the document completely and carefully, you must completely understand it. This EA is not an automated strategy! It is a trade management EA! It has start and stop buttons. You decide about the begin and the end of a pyramiding cycle. Don't even try to run an automated backtest. You can to some degree simulate manual trading in visual testing mode but automated tests don't make any sense.

The EA will help automatically placing the stop-orders for the anti-grid, plotting the profit into a candle-chart and closing all trades either with a mouse click or automatically when a certain line drawn into the chart is reached. It will allow you to either trade the anti-grid bidirectionally to profit from a breakout in any direction or in a certain trading direction only.

You must enable "allow DLL imports" and uncheck "confirm DLL calls" or the EA will not work. It needs to import the PostMessage() function from the Windows API to update the equity chart.

The EA has 4 modes: "stopped", "long", "short" or "bidirectional". If you attach the EA to a chart the first time it will be stopped which is also displayed in the upper left corner and you will see 3 green text labels in the upper right corner. These 3 labels are the 3 start buttons. To activate one of them first double-click to select it and then drag it a few pixels away (I'm sorry, but this is the only way to make buttons in mql4). The EA will then immediately switch into the selected trading mode (which is also displayed in the upper left corner) and begin to place the pending orders and trade until you stop it (you will now see a red stop-button in the upper right corner).

If you double-click and drag the red stop button it will immediately close all open trades and switch back into the stopped mode.

The current mode and state of the EA is stored in global variables, so it will survive a restart of MT4 without any problems.

The EA has a few hidden extra features: It will plot a realtime equity chart, updated on every tick, containing all profits and losses (floating + realized). To view this chart chose File | Open Offline from the Metatrader menu and select the chart with the name starting with "snow". It will always be a H1 chart, no matter which timeframe you have put your EA on.

If you draw a line (or two) into the chart and write the word stop into its description then the EA will recognize this line (these lines) and close all trades and stop trading as soon as price crosses this line. (After such a line has been hit it will rename it to stop triggered and the line will be inactive, so don't forget to change it back to stop if you want to use the same line a second time. You can enable "show object descriptions" in the chart properties to always see the descriptions of the lines directly in the chart)

Trading with this EA

Trading with this EA basically works like this: You put it onto a chart and have it waiting in stopped mode and as soon as you see a setup (an imminent breakout or a bounce) you start the appropriate mode (long, short or bi) and then monitor the price chart and the profit chart and wait for the best possible exit where you then will actuate the stop button to close all trades. Alternatively you may make use of the stop line as described above to stop it automatically at a certain level.

Please test the EA on demo for a few weeks before you take it live to get an impression of how big the losses and the profits will be.

______
¹ A sell-stop while being long or a buy-stop while being short is equal to a stop-loss order, so we can for the purpose of trading replace all combinations of entry and exit orders, no matter how complicated, with a flat model of simple pending buy and sell orders and for the purpose of making it more descriptive when thinking about it we may think of it as individual trades with their own take-profit and/or stop-loss orders and it will not make any difference.

² gridder: retail trader slang, a trader trading one or more conventional limit-order grids, in most cases without fully understanding them and usually compensating this knowledge gap with permanent whining about non-"hedging" and FIFO rules and other non-problems.
snowball

http://www.forexfactory.com/showthread.php?t=226059&page=2

FF中的帖子有人提问:

How many levels do you get at any given break out? I believe one basket would get around 10%. with pyramiding it is not as aggressive as martingale.
When do you turn your trades off? Or do you just simply run it until it stops you out?

作者回答:

This is difficult to answer. I usually wait at least until it goes into profit one or two levels beyond the green breakeven line, sometimes I have to wait a week(!) or even more (with 30 pip per level on eurusd), sometimes I can have one or two profitable pyramids in only one day. It is not unusual that I have 20 or 30 or even more stoploss hits before it finally goes into profit, much patience is needed.

Thats the reason I recommend demoing it for a few months until you get a feel for how it behaves and what to expect and also to see how much drawdown and profit to expect. This will give you the confidence you need for this system.

In the following screenshot you can see what I'm currently doing: It is in long mode and currently accumulated 436$ losses (~14 stops since friday) for this pyramid, it is one of the not so easy ones (because I expected a long and euro did the opposite). I will most likely close this pyramid once it crosses the green break-even mark which is currently at 1.2290.

As you can see it has trailed down the first entry this morning and with it also the break-even point. Currently I would need a total of 6 levels in total from the bottom (any bottom) to cross break even and come out with profit.

作者的回答中可以看到他没有设定盈利出场的条件。其实到目前为止我个人的反网也不想用固定的止盈值来量化盈利出场,因为盈亏的波动是向未来无限延伸的,界定了固定出场条件 就等于失去了看得见的机会,在亏损可以承担又有机会盈利的前提下,设定止盈目标对交易并无益处。