Topic: EURUSD 1 Day Breakout

Ok,

I would like to post this, hoping we can discuss the mechanics of FSB a little.
This system was tested on data from a different broker, so the results may be different with the original FSB data - but I would like to discuss the rules, and how they are applied rather than the results.

Here is the strategy:
Forex Strategy Builder V 2.4.0.0
Strategy name: New
Exported on: 4/13/2007 14:24:43

Market: EURUSD 1 Day
Spread: 4 pips
Swap Number: 1 pip

Balance: 12194 pips
Minimum account: 45 pips
Maximum drawdown: 486 pips
Time in position: 86 %

The same direction signal - does Nothing
The opposite direction signal - does Nothing

[Opening point of the position]
Envelopes
     Open long at the Up Band
     Smoothing method  -  Simple
     Base price  -  Close
     MA period  -  1
     Deviation  -  0.4
     Use previous bar value  -  Yes

[Closing point of the position]
Stop Limit
     Stop  -  -25
     Limit  -  49


Now, to loosely translate the rules:
Buy @ Stop with a stop price somewhere above yesterday's close
Short @ Stop with a stop price somewhere below yesterday's close
Use fixed pip profit target and stop loss

Now, in real life, there could be a bar that touches all 6 prices: The long entry, short entry and the SL/PT of each.

I tried to understand from the chart what exactly happens each day, but I got a little confused by all the arrows and lines.

So I guess I would like to discuss (and ask):

a. What happens in such a scenario? For example, are both long and short position open? And what happens with the SL/PT? - since they were both hit on the same bar - is it considered a loss or a profit?

b.what are all the position-related markings on the chart? I could see down arrow, up arrow (which I assume mean "here we entered long/short" and I see some X's and some small horizontal lines (which may be SL and PT levels?)

For what its worth - the above strategy looks way too simple and was way too easy to create - as someone whos writing strategies for a while now, I must be skeptical and assume that something may be wrong either in the implmenetation that I present here, or in the backtesting engine (the data is no longer a factor, since I am using my own data, from my own broker)

Anybody with an opinion or with a better understanding of this, please feel free to jump in.

Re: EURUSD 1 Day Breakout

In this example we use Envelopes(Close, 1, 0.4) as an entry point.

[Opening point of the position]
Envelopes
     Open long at the Up Band
     Smoothing method  -  Simple
     Base price  -  Close
     MA period  -  1
     Deviation  -  0.4
     Use previous bar value  -  Yes

The indicator Envelopes uses a central Moving Average and places two bands around it on distance n% of the value.

In this case we have a Central MA with period of 1 and it is based on Close Price, deviation 0.4%.
This means that we have to plot two entry levels:
Up (long stop entry)  = Close * 1.04     and
Down (short stop entry) = Close * 0.96

But, as we use closing price of the bar as a base price for calculating the indicator. We can wait for the bar ending to receive the correct indicator value. This means exactly the last tick.

Well, the bar just finished and we have the both entry values. We can set our entry orders. But, the bar has finished and our orders can be executed in the bar that just begins (The next bar. This is not the same bar, we calculate the indicators.).

See:       Use previous bar value  -  Yes

This is extremely important.  Not only in this case, but always when calculating a backtest. The usual broker platforms plot the indicators exactly below the bar they concern, and this is true only in the case when the indicator uses Open Price as its base price. When it uses Close, Middle or some weighted price we HAVE TO use the previous indicator value when calculating the backtest. See more here: http://help.forexsb.com/useprevbarvalue.html

In our example we have not additional Open logic conditions (entry filters) and FSB sends two entry orders. Also, because of the closing strategy:

[Closing point of the position]
Stop Limit
     Stop  -  -25
     Limit  -  49   

FSB sends close orders for both open orders. These closing orders are conditionals. They will be executed ONLY if its base order is executed. In the Journal table you will see the number of the base order in column  If Numb

Other interesting is that, these orders are of type the one cancels the other. You can see in the journal, they have two prices. Internally each of them represents two orders - one buy stop order and one buy limit order (or sell). FSB plots these two levels on the chart with a green and a brown dash. (The green is the take profit level and the brown is the stop loss level).

So we have all orders for the bar. The FSB's backtester calculates the bars one by one starting from the first one, for each  we can calculate the indicator value ( Example: for a MA21 this is the 22nd bar.)

While FSB uses the current time fame data only (for now). The testing result is never 100% reliable when the closing is before the closing of the entry bar.

When we have 1 or 2 entry signals and closing at the Close price of the current bar the algorithm of FSB calculates the backtest well (I think more than well. It gives the result immediately.).

In this example the calculation of both TP/SL levels is an issue in the algorithm. The result is highly overstated. This logic exploited the algorithm to calculate the TP level first.


When the results are 100% reliable.

1. We close at the Closing Price of the bar.
2. We close on the next bar or later.
3. We Open at the beginning of the bar and we have one close level in the bar.
4. When we have two (or more) level and all of them are either higher than the Open Price or lower than it.

When we have two entry levels: Long end Short at one level:
FSB execute the long order first.

When we have two entry levels and the first is higher than the Open Price but the other is lower:
FSB interpolates the bar and the probability for a correct execution is around 87%.

3

Re: EURUSD 1 Day Breakout

It seems, we can use stop - limit logic in short data charts when the exit signals are going to the nex bars ;-)

Re: EURUSD 1 Day Breakout

Thank you Popov for the detailed answer. It is good.
I am completely aware of the most basic mistake people do of using the value of the indicator to trade on the same bar. I am past that level now but nonetheless, it is good that you mention it.

You refer to it as "use previous bar value" - I am simply always buying at next bar (calculate on this bar, and buy @ limit at Bar+1)

So we got at least one thing clear; the entry logic is:
if not BuyAtStop( Bar+1 ) then ShortAtStop( Bar+1 )

This, btw, may be problematic - since it favors bull markets.
If this logic is reversed, we may get different results - but I guess that the only way to truely solve it is to use data from higher resolution.

Now, you touched the point nicely, and I would like to discuss more:
Talking about SL/PT - what would be the logic (in pseudo code) for that?

You mention that you interpolate the bar to determine what hits first - judging by the charts, it looks like FSB is doing something like this (for long positions):

( Bar is any bar from the positoin entry bar onward, including the entry bar itself )

if( Bar is Rising ) then {
  if not SellAtLimit( Bar )
  then SellAtStop( Bar+1 )
}
else {  // Bar is falling
  if not SellAtStop( Bar )
  then SellAtLimit( Bar+1 )
}


Did I capture this somewhat correctly?
Also, how did you extract the 87% accuracy level?

It will be absolutely fantastic if FSB will use data from higher resolution to understand what hits first - this will take it to a whole new level.

Re: EURUSD 1 Day Breakout

Jar Jar - if you mean that daily strategies, will use, lets say 1 hour charts and will only place exit orders at one hour after the entry hour, than I agree. This is the only error-proof way.
Of course, it means that you may miss some exits if the market is fast, but at least it is more accurate and you know that if you get good results in this way, you will get good results in real trading.

Also, if FSB will someday support automatic usage of the higher resolution data, and you have up to 5 minute or 15 minute bars, than this will be perfect.

6 (edited by Jar Jar 2007-04-13 15:01:12)

Re: EURUSD 1 Day Breakout

Normaly we have to use at least one open filter to show us the dirrection of the trade. In this case it is not problem when we enter long/short in the beginning of the bar or other level. The open filter prunes the wrong signal.

Re: EURUSD 1 Day Breakout

I'm working on it guys. The shorter period tester will be ready soon. And it will take the calculation only when is needed. It will use all the data we have (till 5 min). and will make a road for calculation for each bar. To speed the process if there are no calculation or if everything is clear - only the fastest algorythm.

8 (edited by DannyBens 2007-04-13 14:52:11)

Re: EURUSD 1 Day Breakout

Not sure I follow - any example?
Also, if I DO undestand correctly, not sure I completely agree - there are numerous strategies that just "through the net" in the lake - buy at limit or buy at stop - which ever comes first. A classic breakout system, and also (in the opposite direction) - a classic range trade.

I do agree, that in more elaborate systems, you only allow longs or shorts based on other indications, but when we deal with strategies that hold position for a bar or two, and only capitalizes on the "noise" then the direction is sometime of no importance.

Wouldnt you agree?

EDIT:
Sounds good Popov (didnt mean to rush you) - I am becoming hooked! my entire day was coffee -> forum postings -> system testing and back to 1....

Re: EURUSD 1 Day Breakout

The current backtesting algorithm is not perfect (in the example with both TP/SL levels in the same bar - completely wrong). But it is hundred times faster then the one in some other platforms.

About the results when we have two signals in both side of the opening price. I develop this method and it is tested and optimized using shorter periods. It is almost 90% reliable.
You understand  I can't discuss it here. It is the core of the application.

Re: EURUSD 1 Day Breakout

Completely understand - no need to expose what you dont want to expose.
But, I am guessing that I am not the only one that will ask these questions - all I want to do, is to make sure that the algorithm is reliable, and that when the time comes, I will be able to reproduce the same strategy logic in a trading platform.

Yes, it is obvious that FSB is faster than others.

11 (edited by DannyBens 2007-04-13 15:04:12)

Re: EURUSD 1 Day Breakout

Back for a second to the Envelope:
You mentioned that the upper band is Close * 1.04 (using envelope 1,0.4)
What am I missing? The calculations do not add up for me.
Lets say EURUSD, Close = 1.3000
so upper band is 1.3000 * 1.04 = 1.3520 - which is 520 pips difference, which is obviously not going to hit in the next bar.

Where is the fault?

EDIT:
Should be 1.004 and 0.996 I believe?

Re: EURUSD 1 Day Breakout

Opss. I'll check now

Hahaha  - mising brackets. Seems a new update after 30 minutes.

[edited]
now is OK

            for (int iBar = nMA; iBar < Bars; iBar++)
            {
                afUpBand[iBar] = afMA[iBar] * (1 + fDeviation / 100);
                afDnBand[iBar] = afMA[iBar] * (1 - fDeviation / 100);
            }

expect it in the net: smile

13 (edited by DannyBens 2007-04-13 15:16:42)

Re: EURUSD 1 Day Breakout

FSB is calculating correctly, just the posting confused me
High band =
Close * ( 1 + Deviation / 100 )
Close * ( 1 + 0.4 / 100 )
Close * ( 1 + 0.004 )

EDIT:
Update?...

Re: EURUSD 1 Day Breakout

It was wrong. Now will be correct

[edit]
Let check again

Of course 1.004

[edit2]

There is an error in your exe . I'll post the update after 10min.

Re: EURUSD 1 Day Breakout

Keep em coming! smile

Re: EURUSD 1 Day Breakout

Ok.
The Envelopes indicator has been corrected in FSB v2.4.0.2

Thanks a lot. It was possible to stay with the bug with years.

Re: EURUSD 1 Day Breakout

Downloaded 02 build, thanks for the quick fix.

Something is bothering me with this day breakout test system - the smaller I put the stop loss, the better the results.
Best results with 5 pip stop loss - this is not realistic, 5 pips stop loss will hit many many times.

Any thoughts?

Re: EURUSD 1 Day Breakout

I can't say anything since we made calculation using the current time frame only. Without deeper analysis we can't see the movement inside the bar.