Topic: Questionable Entries

Popov,

I still have questions regarding entries on FSB.

I have selected something really BASIC : Bollinger entry at UpperBand (20,2, simple, close) and exit on stop loss (-5 pips).
Then, all charges were set to zero for testing purpose.

But still, you can see on attached picture that some entries trigger at unappropriate places ...

What do you think the problem is ?

Alain

http://s4.postimage.org/12oiVJ.jpg

Re: Questionable Entries

Alan please be more precise and write in numbers what the entry price is and what entry price you expect.

According to your chart the error is less then a pip.


http://s1.postimage.org/1BQjVA.jpg


I'm sure there is no error in the calculations.

Re: Questionable Entries

Popov,

My concern is not so much on entryprice values than on prevailing conditions that trigger an entry.

If I understood well the underlying concept of 'Opening a position on Bollinger Bands', it should normally :
   1- wait for a bar (open, high, low or close) to cross the band (upwards for a long entry, downwards for a short entry)
   and then :
   2- open a position (long or short) on the value of UpBand or DownBand of the PREVIOUS BAR.

Apparently, on here-attached pic, yellow-highlighted entries triggered as expected, whereas pink-highlighted entries should NOT have triggered (according to me).

Thanks for your reply.

Alain

http://s4.postimage.org/130UfA.jpg

Re: Questionable Entries

alevi wrote:

   1- wait for a bar (open, high, low or close) to cross the band (upwards for a long entry, downwards for a short entry)

No. You don't need crossing of the current band.

Listen.

Bollinger Band is based on the closing price right? UpBB = MA(Close, 20) + 2* Std. Dev.

Imagine the following case:

Trading on a daily chart at the time is 2pm. MetaTrader plots the current bar and announces that the current price (at 2pm) is the closing price. Respectively it plots also the B Bands. But this is the closing price and this is not the B Band. These are some Current price and bands. They will change till the end of the bar. The platforms shows this values but they are not Final. You and every one who pretends for correct backtesting cannot use the current values. Doing so you'll receive wrong backtest results. To prevent this FST automatically decides whether  to use current values or previous values for backtesting.

The cases are:
- When the indicator is based on Close and the position opens on price different from Bar Open, you have to use the previous values.

- When the indicator is based on Close and position opens at Bar Close - current value.

- Indicator based on Open - current value.

Your case is the first one. The opening doesn't depend on the current B Band. The logic rule "Enter long at the upper Band" together with "Use previous bar value" means that you have to open long when the market price reaches the previous UpBand. You have nothing to deal with the current BB. You even don't know how much is it in the real live. The entry is at the indicator value plotted at the middle of the previous bar.

When you see an entry arrow, look at that level one bar ahead. That's the entry indicator value is. The program rises an entry signal when the price reaches the entry value +- half pips.
The prices are normalized from the broker to 4th  or 5th digits. The indicators are calculated with full precision. The position price can be fractional because of averaging.

These differences of up to half pips after zooming looks like gaps in the chart. That's the reason all the information is shown in the right side info bar in digits. You can see there the Current indicator value, the entry value and the position's price.

If I'm not enough clear, please write in your posts the values or when you make screen shots put the cross at the desired bar.  Make the screen shot showing the info bar like this:


http://s3.postimage.org/1kXUx9.jpg

Re: Questionable Entries

Popov,
May you have a look at the attached pict ?
(exact same strategy, no change ... except the time base that now is 1-hour to match your last post).
Thanks
Alain
http://s3.postimage.org/1l34Er.jpg

Re: Questionable Entries

Alain this is a special case when the price jumps over an indicator without touching it. Fortunately Forex Strategy Builder and Forex Strategy Trader manage this situation properly by opening position at Bar Open price.

See the attached pictures.

http://s3.postimage.org/1l95N9.jpg

http://s2.postimage.org/37Pqr.jpg

Without this features the signal would be missed.

Re: Questionable Entries

Popov,

I don't understand when you said (Today 17:33:29)  "when the price jumps over an indicator without touching it" ...

Bar #515 did NOT jump OVER the previous bar Bollinger Band, so what's the point of opening a position at bar #515 open ?
Moreover, bar 515 is a bearish candle ... !!!

If we go this way then we could say the same thing concerning next #516 bar that is a BULLISH one !!!

I am a bit lost because you first explained me (Today 16:14:13) that "you have to open long when the market price reaches the previous UpBand" ... and TO ME bar #515 does NOT fullfill this requirement.

Thanks for your reply.

Alain

http://s1.postimage.org/1DvrmS.jpg

Re: Questionable Entries

Dear Alain,
I made a special BB for you. It is without "Use previous bar value" and "price jumps".
It has to be easier for understanding.

Put it in "Custom Indicators".

Post's attachments

Bollinger Bands Alain.cs 25.03 kb, 3 downloads since 2009-11-24 

You don't have the permssions to download the attachments of this post.

Re: Questionable Entries

Popov,

Thank you very much for this custom indicator.
I am gonna put it on extensive testing and compare the results with the 'regular' bollinger indicator.

If I understood well what you said in your post of Yesterday 16:14:13, this new indicator CAN NOT be used in a setting where  :
"the indicator is based on Close and the position opens on price different from Bar Open, you have to use the previous values"

but MUST BE used in a setting where  :
"the indicator is based on Close and position opens at Bar Close - current value"

Am I correct on this point ?

Thanks again 1000++++.

Alain

Re: Questionable Entries

This custom indicator is for testing the different logic rules. The entry points will be much clear because they are exactly on the BB bands. This indicator will act exactly like the MetaTrader BB indicator. 90% of the experts I've seen rise signals at the current indicator's value and do not use modifications for "jumping" prices.

You can compare the results between the original BB and this custom BB. You can use both and you can make  custom indicators from almost all standard codes. They are free for download from the indicators section.

Anyway I think that the standard indicators are more safe and reliable because of these modes. All the sources are publicly available.

Re: Questionable Entries

Popov,
You said Yesterday 15:39:44:
"90% of the experts I've seen rise signals at the current indicator's value and do not use modifications for "jumping" prices".
Do you think that what makes a HUGE difference of profitability between your FSB and most EA's is the implementation of "previous bar value analysis" and "jumping prices management" algorithms ?
Alain

Re: Questionable Entries

There is HUGE difference in the reliability of back test.

Re: Questionable Entries

Popov,

I am back on this topic !!!

I am now 100% convinced that 'Previous Bar Value' is DEFINITELY the right way to do things ... (I don't use anymore your custom 'Current BB' indicator).

HOWEVER, I still have a few doubts that I would like you to raise :
Look at this bar #45136.
It should normally go LONG, why didn't it do so ? (see pic)

This is not the single instance that I picked in the chart, I could show you other doubtful instances.
But as I am sure that there is a RATIONAL explanation, I prefer to show you only one example for you to explain.

Thanks.

Alain
http://s2.postimage.org/VqA89.jpg

Re: Questionable Entries

There is nothing special in this bar. There is no entry there because the bar doesn't touch the entry price.


http://s1.postimage.org/wZ9zA.jpg

The formula for fixing "jumping prices" doesn't prevent signals. It moves the entry level to the bar's opening when we have such cases.

The code is here (for Moving Average):

for (int iBar = 2; iBar < Bars; iBar++)
{   // Covers the cases when the price can pass through the MA without a signal
    double dValue   = adMA[iBar - iPrvs];     // Current value
    double dValue1  = adMA[iBar - iPrvs - 1]; // Previous value
    double dTempVal = dValue;
    if ((dValue1 > High[iBar - 1] && dValue < Low[iBar]) || // It jumps below the current bar
        (dValue1 < Low[iBar - 1]  && dValue > High[iBar])|| // It jumps above the current bar
        (Close[iBar - 1] < dValue && dValue < Open[iBar])|| // Positive gap
        (Close[iBar - 1] > dValue && dValue > Open[iBar]))  // Negative gap
        dTempVal = Open[iBar];
    Component[1].Value[iBar] = dTempVal;
}

In normal conditions the entry is at the indicator value:
    double dValue   = adMA[iBar - iPrvs];     // Current value
    double dTempVal = dValue;

In one of the special conditions the entry is at the bar open:
    dTempVal = Open[iBar];

The conditions are:

1. The bar jumps above the indicator without touching it:
        dValue1 > High[iBar - 1] && dValue < Low[iBar]
(The previous indicator is above the previous high and current indicator is below the current low)

http://s4.postimage.org/1X1UsS.png

2. The bar jumps below the indicator:
        dValue1 < Low[iBar - 1]  && dValue > High[iBar]
(The previous indicator is below the previous low and current indicator is above the current high)

http://s2.postimage.org/VKpNJ.png

3. The indicator value is in a positive gap:
        Close[iBar - 1] < dValue && dValue < Open[iBar]

http://s2.postimage.org/VJqr9.png

4. The indicator is in a negative gap:
        Close[iBar - 1] > dValue && dValue > Open[iBar]

http://s3.postimage.org/9VKnA.png


All the images show indicators without "Use previous bar value" (iPrvs = 0). If  "Use previous bar value" = true, iPrvs = 1.

Re: Questionable Entries

Popov,

I am a bit lost with your figures because they now show 'Currrent values' instead of 'Previous Bar value" !!!

Is it possible for you to REDRAW them all with "Previous Bar value" ?

Before you do so, would you agree with these two pictures ?

Alain
http://s2.postimage.org/WTour.jpg

Re: Questionable Entries

In the first case we have a jump.

The second case is a positive gap. The entry value is between the previous close and the current open. That's why the program opens at the first possible price - current open.


http://s4.postimage.org/1YxcY9.jpg

Re: Questionable Entries

Thank you Popov, it's now a bit 'clearer' to me ... not that easy to comprehend, though !!!
Would you agree with the following (see pic) ?
Alain
http://s3.postimage.org/bPAJ0.jpg

Re: Questionable Entries

Excellent. Three notes only.

 
http://s2.postimage.org/Xzem0.jpg

Re: Questionable Entries

Popov,

I understand the "JUMP&GAP" principle much better now.

But I believe this theory can apply ONLY to FSB BACK-TESTING on Historical Data.

How do you handle this principle with a REAL-TIME feed through FST ?

You can NOT test in REAL-TIME High[iBar] (or Low[iBar]) and THEN place an entry (stop or limit) on Open[iBar] according to the test result ....
By the time the current bar (iBar) is tested, it's already over and it becomes a PAST bar and you can no longer place an entry on Open[iBar] !

Please see the attached pic for a concrete example.

Thanks.

Alain

http://s2.postimage.org/Yzqj0.jpg

Re: Questionable Entries

Popov,

Sorry to bother you for I think you have a lot of work with the FST new release, but I have another question concerning the "JUMP&GAP" theory ... (see pic).

Alain

http://s2.postimage.org/YBVs0.jpg

Re: Questionable Entries

Hello Alain,

To your first question:
1. Congratulations, the noted values and variables are correct.

2. The formula for backtesting  and for real trade is the same. My ideas for that are:

a) Indicator is used for entry
- the usage of code for "Jumping" bars highly improves the backtest.
- in the real trade we have O=H=L=C at the bar opening and we can apply the formula.
- if the price goes in the direction of the Jump, the trade and the backtest are equal.
- if the price goes in the opposite direction, the entry error is Open - Indicator value

b) The indicator is used for exit
- All points are the same as the previous except the last one. If the indicator determines a SL,
the exit will be executed at first possible price, which is Bar Open. So there is no error.

In case of pending orders - the execution can be either at the indicator value or at  bar open.

So I think if we have an error, it will be several pips at entry. In the opposite case we will miss many signals in the backtest as well as in the real trade.

I was surprised when I noticed this in a MT expert 5-6 years ago. The expert was set to open a position at a Moving Average. The price was well below it. Later I noticed that the price was crossed over the MA but no entry was executed. My further observations showed that the price was jumped over the MA with one pips.


To your second question:

http://s4.postimage.org/1lAEi.jpg

Re: Questionable Entries

Popov,

You quoted :

- the usage of code for "Jumping" bars highly improves the backtest.
no doubt, but backtest only !!!
that could be frustrating once used in real-time trading...
- in the real trade we have O=H=L=C at the bar opening and we can apply the formula.
yes, that sounds smart ... but how robust enough is this assumption on a long-term real-time strategy
- if the price goes in the direction of the Jump, the trade and the backtest are equal.
sure, but it goes back and forth ... the price may increase fisrt then reverse ... then close in the opposite direction, thus making the "open bar" entry strategy totally irrelevant !
- if the price goes in the opposite direction, the entry error is Open - Indicator value
arithmetically true ... but so treachery. It could make the backtest very promising but then a deceitful real-time trading.

I am not a top expert in trading algorithms, but don't you think that it would be more coherent to :
1- keep your 'previous bar' analysis that is essential and arithmetically 100%-proof (compared to the META-TRADER 'current bar' analysis that is evidently wrong)
2- then keep the bar that follows for testing purposes (what's the trend, is the "previous bar" entry touched, is it a gap, is it a jump ... )
3- and finally take the position on the THIRD bar : at previous(-2) bar value or at open according to the test made in 2-

I understand that this option might lead to some "LAGGING" on position opportunities but it would be perhaps a way to have BACKTESTING get "closer" to REAL-TIME reality ....

What do you think ?

Alain

Re: Questionable Entries

You are write about the difference between back test and real trade. It is not correct to use the current bar High / Low since we don't know them until the end of the bar.

Alain, thank you for the report!

With a little change we can make everything on place. We can calculate "Jumps" by using the current bar opening price (instead High/Low).

Example for MA Crossover entry:

Rules:
We enter long when the market price touches a MA.
- If the price was below the MA before the touch, we enter long.
- If the price was above the MA before the touch, we enter short.   

Normal conditions:
The bar opens below the MA and goes up. When it touches MA, we enter long.
Jump upward:
  The bar opens below the MA and closes 3 pips below it without touch. The next (now the current) bar opens 2 pips above MA. We have a crossover but because of the discrete nature of MA we missed the exact entry. So we enter at Open, which is the first possible price after the crossover.


The code for covering special cases such jumps and gaps is:

for (int iBar = 2; iBar < Bars; iBar++)
{   // Covers the cases when the price can pass through the MA without a signal
    double dValue   = adMA[iBar - iPrvs];     // Current value
    double dValue1  = adMA[iBar - iPrvs - 1]; // Previous value
    double dTempVal = dValue;
    if ((dValue1 > High[iBar - 1] && dValue < Open[iBar])|| // The Open price jumps above the indicator
        (dValue1 < Low[iBar - 1]  && dValue > Open[iBar])|| // The Open price jumps below the indicator
        (Close[iBar - 1] < dValue && dValue < Open[iBar])|| // Positive gap
        (Close[iBar - 1] > dValue && dValue > Open[iBar]))  // Negative gap
        dTempVal = Open[iBar];
    Component[1].Value[iBar] = dTempVal; // Entry or exit value
}

This logic has to be applied at other "entry" indicators like: Bollinger Bands, Envelop, Keltner Channel, Starc Bands...

Re: Questionable Entries

Popov,

I'm gonna try that mod on BB and will let you know about the results.
(I am not skilled at all in MQL4 but that should not be so difficult according to your previous explanation).

Alain