Hi Jacques,
I'm working on this since a while, with some interesting learned issues of this hedging tactic.
Actually the EA is a 24/24-5/5days multipair screener/monitoring.
Whole framework is a "smoky" built of many many include files, lot of 4Dim arrays, plenty of global variables and board printing on charts (orders/timeframe, pair isolated cash management, computed signal decision rules values/timeframes)...
Schematically, the core engine (EA) appears as the processing algorithm backbone, orchestrating methods imported from includes.
Great attention must be given to chronology sequence, as one would assemble the building blocks in a poor way, and even concludes it does not perform well enought to deserve more brain shaking...
Form a bird eye view, start with an Array book, something to store like 50 parameters of each 200 orders (don't laught please.. :) )
Immediatly following, write BookLoading(), BookBackup() methods in order to store this book and retrieve it from disk in any crash case
Each created order fills this bookArray with is attributes (ticket, type, symbol, margin, lots, PipsProfitTarget (if any), StopLoss Level (if any)....,hedgingFlag,...,HedgingTicket,.....) just to point out the main attributes needed to further implement a sound hedging information processing..
Let's now say that each order openened is thus referenced, then you can built principles on what follows :
As frankiev2 really hates stoploss (like you guy, really been wondering when i'll finally ear this from someone else...) use the order StopLoss book field as a LHP:Limit Hedging Price (R), in order to state wheter or not he went in the Blue reading the bid/Ask quote..
If crossed, then EA launch new order with appropriate leverage and adequate attributes in case he would himself become the dark side of your journey...the rest is just a question of sushi sushi cofee cofee....don't forget to use appropriate fields to link orders hedging-hedger and so on...
Ok, i came out with this like frankiev2 is asking for. I've been trading my live account like this, going long/short at entry time (no matter, blind diving) then arbitraging net long/short exposition following market extremums....i won lot of good money and lost lot off the best money...
Just to say that after a while trading like this, sleeping at midday (i'm in GMT -10), worring about next loss following good trades, i then started implementing this discretionnary decision rule step-by-step...solutions brought more and more confidence, absolutely necessary to confront with some algorithmic eadhaches (don't now if well written, see what i mean...thanks).
Going multipair this way on hand calls for more neuronal density than mine, even one pair case did blow my calculus speed...many times i've tasted my broker STOPOUT laughthing in off-voice...damned once again bursted two pips before the market reversed 50 pips in awaited direction...OK guy, forget restaurant, dance and this gorgeous creature, you're know riding a bycicle (if left...)
Serious advice : as you give away stoploss, never forget it's still in your Back ! STOPOUT.
How can it be, hedging is made to proclude that ! But you often face (much more than you think) leakages during hedging...arising from the fact that hedging is just hedging and there's no free lunch out there, market dynamics rest mysterious even once revealed...
frankiev2, whatever kind of leverage mezzanine built you will finally come to, remember that your net exposed hedge margin cannot be more that initial margin based on capital account at start, you can build up whatever kind of mezzanine you would like or be obliged to deal with, but your net margin gap can't exceed your account value minus left free margin...
Each time you open an order, what you don't want to be a stoploss is nevertheless a freemargin value you must clearly not wipe completely, the only difference is that you start hedging just before the zero bound get tilted.
So let's illustrate owning 900$ financning buy(1 lot) with 600$ locked margin (remenber further that this is the most well protected part of your money, think of it as an incentive to max the leverage), and a 30 (bad) pips reverse move costing 300$ (badpips cushion), wich set your LHP (in place of stoploss) 28 pips bellow OrderOpenPrice() (2 pips to pay for EURUSD spread at Hedge opening).
After a while (sometime really quickly) the market hits the LHP, hedge time has come : then set Sell(1 lot), wich cost nothing and caracterize the Cristallization Scheme : you can deal with 300$ is your latent loss surfing the market wave, but it's really a nighmare when it takes a long time rolling-over almost on hands, late at night after darkness at noon.
If so, your free margin is now 600$, the loss will never exceed 300$ .... but you don't just want to play the casino wave...isn't it : Trader You Are !
Leave this Static Hedging, even if the Surfing Casino Wave Tatic sounds somewhat a bit of this kind move to real dynamic hedging.
Starting at least with a Sell(1 lot) hedge, you then decide to push the 600$ redeemed by such a perfect asset/liabilities margin matching, short side thus gearing the hedge leverage factor. Imagine you went on full on a 2/1 bet : now a single market drop around 3/4 of the initial 30 loosing pips will bring you back in light. Wonderfull as it Should Ever be.
But what if market reverse long just slightly enough to put you in trouble ? In fact it now comes clear that you where in a range market and your parameters set your hedging criterias on is waves bounds .... someone laughing in my back ? Damned broker, tweaking ticks to burst me ? ...be cool, it also happens like this in the strategy tester on history ticks that none is distorting ...
Ok ! Bad trick as only half of starting loosing pips (15=30/(2/1)) will suck 300$ free margin left cash on sell(2 lots), asking 150$ more to keep still loosing buy(1) alive : STOPOUT, and you get the worse, lost 450$, but fortunatelly leaving on 1st floor...can still dive dans la Seine...(for Frenchies)
But in this Mighty Day, clever we were : we knew about this so we tailored the sustainable cash management sell(xl lots), setting his LHP at y$...as best bargaining between financing additionnal sell lots and raising cash badpips cushion with the 600$ : one part secured, other at risk ... don't get too academic, it's just cause it sounds well
Then, each new hedge means more freemargin cash, even if you manage to keep a dynamic leverage while rolling-over, this one may accidently decreases to death, your whole initial locked protected margin being finally swapped to free margin under broker (damned) appetite...what follows has really beeter taste : trust me. Why don't A Man knows when he Lost ? And you my friend, would you ?
Conclusion, what your aiming at involves much more features than the simple principles highlited above, and i'm now speaking to the programmer : Jeacques you're both commiting to an exiting but really really demanding quest.
While waiting to ear from you, i go back tackling my actual challenge : how winning the 'Mikado' game of Hedge Termination with the Broker Knife on throat...when you're swinging whith no less than 7 linked leveraged hedging position.
You're out of the blue, joint P/L >=0, it's time to deliver the hangued man, but you must know the twist, a bit of sell close, then a bit of buy...and so on...but carrefully please, one mistake and all orders even on differents pairs will be reseted by your broker...
At end, did you knew that at close, broker does not really act on global settlement, profits coming in account after free-margin sustainability check, quite subtle believe me, so when you close an hedged or hedging position be sure that left orders margin financing does not rely on net profits you're expecting to receive, cause you'll get the STOPOUT before getting your gains...the free margin is not zero does not give the complete scheme.
Must think of OwnCloseBy() method for hedged orders, mql ordercloseby() stating that you know exactly how much lots you'll like to close, but how did you get this number ? ex : Closeby(0.5Buy,1.2Sell) at Buy(-500$), sell(+300$)....see what i mean...exiting must Jeacques think, i wish you'll like it...
I'll be glad to read your point of view.
Sincerely,
Hi Frank,
i have already coded a such system with some little differences : i double lot size at each hedge (0.1,0.2,0.4 etc...).
This EA made a "shark" profile on my equity curve. Growing and closing all orders when floating positive make shark tails. Nice and funny. And then i abandonned this way when i saw the same thing like you : in ranging markets price bounces and open lots of positions. Your solution of having a max number of open positions is a nice way to do.
One remark :
when your closes your loosing positions your net isn't 0 but your loss is the sum of your positions spread*size of lots. I agree it's better than a big SL, though it can be important with big lot sizes.. :)
With a such EA, to have a light and nice algorithm you must use arrays as said by babar, but a good programmer can handle this almost easily.
Best regards,
Dam.
Hello HeavyBabar and damtoul,
And thanks for your comments. I was surprised this thread was still silent.
You are both right in your explainations about the plus and the minus.
I have coded this system and I am actually finishing tuning it.
That's true a lot of money is needed for the operation to be successful... and there is always the risk the limit you fixed for the max hedging is broken by a ranging market.
So when I said 'tuning it' I meant finding a good compromise between :
- the strategy providing entry signals,
- the HedgingMargin = after how many pips the hedging order will be open
- the Max level of hedging orders = to what extend the system should be continued before accepting a loss. (and the loss will be at maximum the HedgingMargin*2*GreaterLots)
- the maximun of orders you like to open simulteanously, in conjonction with the ratio : winning operations / finally blank operartions (resulting with profit = 0) / number of operations performed ; because the goal is to making profit and everyone knows while hedging you don't make money.
First of all, it has to be used with a strategy providing signals in a trending market. I wish I had a nice scalping strategy like the one from DayTrader seems to have built (see this post), something like with 80% winning orders with SL=30... But unfortunatly I really don't have a clue on how it is possible (the solution I have in mind is issued from a non scalping system and will trigger orders only once in a while, I don't think enough to be interesting). By the way, if you have a solution like that, I will be pleased to have a look, I will certainly learn something from it. As my style is more Swing Trading, after a few tests, I really wondered if I will use this hedging system one day with real money!
Frankiev2 described the system with a HedgingMargin = 15, you can easily guess it is not enough with swing trading.
I met Mister STOPOUT too when I first came to work on the Forex (you know the one who close all your orders all of a sudden) ; so I became something like very precautious, if you see what I mean. I am always afraid of forgeting a detail when modifying the Lots size calculation, it's always so painfull when you discover you had. To go short on the explaination about how to protect your operation (I say 'operation' talking about the process from the opening of an order with the hedging system ON to its closure), I used a chart you will find in the attached document. I think it is understandable enough for others (sure HeavyBabar and damtoul will understand) . If you are not understanding it, think it is better to before continuing to build such a system. It has to be mixed with the broker limit system not to be stopped out. The EA just reserve the necessary amount for the entire operation in the worse case before opening an order. The chart gives you the maximum loss the operation can have according to the setting, it is better to think over that before going into programming... I made my choice and now the future will tell me if it worth the doing...
Of course, to avoid bad situations such as a sudden reversal of the trend, all hedging orders must be closed in the same time.
About the programming: I don't use arrays. I am not used to. I do not store information I share with the server, or if you prefer, the needed vision of the context is rebuild for every order being processed. Well it's may be a little bit more complex but at this level of complexity I think you will agree to consider it is the same kind stuff.
I wrote the routine in a Multicurrencies EA as well. It has functions for multi strategies signaling, Money Management, trailing, etc.
I do not use includes because when I first tried, it didn't work and apparently that was not my priority to solve the problem (that was when I first began to write the EA). I forgot that point and I will have a look deeper in the documentation later on.
I really appreciated your comments, thanks again.
Best regards
Hi Dam !
Nice to meet you once again, as you see i'm still lurking aside considering different point of view.
Your way deserve consideration Jeacques, all programmer knows that the meaningfull issue is to have it working, not digging in pleasant but poetic considerations, so just do it the way you feel it !
What's really interesting with you two Jacques and Frankie is that you gained professionnal skills in the area, despite my background in theoretic derivatives mathematical finance i'm a newborn on the real life trading topic, so i can't really figure out when i'm stepping the right way owing to best practice standards in the field, or when my conceptual approach would appear completely screwed to professionnals.
So i'm really glad to discover your thoughs. Big Thanks to Damtoul Too, who, may be, will reconsider his hedging attempts and implement them. Don't get pessimistic Jeacques, hedging is not just the insurance side of your trades, as frankie showed in his exemple it can really act as a profit making oriented strategy, almots when it comes dynamic.
I came out with the result that defensive hedging is a poor tactic, the core principle lying in a good leverage agressivity and reactivity to market pulse . One may finally be deceived playing the good old Daddy hedge style, whereas a more adrenalin pushing approach ends in much more satisfaction, speeding the hedging process and gathering profits.
The more cool you are on hedging, the more leakage you endorse while closing/cutting part side of hedges on market swing.
Ok, keep the rest to when it comes interesting for both of us to discuss about, a the time some observations to Jeacques comments (Damtoul already knows what i'm about) :
1 : Hedger tunning : i'm setting the hedgingMargin from market volatility at entry time. Can also try distance from bid/ask quote to a long moving average or any indicator signal level raising a meaningfull compare with price, or explore garbbage collections of this kind.
2 : Max level of hedging orders : this special feature can be anoying at some time -> (3).
3 : Entry signal : from point (2), when (1) becomes necessary then (3) must be reconsidered. Worse reason for an Hedge to occur is when (2) is not far enought from market context measures, can't say if it should always be 10,20, 50 or 100 hedging pips as this order attribute may be dynamic following market situation. But when you get caught on this type of hedge you should stay confident with (3) and just correct with a new hedge order thus reversing in a 2 orders on goodside / 1 against (bad Hedge)).
At leats 10 pips might even be enought in some market context to accept that even the signal was good something new did happen which caused market reverse and was not anticipated, or that it was just a false breakout : thus setting 30 pips before hedging makes the problem, opening hedge side at new market reverse, this one engaging in a new swing dynamic, and may be will never recover to the first openprice() order. Then both hedge legs might be loosing.
If you plan to execute signal raised at high frequency timeframes (1Mn, 5Mn) the tunning quest of the wathever happens good HedgeMargin pips might just leave you sticking to the dynamic approach.
Grasp your own evidences, i'm interested on.
Remember that all factors above interact in EA testing, so it is sometime really difficult to distinguish the real cause of a poor performance. Just trust your Faith...and don't give it up easilly...
Best regards All
Hi HeavyBabar,
For the time being my system is
- bringing the total operation to a result of 0 when trend is going the other way
- leaving the first order winning some pips when the trend finally come back in the forecasted direction
- may loose some money when reaching its limits + trend is going the other way
It is not so bad, I just have to act in a way to avoid the third option. Opening orders fitting the trend to come, that's the signaling functions problem.
I am not so willing to tune the HedgingMargin according to the market volatility it is not a good criteria for forcasting the trend to come, may be for the next minutes at max. Sometimes the operations last hours. And sizing up volatility on higher time frame (above H1) is not compatible with the system wich require a low HedgingMargin.
But any way my signaling systems take the factor into consideration, that's may be why I am not intending to report it in the hedging tuning. Well, like almost everything else, it's a choice that has been made one of those day. You're right it has to be reconsidered times to times, that one of the purpose of such a discussion, isn't it?
Turning the hedging system into a winning strategy, well, I tried a few options but with no success. It is quite costly to open a first order.
I could also open a reverse position in the same time i open the first order and then make profit with the order that will survive the two operations... I don't believe in such strategies, with such a system you need to open a lot of orders to finally make money and usually you loose at least the spread. I prefer to open orders according to the trend analysis.
May be some ideas will come...
On hedging, I think the best approach is to use hedging to take profits on a short timeframe, while holding a longer-term position. For example, let's say that on the daily chart, you are long in EURUSD, looking to clean up on a trend that should hit your TP in several days. During that time, much price movement occurs at the H1 or M30 timeframe. Are you going to just sit there and watch it? Why not trade it instead? Selling, buying, whatever... the point is that your short term trading should not be impeded by your long-term position simply because you happen to be working a single pair in a single trading account.
As far as making an EA out of it, I don't know. It can surely be done, but even within a single timeframe, hedging amounts to short-term trading to maximize profits or insure against losses from a position held longer than the hedging trades (although I suppose one could reverse that perspective). So, why not just accept this timeframe differential and place your long (or short) bet on the daily chart, then day-trade the hourly charts? It may not be "hedging" in the traditional sense of the term, but it is holding (for a short time) contrary positions in the same security.
RS
Okey people.. i need help, advise or direction.. I'm a trader, not a programmer so please dont make fun of me if I ask stupid questions.
I'm not here to make anyone else make this EA, I'm prepared to make if myself.. but i'm here hoping someone can help, know of something like this have been done already and can show me where I can get more info.
Or anyone think this can work for them also and have better programming skills than me and are willing to help out with the coding.
This should be a order management EA, or a MM EA.. take your pick. I use this method today, with huge succes, but it's a pain to do manual and I want to cover more pairs to get better gains on my account.. so thats why I thought an EA should be able to do this for me.. much faster and more correctly.
Background:
I hate loosing money, i hate SL because when hit.. even if it's there to save you, you have lost money when that trade have ended. But when the SL is hit it's because of two reasons.. you SL was to tight or your trade was in the wrong direction.
But if you could have a SL that saved you and when hit, did'nt make you loose anything.. would'nt that be great? I have that.. how?, by semi hedging.
examlpe:
I take a buy trade 0.1 lots at 1.2950.. I put a TP 1.2965 and a SL 1.2920. (the SL is double the TP, and will be on all orders). At the same time I place a sellstop at 1.2935 0.2 lots TP 1.2920 SL 1.2965. If my first order hits TP then I'm fine.. 15 pips plus and I remove my sellstop order. BUT if my sellstop order is hit, this means my SL is hit as i trade with a 15 pip SL. By now I would have lost 15 pips, but thanks to the sellstop order, i'm hedged. If the sell orders TP gets hit now.. I will get out +- 0.. at BE.
0.1 x -30 pips = -30$
0.2 x +15 pips = +30$
Net = 0$
But with only a SL of 15 pips on my first order I would now have 15$ less on my balance.. BUT with this method, my trade went wrong and still didn't loose any money.
But what if the trade turns before the second order TP is hit?
When the second sellstop order is activaded, then i place a third order, buy 0.4 lots with the same numbers as the first order. Buystop 1.2950.. TP 1.2965 and a SL 1.2920, and if that is hit, i place a new sellstop for 0.8 lots TP 1.2920 SL 1.2965 and so on...
I have been in a trade where I had 5 positions open at the same time, but I missed that the market was caught in a range, usually I get 2-4 positions on a trade if i get it wrong. i have set a max of 6 open trades after that i will hedge them to neutral.
Example..
Buys open at 0.1 lots, 0.4 lots 1.6 lots = 2.1 buy lots
Sells open at 0.2 lots, 0.8 lots, 3.2 lost. = 4.2 sell lots
The next position taken here will be a buy for 2.1 lots so im neutral hedged also.. all TP and SL should be removed, because if i get all these positions activated, I'm caught in a ranging market and it's better to close the last position when the market is not ranging anymore.. and in this case, the last position should be closed when you see a sell signal.. strong..
Therefor, you should not take trades and using this method if the market is ranging.
So what do I want the EA to do?
This is a very nice method and gived me better confidence in my trades, but it's hard work placing, manage the trades, andi want to trade more pairs.
So an EA that places an opposite buy/sellstop order as soon as my first trade is placed.
The EA should then monitor that trade also, and if the first orders TP is hit, it removes the second STOP order. But if the second STOP order is activated, it places a third buy/sellstop order and so on.. until the trades have ended.
The EA should keep track of orders for diffrent pairs.
If it could be programmable, it should monitor more than one trades in a pair.
Example:
In my tradingplan I use maybe 3 tradingsystems, breakout, divergence etc. I might place one trade on a breakout i find. then i place a trade on a divergence i see.. and so on.. So It could be great if the EA could keep the trades apart, maybe with the help of a number or a comment in the trade.
Finally.. I just want to place my trades on my signals. Then the EA would monitor them all and manage them until I'm out of them..
SO has this been done by others you know of, can you point me in the direction..?? Or can anyone hint me on how to do this.. or even better if any with much better coding skills feel they would like to help???????
I use this myself with great succes for the last 6 months.. and my account is growing with a nice curve.. thanks to the absence of the SL.. and the balance is never less after a trade even if it goes wrong. The only thing you need to watch is ranging markets.
I will try to answer questions on this, but I'm mostly here to make an EA doing this painful work, so I can concentrate on my signals.
Help me...
many thanks....
if somebody has the EA, please share
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I'm not here to make anyone else make this EA, I'm prepared to make if myself.. but i'm here hoping someone can help, know of something like this have been done already and can show me where I can get more info.
Or anyone think this can work for them also and have better programming skills than me and are willing to help out with the coding.
This should be a order management EA, or a MM EA.. take your pick. I use this method today, with huge succes, but it's a pain to do manual and I want to cover more pairs to get better gains on my account.. so thats why I thought an EA should be able to do this for me.. much faster and more correctly.
Background:
I hate loosing money, i hate SL because when hit.. even if it's there to save you, you have lost money when that trade have ended. But when the SL is hit it's because of two reasons.. you SL was to tight or your trade was in the wrong direction.
But if you could have a SL that saved you and when hit, did'nt make you loose anything.. would'nt that be great? I have that.. how?, by semi hedging.
examlpe:
I take a buy trade 0.1 lots at 1.2950.. I put a TP 1.2965 and a SL 1.2920. (the SL is double the TP, and will be on all orders). At the same time I place a sellstop at 1.2935 0.2 lots TP 1.2920 SL 1.2965. If my first order hits TP then I'm fine.. 15 pips plus and I remove my sellstop order. BUT if my sellstop order is hit, this means my SL is hit as i trade with a 15 pip SL. By now I would have lost 15 pips, but thanks to the sellstop order, i'm hedged. If the sell orders TP gets hit now.. I will get out +- 0.. at BE.
0.1 x -30 pips = -30$
0.2 x +15 pips = +30$
Net = 0$
But with only a SL of 15 pips on my first order I would now have 15$ less on my balance.. BUT with this method, my trade went wrong and still didn't loose any money.
But what if the trade turns before the second order TP is hit?
When the second sellstop order is activaded, then i place a third order, buy 0.4 lots with the same numbers as the first order. Buystop 1.2950.. TP 1.2965 and a SL 1.2920, and if that is hit, i place a new sellstop for 0.8 lots TP 1.2920 SL 1.2965 and so on...
I have been in a trade where I had 5 positions open at the same time, but I missed that the market was caught in a range, usually I get 2-4 positions on a trade if i get it wrong. i have set a max of 6 open trades after that i will hedge them to neutral.
Example..
Buys open at 0.1 lots, 0.4 lots 1.6 lots = 2.1 buy lots
Sells open at 0.2 lots, 0.8 lots, 3.2 lost. = 4.2 sell lots
The next position taken here will be a buy for 2.1 lots so im neutral hedged also.. all TP and SL should be removed, because if i get all these positions activated, I'm caught in a ranging market and it's better to close the last position when the market is not ranging anymore.. and in this case, the last position should be closed when you see a sell signal.. strong..
Therefor, you should not take trades and using this method if the market is ranging.
So what do I want the EA to do?
This is a very nice method and gived me better confidence in my trades, but it's hard work placing, manage the trades, andi want to trade more pairs.
So an EA that places an opposite buy/sellstop order as soon as my first trade is placed.
The EA should then monitor that trade also, and if the first orders TP is hit, it removes the second STOP order. But if the second STOP order is activated, it places a third buy/sellstop order and so on.. until the trades have ended.
The EA should keep track of orders for diffrent pairs.
If it could be programmable, it should monitor more than one trades in a pair.
Example:
In my tradingplan I use maybe 3 tradingsystems, breakout, divergence etc. I might place one trade on a breakout i find. then i place a trade on a divergence i see.. and so on.. So It could be great if the EA could keep the trades apart, maybe with the help of a number or a comment in the trade.
Finally.. I just want to place my trades on my signals. Then the EA would monitor them all and manage them until I'm out of them..
SO has this been done by others you know of, can you point me in the direction..?? Or can anyone hint me on how to do this.. or even better if any with much better coding skills feel they would like to help???????
I use this myself with great succes for the last 6 months.. and my account is growing with a nice curve.. thanks to the absence of the SL.. and the balance is never less after a trade even if it goes wrong. The only thing you need to watch is ranging markets.
I will try to answer questions on this, but I'm mostly here to make an EA doing this painful work, so I can concentrate on my signals.
Help me...