Topic: ATR Stop: ATR initialization error in MT4, warning message in FST?

Hello guys,

i'm using a FSB Strategy with an ATR Stop Exit condition on an Alpari UK Micro account.

The first trade had a wrong SL, just 3 pips, equal to the Stoplevel for this account; it should have been much larger according to the strategy settings.
I suppose that the ATR that FST got was wrong, since I'm already aware of this MT4 related problem when using a EA (if ATR is not initialized, its value is not correct).
I suggest to implement in FST a warning of unplausible low ATR values from MT4.

Thanks.

Kind regards from Germany.

Re: ATR Stop: ATR initialization error in MT4, warning message in FST?

This is what it reads in the code:

double minStop = 5 * Point;
ATRStop[bar + prev] = Math.Max(ATR[bar] * multipl, minStop);

I think we can consider it a bug - if crim has 5 digits, minStop is not 5 points but ten times smaller than that! Alpari is 5 digit crim so that explains the small SL.

Re: ATR Stop: ATR initialization error in MT4, warning message in FST?

Hi footon,

thank for the reply.
In any case I should get the largest value among ATR*multipl and minStop, that means the former (I use a multiplier of 3.80, see my newest post). How can it be that the SL is so small?

Regards,

lt

Re: ATR Stop: ATR initialization error in MT4, warning message in FST?

What are the ATR readings for position opening bar and previous bar?

5 (edited by loton_it 2012-08-15 00:55:18)

Re: ATR Stop: ATR initialization error in MT4, warning message in FST?

Hi,

from MT4: 0,4356 current bar, 0,4481 previous

lt

Re: ATR Stop: ATR initialization error in MT4, warning message in FST?

loton_it wrote:

Hi,

from MT4: 0,4356 current bar, 0,4481 previous

lt

Sorry, I should have been more clear - readings from FST are important, MT is just the link between the broker and FST, all calculations are done in FST!

While we're at it, please provide the following info: trade opening price and the open price of that bar, FST's ATR reading from previous bar (and make sure the smoothing period is the same as in ATR Stop indi you traded with), the value of SL which was set by FST.

It's getting late or actually early, 3am it is, so I'm off now. I'll look into it when I come back!

Bye for now.

Re: ATR Stop: ATR initialization error in MT4, warning message in FST?

You're 100% right, hereby the info you requested:

Open price of the bar: 78.724
ATR reading of the previous bar (in FST): 0,4541

The trade log follows, containing open price and SL; you'll see that I had just a SL of 7.2 pips (should have been 0,4541* 3,8 (multipl)=172.6 pips :

2012.08.14 23:35:34,MT4-FST Expert version 1.10 Loaded.
2012.08.14 23:35:34,Connection_ID=4, Protection_Min_Account=0, Protection_Max_StopLoss=0, Expert_Magic=20011023, Separate_SL_TP=1, Write_Log_File=1, TrailingStop_Moving_Step=0, FIFO_order=1

FST Request: Open a new position.
2012.08.15 00:44:31,USDJPY iargs[0]=1 iargs[1]=51 iargs[2]=0 iargs[3]=0 iargs[4]=0 dargs[0]=0.01000 dargs[1]=78.70000 dargs[2]=30.00000 dargs[3]=0.00000 dargs[4]=0.00000 TS0=0;BRE=0
2012.08.15 00:44:32,SendOrder OrderSend(USDJPY, 1, Lots=0.01, Price=78.70000, Slippage=51, StopLoss=0.00000, TakeProfit=0.00000, "ID = 4", Magic=20011023), Response=38209471, LastError=0
2012.08.15 00:44:32,OpenNewPosition SendOrder orderResponse=38209471
2012.08.15 00:44:33,ModifyPositionByTicket OrderModify(USDJPY, Ticket=38209471, Price=78.70000, StopLoss=78.77200, TakeProfit=0.00000) Response=1 LastError=0
2012.08.15 00:44:33,OpenNewPosition ModifyPositionByTicket orderResponse=1
2012.08.15 00:44:33,AggregatePosition Ticket=38209471, Type=Short, Time=00:44:32, OpenPrice=78.70000, Lots=0.01, Profit=-0.36, Commission=0.00, StopLoss=78.77200, TakeProfit=0.00000, "ID = 4"


Thanks again for your kind help.

lt

Re: ATR Stop: ATR initialization error in MT4, warning message in FST?

Hey Lorenzo,

Am I correct in assuming there are no permanent stop losses used or account equity protection for that matter?
If so, it goes horribly wrong! My calculations don't add up exactly, but it is very close.

I think this happens: FST calculates stoploss, and then expert sets it up, but the problem is how it does that,

stopLossPrice = MarketInfo(symbol, MODE_BID) - stoploss * MarketInfo(symbol, MODE_POINT);

For ATR Stop it shouldn't multiple it by point, when it does that SL is practically the same as stop level.

Only thing I can do is confirm there is a bug, from this point developer is needed to confirm if my theory above is correct or should we look for a bug elsewhere!

Lorenzo, if the fix is going to take a very long time due to developers planned absence, I might cook something up for a workaround. The bottom line is I'll report this to developer, and if it's going to take longer to fix, I'll squeeze the workaround thingy in my schedule.

Re: ATR Stop: ATR initialization error in MT4, warning message in FST?

Hi footon,

thanks for your reply :-)

Your assumptions are correct, no permanent TP,SL,BE or whatever equity protection.

About your explanation, I fully understand what you mean: FST calculates the SL in pips, the final SL price is calculated by EA according to the formula you provided. Actually, there would be no need to multiply by point.

A possible workaround would be to divide the ATR Stop output by point. It should work, correct? In the end the output format would be the same of the Stop Loss exit condition, where you type the SL value in pips in, right?

I'll try this way with a custom ATR Stop indicator and I'll let you know. Should you have another idea, drop me a few lines and we can discuss about that.

Cheers,

Lorenzo

Re: ATR Stop: ATR initialization error in MT4, warning message in FST?

loton_it wrote:

A possible workaround would be to divide the ATR Stop output by point. It should work, correct? In the end the output format would be the same of the Stop Loss exit condition, where you type the SL value in pips in, right?

That's exactly what I thought to do big_smile

It's a very good way to go forward, if it works out fine, we'll know what is wrong. If this doesn't fix the issue, we'll know to look elsewhere!

Re: ATR Stop: ATR initialization error in MT4, warning message in FST?

Hi,

this is the (hopefully) corrected version of ATR Stop only for FST.

ATR and minStop should be correct now.

I'm currently testing it. Please have a look in the while.

Cheers,

Lorenzo

Post's attachments

ATR Stop FST.cs 6.47 kb, 3 downloads since 2012-08-15 

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

Re: ATR Stop: ATR initialization error in MT4, warning message in FST?

Hey,

Good effort, Lorenzo.

One thing though, minStop is not corrected when crim has 5 digits.

To correct it, I would use the following:

double point = (Digits == 5 || Digits == 3) ? 10 * Point : Point;
double minStop = 5 * point;

Other than that it seems to be OK.

Re: ATR Stop: ATR initialization error in MT4, warning message in FST?

Thank you for the reports,
I'll investigate the problem and will try to fix it today.

Re: ATR Stop: ATR initialization error in MT4, warning message in FST?

Issue with "ATR Stop" indicator was only in minStop value. It must be corrected as footon advised.

In order to prevent errors with mixing Point and point I did it like this:

            double pip = (Digits == 5 || Digits == 3) ? 10 * Point : Point;
            double minStop = 5 * pip;

This correction is valid for both FSB and FST.

It seams that FSB backtests ATR Stop correctly.

The problem with FST is that it expects stop distance in integer points (55) but indicator returns points as a double number (0.00055). ATR_Stop / Point is a valid correction, but it must be done in FST algorithm instead in the indicator in order to preserve FSB - FST compatibility.

I changed it in FST -> ActionTrade.cs -> GetStopLossPips(double lots):

// From
case "ATR Stop":
        indStop = Data.Strategy.Slot[Data.Strategy.CloseSlot].Component[0].
                         Value[Data.Bars - 1] ;
        break;

// To
case "ATR Stop":
        indStop = Data.Strategy.Slot[Data.Strategy.CloseSlot].Component[0].
                         Value[Data.Bars - 1] / Data.InstrProperties.Point;
        break;

Re: ATR Stop: ATR initialization error in MT4, warning message in FST?

The above changes was applied to FST v1.6.
It's available at the Download page.