trading multiple currency pair within the same EA - page 2

 

Shulic

> separate version of our EA to trade only on one currency at a time..

Ahh! Now that I could go with :)

> ...then mix the trade reports ... A dirty hack?

I dont think so!

The strategy may be multi-currency but the tactical implementation should be n EA's working separately.

They can always read the open or pending positions of the other EAs, &/or share global variables

Good luck

-BB-

 
BarrowBoy:

Shulic

> separate version of our EA to trade only on one currency at a time..

Ahh! Now that I could go with :)

> ...then mix the trade reports ... A dirty hack?

I dont think so!

The strategy may be multi-currency but the tactical implementation should be n EA's working separately.

They can always read the open or pending positions of the other EAs, &/or share global variables

Good luck

-BB-

Yeah, that really blows. The more problems and limitations I come across with mql the more I feel like not using it for bot trading. Using what institutions use is more like it. And is what I will be doing very soon.

 

BarrowBoy wrote >>
The strategy may be multi-currency but the tactical implementation should be n EA's working separately.

They can always read the open or pending positions of the other EAs, &/or share global variables

This is the right way : one EA as a simple Connector, launched on each symbol() you wanna trade, except one on wich a Central EA is dropped (performing all computations and trades exec).

Communication beetween connectors and Central EA relies on global variables.

At init() each connector creates a global variable like "Symbol_Name_Cnx" and set it to 1. Once all connectors dropped, Central EA is launched on your last choosen symbol(), and init() checks existence of all others "Symbol_Name_Cnx" global variables, figuring pairs you want to trade.

Then, for each central pair tick, retrieve your decision rules necessary MarketInfo() for each "Symbol_Name_Cnx"==1 global variable symbol().

Once all computing/decisions stuffs done, then clear all global variable "Symbol_Name_Cnx"==0, thus avoiding unecessary computations on each central pair tick.

This way only Connectors EA reset their "Symbol_Name_Cnx"=1, using this mechanism as synchro.

Of course Central EA may miss some Connectors EA ticks, but not all of them all the time. This works pretty well for my multipair/multitimeframe clusterized signal EA, hard job but still not rich, just enthousiastic to move ahead... :) ! Hope you'll carry it to.

But remember as lots said before : no multipair in Tester, so have to "parametrize" one/one symbol() in tester, then move to demo multipair testing, and hope for you in live trading...

One thing more, before stepping in the process of building such a can (from my point of view) you must clearly accept to deal with 4Dim Arrays[][][][]...(max mql allowed dimension)...if you still ask why, think twice before commiting to...

At least, if you want the full picture, printing boards or others figures on Connectors EA charts, presenting main computing issues, orders board positions and/or decisions rules checks stated by Central EA, you need more additionnal global variables, as you cannot deal with outside charts printing issues innersideCentral EA ....so need Arrays[][][][] to keep track of all those communication glob. vars., both managed by Central EA and Connectors, as Connectors charts objects draws code is necessarilly innerside ...(mql touch...)

I know this makes lot of smoke, but as it do what i want it to, i'm still walking this way...hope someone will suggest lighter approach.

To conclude, sound architectural approach calls for a dll (what i'm now working on), but special one, as it must provide a shared memory area to all using processes calling it (wich is not the casual dll building scheme) : why ?

This way, metatrader EA is just a connector, kind of communication layer with the broker server. On each ticks, he posts necessary MarketInfo() datas in dedicated memory area (think multipair/multitimeframe), retrives his dedicated (symbol()) computed results and proceeds with decisions executions, entry, close, Ordermodify...moves StopLoss/StopProfits...

In summary, taking Central EA outside metatrader in form of a VC++ apps, talking with EA through this dll...

One may ask : Is This Really Necessary ? ....... working with mql sequential c like synthax and array dimension limitation renders some algorithmic issues awfully cumbersome...object C++ comes with some 'elegant' features symplifying the trick, and of courses raises new problems.

Hope i'll publish my actual code to make it common knowledge, just to thanks all those forum contributors whom i'm so indebted to, i've learn so much from you guys....

As you can see far, remember you're stepping on Giant Shoulders....so to give thanks and help others...

 

Goood idea HeavyBabar.


My EA trade on 25 currencies and use this system, but a simplier one.


Each chart has the same indicator and EA attached to it. Indicator creates a GV as you describes and communicate exclusively with the EA attached to the same chart.

You don't need several EAs : just an indicator that sends Open/TP/SL signals, and an EA that executes.


Code is very simple, and all works well.



Multicurrencies trading involves several problems. I think diversification is a good thing, but beware of correlations between currencies : this acts the same as leverage=>increases your profits.... or losses.... I think a good compromise is to select a basket of non correlated currencies. I don't have look at that yet, but i think it's about 8-10 currencies.


Dam.

 

Nice approach damtoul, seems really light compared to the Heavy.... i'm handling. As you point out features coming out exclusively in multipair trading, i'd like to share some toughts with you, may be others will find them of interest (i hope). But before going further be forgiving as my english is not native language quality :) !

Ok, damtoul, the way you came out with it is really interesting, you solved the synchro problem arising when central expert (in my case) is asleep and connectors keep nocking at the door without any reaction, even if it does'nt adress a big issue on one year experience this weakeness can one day completely burst my trading tactic.

I also came out with the same constatation, one should act on a restricted basket, 8/10 currencies seems enough from my knowledge, but i'm not convinced that diversification and correlation are meaningfull insights in high frequency trades or intrady insider strategy.

In fact, the more you act as an investor, adopting lower in/out frequency the more your trade signal comes to economist fundamentals market driving factors like, even if you think not : just as your signal builds on long periods moving average contingent indicators whatever the exotic name given to it, then your filtering market reaction to fundamental factors.

One step further, the most difficult pair to me is EUR/USD, others exibiting less difficulties.

Even if EA is architectured on indicators clusters, it only take advantages of a few of them. The best signal i came out with is a very very very simple mix of bollinger bands dynamics and 3 others moving averages hierarchy and velocity.

My quest was to build a high leverage/high frequency EA neverminding the casual trader trick of trending to ranging market transition. Some additionnal work on cascading coherency check on this signal output at different timeframes really improved the whole efficiency and performance, but as one should always remember "There's no free lunch !".

You can't expect achieving the perfect signal, and even if you could, you would still be facing the unforecastable earthquake like issue : think to this Barings Singapour Trader (Nick Leeson), very good in is undertaking but who sinked after the Kobe Earthquake and almost cause he played the redemtion "All or Nothing" strategy after having spectacularly cleared is losses and redressed many human back/front office mistakes (inverting buy/sell)...

In my case, as i've completely banned stoploss, market entries must establish optimal freemargin left in order to stay in the process as ticks may show chaotic dynamics even if sticking to the target.

Most the time with an << efficient >> signal the main loss factor is the broker stopout, and that's the main issue i'm dealing with since then. At birth, each position have a limit hedging price at which an optimal (to my actual knowledge) leveraged position is opened, checking lot of other insights, main being that the market effectively reversed (ongoing zero bar signal value).

There's not so many comments on hedging topic out there, so it took time to accept (algorythmic/architecture) complexity of the process and i progressively built an interesting stuff (hope others would agree). At this stage, after many many patches and debug, one big big problem raise an algorithmic complexity fearing me.

All my losses are stopout (worse case having many orders on many pairs), occuring at sucessfull hedge close cause i haven't took in account the fact that ongoing leveraged hedging leads to mezzanine system, and you must respect a strict closing rule based on orders chronology sequence....i' tearing for c-double linked list in mql making solution to this so simple.

I'm still earning money, but nothing compared to what's gained when no stoploss ( sorry, STOPOUT)....Damtoul, i'm not rich yet, just staying alive and going on tweaking this "smoke can"...conclusion : to many stopout losses, good hedging performance with poor clearing approach.... it's not the worst situation out there, but what a big deal for such a small wage !

Having reached my approach backbone, leading concept for me is Multipair Cash Management, justifying the need for me to tackle this challenge with a solution done of of Connector and a Central EA, cause it was an absolute necessity to implement a sound cash management isolation, thus in a centralized way.

At start, account capital is equaly broken between traded pairs, each therefore applying an immunization factor limiting it's trading capital to 75% of account balance received (25% leakages cushion for computing errors, swaps values, light loss drifts during hedging..., but mainly to reduce impact on capital of of the growing leverage mechanics allowed to the loosing order undoubtly following successfull trades). Therefore profits made are 75% dropped in this cushion, 25% added to trading capital...

This way, each connector draws an orders board at the different timeframes of the 6 known types on his chart, with a stage levels board of the trading signal checks at these timeframes, and almost a cash management board, the Central EA doing the same on his pair chart. This eases figuring out what's going on for each traded pair with a single eye drop, looping trough open charts. Of course, the whole is particularly heavy in global variables, many many includes... so i'd like to get your point of view.

How do you handle those multipairs cash management issues and monitoring needs ? What kind of signal mix do you use ? Is it a 24H-5/5 screening market EA ? Did you think about timing the market (open places market hours, GMT to Local Time Translation...) ? Use stoploss ? What about hedging ? Bought Yatch last week (i could'nt) ?

Looking forward...

 
Heavybabar:

Hi babar,


nice discussion we have. No prob for english, that's the same for me. :)


First if you trade correlated currencies, your indic/EA attached on each currency will generate same buy signal, and multiply your P/L by the number of currencies. I talk about the problem because i see it every day. :)

About your post and strategy, mine is simplier than yours. I explain :

- Multicurrency management : each EA/pair can open between 1 and 3 order(s). When indicator sends a signal, EA open is lots<3 and margin>1000%. Each EA can open and close and work if these rules are OK. GVs are equal to the pairs traded : 25 in my case.

EA trade only standard lots (1$/pip)

- For entry/exit i use ADX to define market (trend or range) and volumes (a little mix of mine from the Wickoff theory : Volume Spread Analysis). EAs trades on Daily. It's 24/24h 5/5 screening.

- I don't care of market hours, except if EA detects trend it opens at 0 am (new bar) else wait for an entry signal in the day (mainly range).

- SL and Hedging..... that's a good question..... i've worked and thinked about that a lot.... maybe i'm wrong maybe i'm right. To avoid losses i studied hedging... a lot, but i you said, hedge coding becomes very rapidly complicated... and instead of managing one loosing orders you have one loosing and one gaining and a gap.... and so on..... and when you close your hedge, if it's a false signal you amplify your losses instead of nullify. Not good at all.

So..... how do you gain money on forex : gain more pips than you loose (leverage only amplify). How do you gain more pips than loosing some? Let profits run and cut your losses tight. It's not easy to do as you trade manuel, it's even hard with algo trade, but it's the key to success.

IMHO code your EA like that. That's what i do/try. My greatest success for the moment is having an EA running with a floating +-300$, instead of ealier versions that gains a lot in equity, but keeping losses floating=>bad, very bad.

I use Stop And Reverse strategy too : a very large SL for protection (300 pips), but if i have a loosing position and indicator see there a trend change, it tells to EA to close and reverse position. I need to make adjustement but it works very fine!!

Reverse have a double lot size and a TP equal to opposite losse=>when i have a 50 pips loss, it have great chance to end with a 2*50 pips profit. :)

- I don't have a yacht yet, and think never got out. But if my EA can give me an income to live humbly it will be great. For the moment my EA trade only on demo mode because it can earn 1000 pips a day, and then loose 800 or 1200 the next 5 days.... I work hard to balance that, and having an EA with a softier DD.


Dam.

 

Hi Damtoul,

Don't know what you mean about volume trade analysis. If it is about metatrader volume reports, i knew that these were just number of ticks occured. Of course one might asserts there exist a good correlation between tick count and contract volume, but i've quickly let it aside when i heard that.

What kind of use do you make with it ? Appears to be a good filter on your trend signal hysterisis at sometime ?

Would like to know about.

Concerning your hedging remark :

..and instead of managing one loosing orders you have one loosing and one gaining and a gap.... and so on..... and when you close your hedge, if it's a false signal you amplify your losses instead of nullify. Not good at all.

I really jumped this over implementing own ordercloseby processing on both hedge legs and maintaining an hedge gap exposure following market swing directions. This way i turned statitic hedges in dynamic profit taking/losses reductions strategy.

Looking forward

 
Heavybabar:

Hi,

Great to see your work on multiple pairs with an EA. You have good insight into the methodology. I am working on a single EA that watches all pairs of the broker. It does miss ticks, but the response time is adequate for my implementation and time frames of H4 and D1. An endless timing loop seems a good solution, but I think it may have to be in a script instead of EA or indicator to run between ticks. That is the next hurdle. Either way, the data seems timely enough to watch all pairs and place trades. I get the pairs I want to trade from the symbols.sel file, which allows me to select them from MT4 in the upper left window. I currently run all pairs, and have the EA decide which to ignore dynamically, as one of the correlated pairs may have a better setup, so it allows that one and disables the others. Just my approach to the problem. You guys seem to have a good approach as well.

Reason: