Topic: FIFO Violation

Hello,

I'm testing new strategies in a Demo account and receive the following error message:
"Trade XXXXX could not be closed due to FIFO violation".

As a US client I understand there are regulations in place to "protect" investors.  When using FSB are there particular settings I should use to avoid this?

Thanks

Re: FIFO Violation

Hello Sleytus,

Try the following:

https://s24.postimg.org/qbirdzb8l/bal.jpg

Re: FIFO Violation

Open the EA in Metaeditor, locate line 97 and change it to false, recompile and test. Report back as well. I'm surprised though you got the error.

Re: FIFO Violation

Footon -- thanks very much for your quick response.  I will rebuild the EA with the modification you suggest and let you know if it makes a difference.  I'm currently testing about 30 EAs and they don't necessarily trade each day -- but I will report back when this one again attempts to close the position.

Currently the default value for 'FIFO_order' is 'true' -- which means it should honor the NFA regulation and the error should not occur.  Changing it to 'false' seems like the opposite of what the solution calls for -- but I'll give it a try anyways.

Again -- thanks for your help.

Re: FIFO Violation

Hmm, have you ruled out conflict between EAs? I'm thinking now my suggestion will not be of help, if your 30 EAs are all on the same pair, you will still get those errors because the broker won't differentiate trades in relation to EAs as you and your EAs do. If EA no.1 has a position opened say yesterday, EA no.2 has position opened today morning and it wants to close the position today evening, it will give error as there's that position from yesterday (?).

Re: FIFO Violation

That's interesting...   It was my understanding a single instance of MT4 terminal could be used to test multiple EAs.  According to Metatrader docs, one can run a maximum of 128 EAs on a single terminal.  I mean, from Googling I've seen many examples of that.  Supposedly it works when you use a different MagicNumber for each EA.  The EAs I'm testing each have a different MagicNumber.

Or -- are you saying this is another NFA thing that would only affect US clients?

I'm new to ForexSB and find it amazing tool.  And I assume that since it is so easy to generate EAs that users like yourself test multiple EAs at the same time (and not individually).

I apologize that this is getting away from my original questions -- but I guess it is sort of related.

Thanks

Re: FIFO Violation

Well, you can test as many EAs as MT can take, but when you're having multiple positions in one currency pair, then FIFO applies (to my understanding different magic numbers/different EAs are not taken into account). Can you dig up the logs in relation to that error? Did you have previous, older positions opened and the error came from a recent, newer position?
Best clarification on this FIFO issue can come from your broker.

Re: FIFO Violation

In addition, most probably I gave you bad advice earlier, sorry for that, you should roll back the FIFO changes in your EAs.

Re: FIFO Violation

No problem about the earlier advice -- I've learned a lot from your subsequent posts. 

I could dig up the logs, but after doing more Googling I think you are correct.

So let me ask you -- suppose you have 10 EAs that you wanted to test on EURUSD -- what do you do?  I've done a lot of back testing and wanted to move on to testing in a Demo account.

Re: FIFO Violation

I would change the broker, it's the only way to get away from that FIFO madness, testing one EA at a time is a waste. But of course, this is easier said than done. Currently, your EAs are developed on one dataset, changing the broker means different data, which can have rather considerable impact on EA behaviour... Tough choices no matter which way one looks at it.

Re: FIFO Violation

Yep -- I understand.  Just as in real life, it always comes down to trade-offs.  Footon -- again, thanks very much.  You saved me a big, big headache.

Re: FIFO Violation

sleytus,

How did you get around the FIFO violation?  As a US trader, I've just bumped into this obstacle.  How does one get around it?

Re: FIFO Violation

The only way around this is to find a non-US broker who accepts US clients.

I don't have any recommendations.  Most non-US brokers do not accept US clients -- however, there are a few who do.  If you want to go that route then you'll have to do a lot of Googling.

Re: FIFO Violation

Ok

Thanks