Topic: Unwanted position entering after FSB restart

Hi!

I'm using strategy with Keltner Channel Crossover + HMA on daily chart.
FSB (latest version) works with MetaTrader 4 via FSB-MT4 Bridge.

And usually it works as expected unless FSB restart - sometimes right after that FSB performs trade operations but some trading conditions are not met.

As an example - I've just restarted FSB and it opened an extra long position for EURUSD.
On attached screenshot (sorry, don't like to share strategy itself) you can see that KCC condition is met, but HMA - not.
Is it possible that FSB executes trading operations before all strategy components (indicators) are initialized? If so - I suspect that HMA is the first candidate for review.

Post's attachments

FSB_WrongEnterAfterReboot.jpg 157.01 kb, file has never been downloaded. 

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

Re: Unwanted position entering after FSB restart

It is visible by  the screenshot that "Keltner Channel Crossover" indicator gives a permission for a long entry for the last bar.

3 (edited by vlad123 2015-04-02 09:54:55)

Re: Unwanted position entering after FSB restart

Yes, but I assume it should open position using HMA price, not (any) cuurent, correct?
And it works in this way if FSB is running without restarts.

Re: Unwanted position entering after FSB restart

Check the previous bar closing and the HMA "Position opening price". If the price was on the other side of HMA, the entry has been executed on the Bar Open price because the actual entry price has appeared in the gap between the bar. If it so, the entry was et the first available price after the crossover - bar Open.

5 (edited by vlad123 2015-04-02 11:44:34)

Re: Unwanted position entering after FSB restart

Yep, previous bar closed definitely below all indicators, and now price is above of them.
But I still cannot understand why position was opened using price 1.07893 which is definitely higher than HMA's "Position Opening Price" 1.07659 and even Bar opening price 1.07693 (keeping in mind that I use Daily charts).
And I've just restarted FSB one more time (KCC allows long positions, HMA is above position price - i.e. as in the previous case) but new position wasn't opened.

Kind of black magic ;-)

Re: Unwanted position entering after FSB restart

It seams that the auto trading was turned on and 1.07893 was the available price at the moment. If the trading was off at the start up, most probably the position wouldn't be opened.

I personally prefer to switch on the trading when the data bars are loaded and I see that the prices and the indicator values are correct.

Re: Unwanted position entering after FSB restart

Yes, autotrading is ON.
I have tiny computer (Intel Atom 230) running all the time, which is dedicated to host my trading platforms, and I've spedcially configured it to boot and launch all necessary things (including FSB) automatically in case of unexpected power outage.

Is it possible to introduce a small config parameter for auto trading - to wait several ticks (preferable),  or seconds/minutes, after FSB startup? That would be helpful and will let FSB to reflect its state.

Re: Unwanted position entering after FSB restart

We have to decide wisely how to proceed in such cases. Imagine that the HMA was your exit level and if it was missed, your strategy could go to a much bigger loss.

The exported EA's actually has such protection. The do not trade at the first several ticks. However, I think now it could be a mistake. Imagine that you start your expert on Sunday and the market opens at midnight. If your entry is at Bar Open, the expert will not execute an entry at the first tick. However, when the trade is resumed, the expert will not enter because the market is out of the Open price.

There are many special cases and I already have fixed tens of them.
We can leave it like that. It follow the rules that we trade at the first available price after a signal.

Re: Unwanted position entering after FSB restart

Yes, I understand the complexity of development of the generic algorithm for this case and its low significance for the public usage.
I got an idea that it's possible to workaround this case by implementic some kind of "Skip Init Ticks" indicator for position opening which will return "false" (will not allow to open position) until it will receive N ticks.

I'll try to implement it by myself. Will see if it will work and be useful...

Re: Unwanted position entering after FSB restart

I got an idea that it's possible to workaround this case by implementic some kind of "Skip Init Ticks" indicator for position opening which will return "false" (will not allow to open position) until it will receive N ticks.

You cannot do it for FSB Pro. The program creates the indicator at every calculation (tick) and it will not be able to remember the tick count.

Re: Unwanted position entering after FSB restart

Hmm... Constructor, Initialize, Calculate - on every tick?
It's unexpected a bit...
Was there something specific that forced you to implement such behaviour?
Because MQL (for ex.), which I guess the most widely used platform for EAs development, creates and initializes indicators and EAs once. One of benefits of this - partial calcuation of indicator.

Re: Unwanted position entering after FSB restart

I might be mistaken but hey..
imagine we have MACD with a period of 12
then you should use the data from the last 12 bars to calculate the value/point for current bar. For the next bar you take the 12 bars that precede the current (so you move the period 1 to the right, as the current bar moves one to the right). So basically you have no other way of doing it then recalculate every point, for each new bar, right?

Since the indicator is a line that consists of dots (only visually connected trough a line, which actually does not really "exist"), you cannot really "calculate the indicator only once".

Re: Unwanted position entering after FSB restart

Having 20000 bars in history - it seems that FSB recalculates indicator for every one of them on every tick, if indicator is recreated.
But in general - there is no necessity to recalculate past bars, only current one.

Re: Unwanted position entering after FSB restart

"But in general - there is no necessity to recalculate past bars, only current one." You are right...

I should make clear when a programmer says something is "impossible", they don't mean it for real. There is nothing that you can describe with clear language and cannot be done with programming (pretty much).

So when someone says "it is impossible" it has one of two meanings
- I am not doing it because it would take too much time/money to implement, and it would not yield nearly as much goodness for the users
- Some other logical or emotional reason to not do it

From what I know it seems that we are speaking of the first case here. Sorry.

Re: Unwanted position entering after FSB restart

vlad123 wrote:

Hmm... Constructor, Initialize, Calculate - on every tick?
It's unexpected a bit...
Was there something specific that forced you to implement such behaviour?
Because MQL (for ex.), which I guess the most widely used platform for EAs development, creates and initializes indicators and EAs once. One of benefits of this - partial calcuation of indicator.

Does the reuse of the calculated bars and the partial calculations makes MT backtester faster than FSB? Or more reliable? Take the following example: if the internet holts for several minutes and after the recovering the platform receives several bars at once. Are you going to add the newest value to the previously calculated instead of recalculating the whole series?

FSB tries to reduce using states as much as possible. What would be the purpose of FSB if it was the same as MT?

The purpose of both programs is very different.
MT is designed as per brokers needs with the sole purpose to make you trading more. And from the perspectives of the market makers - to lose more.

FSB has a completely different goal - to provide as reliable backtest and trading as possible.