Triple threat exit strategy

rpotor, “first in, first out,” fifo. well, one problem at a time. today being my first day live, i haven’t run into this problem here yet, just thought about it, and don’t yet know how it will affect our efforts to automate. certainly caught it on one of my other methods. trading a basket of inter-pair arb spreads, i ended up with multiple longs in one pair. using an ea called, “close at profit,” which closes all positions when a certain profit is reached by the sum of all positions. but, when that profit was reached and it came time to close, i got a message saying something like, “trade # could not be closed due to fifo violation,” meaning that, among those three e/u longs i had, it wanted me to differentiate which one i initiated first and take that one out first, etc. riiiight. that’s just what i needed to hear. it also took a long time to close those positions manually because the chart kept locking up. once i got out of that, i realized that i could have only one position in each pair to use that closing ea.

there will be times when we may want our stops or tp’s at the same point for multiple positions, same pair. if anyone knows how this fifo works, help us out here. are we going to run into problems when we get to a stop or tp on multiple and same pairs?

I have not seen this error yet. However I don’t think it could cause problems for the Triple Threat EA, because theoretically we are closing all open orders either via a set TP or a set SL, so the EA will not close any orders in itself, it just sets new SL price levels according to the rules - hopefully :slight_smile: It’s the broker’s responsibility to comply with the fifo rule when multiple open trades hit the SL or TP price level on the same currency pair.

However if you’re using that “close at profit” EA you mentioned, I think you might run into this trouble with it in the future, too. Maybe that EA is not smart enough to take this fifo rule into account. Obviously I’m not saying that as an offense directed against the author of that EA, it just might be that he/she wasn’t even aware that the EA needs to handle this as well.

good to know it probably won’t be a problem. thanks for your work. hopefully, several of us can give this new version a shakedown this week.

Rpotor,

I have FinFx who’s GMT +2. After a couple weeks of this I’ve determined that to take Monday’s trade on Friday’s data is too late to capture Monday’s full movement. The compromise I’ve come to is to wait for a full four chart to form, and then base the entry off that. It’s not perfect, but its much closer to pipwoof’s entry. Just a suggestion for a frustrating situation. Thanks again for your work on the EA.

-Armstrong

first of all… congratulations! Right off the bat it opened buy and sell stops on all 4 ccy pairs i placed them onto… thats great enough. I did them just now and cant wait to see this in action when trading starts at the asian markets.
Couple of questions… im using Oanda MT4… would the EA be sensitive to GMT offset? I prefer the start candle to be after midnight and the end to be at 23:00 GMT in line with how pipwoof designed DB-TT system initially… would really be great if the EA does that :slight_smile:

On the other hand, the fact that it works on calculating the highs and lows, saves me from putting figures into excel daily is such a big feat already achieved… good work!!!

:slight_smile: Thanks for that, glad that at least the order placement part seems to work.

I don’t think the EA should be sensitive to GMT offsets. It considers a new day is started when a new daily candle appears on the platform, which is entirely broker dependent. Once a new day is “established” it places the orders for the new day based on the previous daily candle and sets order expiration times exactly 1 day from the start of the new “broker day”.

In Oanda’s case that should mean the following:

Oanda’s GMT offset is GMT-5.
However we are now using summer time, so that is actually GMT-4.
A new daily candle should open on Oanda at Midnight “Oanda time”, which is 04:00 GMT (note that 04:00 - 4 hours is 00:00)
So in your case the EA should open new pending orders (assuming it is running) 1 minute after 04:00 GMT each day (I say 1 minute after, because by design the EA only runs once every minute to ease the load on your computer’s CPU). The expiration on those orders should be 04:00 GMT the next day. On your platform however you will see (if you activate the crosshair from the MT4 toolbar) if you hover above any daily candle that each daily candle’s open time is 00:00. That’s because the platform shows server time (“Oanda time”), which only matches your actual time exactly if you’re exactly in the platform’s timezone. To check the current GMT time see this page.

For example Alpari UK’s GMT offset is GMT+2
We are currently using summer time, so it’s actually GMT+3.
They open new candles at midnight “Alpari UK time” which is 21:00 GMT (note that 21:00 + 3 hours is 00:00).
My MT4 platform always shows the new candle is formed at 00:00 Alpari UK time, but in “reality” that means 21:00 GMT or 23:00 “Hungary time” (where I’m located).

If I’m anywhere wrong above, feel free to correct me, the stuff above is my working theory regarding the confusion that was in my head about the daily open/close times and their relation to GMT, server time (a.k.a. broker time) and local time. :slight_smile:

forex_ news_market_clock (2).zip (63 KB)

i’m not sure why i don’t get that cute little logo when i try to offer an indi, but i hope you can open this one and give it a look. it is one of my favorites. not only does it list upcoming news events and plot a vertical line on your chart, in the left corner it tells you what your local time is, what time it is on your platform, gmt time, and what time it is in all the markets. if it happens that you can’t download it, it is called forex_news_market_clock, but i can’t remember where i got it.

You can get around fifo in a couple of simple ways. Not perfect (workarounds never are), but they work.

  1. use differing lot sizes. Fifo only applies to lots of the EXACT same size on the same currency pair. So, if you trade 3 trades of, say, 1,000 units, 1001 units and 1002 units, the difference in sizes are inconsequential as far as P/L is concerned and you can close in any order. This is where Oanda fxtrade is wonderful.

  2. just change the SL or TP of the particular offending trade. Change it to a price level very near market price and it’ll close it, no problem. Worried about which direction the market will go? “Choke” the trade by modifying the TP and SL to surround current market price.

These are two methods I use when this issue arises. I use Oandas fxtrade platform for it because of the flexible lot size and the ability to quickly drag n drop SL and TP levels.

I never have cared for the mt4 concerning lot size and order manipulation. Now, if Oanda could just implement auto trade conditions on fxtrade…we can dream. Maybe it can be coded into an ea to act under certain conditions but that sounds like a coding nightmare.

Edit: an issue I ran into, easily dealt with manually but the ea may have issues with:

When setting my orders for Tuesday, a/u had a open long with the SL below my entry for a Short entry. Being in the USA, I can’t hedge. So, the short entry would act as a SL for the open Long position. I decided to bring the SL up a few pips and place the short at its proper entry.

Obviously, this wont bother our friends across the pond, but you may end up missing a trade on accident if automating this system.

update:
g/j short 123.25, trades to judgment stop, be, be, be.
g/j flat.
g/u short 1.5714, trades to judgment stop, -10, -10, -10.
g/u flat.
a/u long 1.0493, all open, sl at 1.0475 risking -20, -20, -20.
e/u, short 1.2285, trades below 1.2225. tp +35, air and retrace stops moved to 1.2250, reverses and takes out air and retrace at 1.2250, +35, +35.
e/u flat.
total closed: -10, -10, -10, +35, +35, +35 = +75.
total still at risk: -60.

we are pretty much where we were several hours ago. technically, we can say we finished the day +75, but there are still those 3 a/u positions that haven’t gone anywhere. note also that those fiinished the day near the high, but are still nowhere in profit. i would not add to those, but would just manage what we have open in that pair.

new entry stops, excluding a/u:
g/j, buy 123.53, sell 122.47
e/u, buy 1.2305, sell 1.2223
g/u, buy 1.5732, sell 1.5670
e/j, buy 96.62, sell 95.51

i did trade the a/u and e/j live this morning and retain 5 open positions:
a/u long 1.0493, sl placed at 1.0475, risking -20 X 3 = -60.
e/j sell 96.40, tp hit at 96.00, +40. currently printing around 95.75, have elected to move both remaining stops to 96.00, locks +40, +40.

rpotor, thanks for the helpful program. pipwright, i appreciate the tips on managing fifo. good trading all!

Read more: 301 Moved Permanently

Rpotor thank you for the Ea for this system, have you used it on demo please post your result

Thanks for that explanation… I’m not sure if I should be answering my own question but does the EA work correctly only when placed on a Daily chart? I placed mine earlier on an hourly chart and it seems correct…

Okay, this morning I could test the SL changing functions of the EA, because my AUDUSD trade managed to reach TP. Unfortunately I found out that the EA does nothing. :slight_smile: It doesn’t break anything (or itself) but it doesn’t modify SL levels either. So I dived into the code again, did some debugging and I think I found all bugs that prevented it to work as it should. I could only test the SL modification of the Buy orders (because my AUDUSD trade was a Buy) but I’m quite happy to announce that it seemed to work! :slight_smile: It set the new SL level correctly. Many more tests are still required however, because this was just one successful execution and maybe other bugs will surface when the SL will “jump” again if we reach a higher quarter, but for now it seems to work. To test it, you can unleash it on your currently open orders (if those orders were placed by this EA -> you can check this by looking at the trade comment, if it includes a loooong series of numbers, you’re gold) and see what it does. Of course you should first remove any previous version of this EA if you have it running on the same chart. Just make sure that in the upper right corner of your chart it says v3.19 next to the EA’s name, then you have the correct EA version running on it.

http://www.rpotor.com/forex/TTE/Daybreak-TT-OrderEntry-v3.19.mq4

RESULTS for 07/30 Total -99 pips

EURUSD SELL
1.22306 -> 1.2275 (stopped out at initial SL)
-45 / -45 / -45
Total -135 pips

AUDUSD BUY
1.04964 -> 1.0525 (initial TP reached)
1.04964 -> 1.0500 (Air and Retrace stopped out at near BE SL)
+28 / +4 / +4
Total +36 pips

None of the other pending trades triggered.

That -99 pips was not so funny yesterday, but today I’m going to stand up, dust myself off and go for it Doom style, so bring it on market! Hurt Me Plenty!

07/30 DAILY HIGH/LOW
GBPJPY 123.584 / 122.477
GBPUSD 1.57477 / 1.56715
AUDUSD 1.05069 / 1.04481
EURUSD 1.23097 / 1.22246

OPEN TRADES for 07/31
AUDUSD BUY @ 1.05166
currently at -4 / -4 / -4

PENDING TRADES for 07/31
GBPJPY SELL @ 122.467
GBPJPY BUY @ 123.594
GBPUSD SELL @ 1.56705
GBPUSD BUY @ 1.57487
AUDUSD SELL @ 1.04471
EURUSD SELL @ 1.22236
EURUSD BUY @ 1.23107

You’re welcome! I’m currently using it only on demo, since we can say it is still in beta version, there might still be bugs in it. I don’t recommend unleashing it on live yet, unless you’re brave and have lots of unneeded money to burn (but in that case it would be easier to lose that money if you’d just send it to my Paypal account. :-))

Anyway, feel free to follow the thread, we’ll post here our experiences /results with the EA and this strategy in general.

Oh, yeah, forgot to mention it! The EA does not require anymore to sit on a daily chart, you can drop it on any timeframe, it can still access daily candle data. On a very new MT4 installation however or on a very newly opened currency pair (like if you haven’t yet opened a certain pair at all in the past and suddenly decide to trade it) it might not hurt to open the Daily timeframe at least once, so that your MT4 client can get historical data. I’m do not know exactly yet how candle data is handled by MT4, but for safety’s sake it’s good practice to switch to a few timeframes on newly opened currency pairs at least for once after you open it on a chart. After that I think it goes fine in the MT4 background, so you can switch back to whatever timeframe you like and drop the EA onto it.

On the thought of keeping the platform alive, I have a small EA that can sit on any chart and just keeps the connection alive. No need to switch timeframes if you use this. Geez - BP won’t let me upload an ex4 so I have had to zip it.
Cheers,
AltosT

P4X-ConnectionManager.zip (5.43 KB)

Rpotor, Thanks for your response and the humor, Still demoing Spirit Daybreak v1.3 EA. Hope your EA will not every time the MT4 platform close and re-opens open new orders with the older ones as with Spirit’s EA?
demoing on AlpariNZ open 3pendeing orders for EJ,and EU and other pairs. What could be wrong Rpotor?

Nope, my EA should not open new orders every time the platform is re-opened, it should be handled by the EA to open orders only when it’s “valid” to open as per the rules. If you experience such behaviour please report it here on the forum as it might be a bug. Please if you report a bug, tell me which version you were running. Current version is v3.19, available from this link.

Normally the EA should open 3 pending buy stop and 3 pending sell stop orders for each currency pair you run it on with an entry price of 1 pip above previous daily high for buy orders and 1 pip below previous daily high for sell orders. However it can only open a buy stop order if the current market price is below the buy stop price and it can only open a sell stop order if the current market price is above the sell stop price. If this is not true it will only open those orders that are possible to open based on this rule. However if you let it run on your chart, it will monitor the market and if the market price moves in a preferable direction it will open the “missing” orders. However also please take into account that on a given day, the EA will only open a certain order type once. So let’s say it places a buy stop order at price level X for EURUSD, but the order gets stopped out. Now let’s say the market price retraces to price level X over the course of the same day, in this case the EA will not open a new buy order because it considers it is “done for the day” for EURUSD buy direction.

rip van a/u finally woke up just enough to tp pos 1, then dozed back off to close out at near be stops 1.0500. this is where we finished up with trades entered yesterday:

g/j short 123.25, trades to judgment stop, be, be, be.
g/j flat.
g/u short 1.5714, trades to judgment stop, -10, -10, -10.
g/u flat.
a/u long 1.0493, tp at 1.0525 +30, pos 2 and 3 fell back to stop at 1.0500, +5, +5.
e/u, short 1.2285, trades below 1.2225. tp +35, air and retrace stops moved to 1.2250, reverses and takes out air and retrace at 1.2250, +35, +35.
e/u flat.
total: -10, -10, -10, +35, +35, +35, +30, +5, +5 = +115.

because we already had 2 open positions in a/u as we began the day, the pair is not included in today’s rotation.

these are our current entry stops:
g/j, buy 123.53, sell 122.47
e/u, buy 1.2305, sell 1.2223
g/u, buy 1.5732, sell 1.5670
e/j, buy 96.62, sell 95.51

edit 6:45 am: gbp/jpy and gbp/usd have entered short trades.
g/j sell 122.47, tp 122.00, sl 122.75
g/u sell 1.5670, tp 1.5625, sl 1.5700

edit 8:00 am:
rpotor, was just comparing our entry points. it looks like you are close, especially the short trades. i noticed the euro is what got you yesterday. i have said that i am really jumpy on mondays and fridays. cut your losses, especially on those days. entered late today and did not have a chance to try out your new machine, but will soon. thank you for all your work.
rpotor, PENDING TRADES for 07/31
GBPJPY SELL @ 122.467
GBPJPY BUY @ 123.594
GBPUSD SELL @ 1.56705
GBPUSD BUY @ 1.57487
AUDUSD SELL @ 1.04471
EURUSD SELL @ 1.22236
EURUSD BUY @ 1.23107

Read more: 301 Moved Permanently

edit 8:20 am:
leave it to the blinkin’ euro to spike up for a long, then lose interest. stops hit -30, -30, -30.

Rpotor,
On my Alpari NZ platform, it opened 3 buy orders for EU, 3 sell for GJ, 3 sell for GU and 2 sell for UsdCad all at the same time.Why so?