I have been a tad busy this week to fine-tune my "old and faithful" manual strategy that I used to do with FXCM on their TS2 for USA.... and trying to replicate the exit logic in mt4. I could manually trade over 200+ trades during events with significant moves
Here's my ask to see if there is a better performance-tuned solution for my exits within the context of doing a Close-All @ %equity reached
Open Trade Volume: could be over 2000 trades to close when some % of equity has reached
All uni-directional trades to close on just one instrument
Looping all open trades is very slow and drains on my floating profit/loss while the loop executes. Not GOOD !
Leaving slippage aside, Is there a better solution to do a massive close-all?
Not a coder here, but having some experience with large number of orders close by closures. One way to save a buck or two is to close by at a desired low spread. For example if the spread is 0.5 pips on average, but it floats from 0.0 to 1.0, then setting 0.1 as a closure target will slow down the speed of closures, not loading the broker server, cause 0.1 spread is happening not very often and not for much long.
The problem here is the mt4 terminal gets heavy loaded while chasing the 0.1 spread. Not sure why exactly, but it does. And 2k trades is a super heavy burden for the buggy terminal, already... It may become unaccessible for large portions of time.
Another solution, might be, to close by from a different terminal. Do not close by from the same terminals where doing the trading.
double MAX_SPREAD_ENTRY_FILTER= n.n; // (in pips) Enter 999 to ignore spread widening. Check for MAX_SPREAD_ENTRY_FILTER allowed prior to opening any positions //
double MAX_SPREAD_EXIT_FILTER= n.n; // (in pips) Enter 999 to ignore spread widening. Check for MAX_SPREAD_EXIT_FILTER allowed prior to closing any positions //
I manually enter and then EA takes over the aggressiveness when price goes in my direction.... and as long as my average price is above/below the current bid/ask and as long as I have margin freeing up with floating profits, I keep adding on every tick... until my %equity target is reached. Go big or Eat sh*t type of a deal (on a small sub-account during events or special conditions... 1500% within a 30-50 pip move :-
0.1 minilot buy >> 0.1 minilot sell
1000+ buy trades of varying sizes totaling 20lots >> one 23 lots sell
varying lotsize and tradecount buy trades >> varying lotsize and tradecount sell trades....... your script will close only hedged trade sizes and leave the unhedged trades open/floating?
Keeping in mind that I am not too worried of trading cost.... speed/execution/performance overhead is what I am concerned
EDIT : HAve you played with "MoveSLToAverageBE"... trail the average price and get the f*ck out
When everything is hedged - then you can manually do a multiple-closeby from the terminal to reconcile them all at once or programmatically loop the trades and use the closeby func. Time is NOT of the essence for this part of the process because your position is already closed.
It's sad that not many traders know they can manage their positions in this manner so they end up wasting money by not using closeby -- and waste even more money by closing down individual trades one by one while price moves against them (inevitable with FIFO brokers).
To answer your question, I am researching the distance trading from the average price. On demo, these are my most successfult setups. But they come with a DD most of the time, and now, after this week of worst signals ever, I am thinking of setting the average setups, live during the weekend. Not surprisingly, the average price just works great, cause closing behind the original entry is common style there.
Hats down to you, cause you did it with respect and in style.
About hedging. They hate it here. Again, cause they understand hedging, as much as they do understand the hedge close by...
Sir Nico will go to Heaven. I am sure!
p.s. veefx in filename only means I like/use/tweaked the code. I am not the original developer.
here's another useful tool I developed. Order line on MT4 is crapshit. it only draws a line bit when not tell you when/where on which candle or on which timeframe the order of taken. when trading multiTF, it's absolutely critical to track our trades by timeframe....to keep track of scale-bility etc
EDIT: I use the ex4 version but strangely can't to find the mql code for it.
I still call it hedging, in my own trading terms. There are two major ways to hedge for me:
1. By opening buys/sells.
a. and keep both opened all/most of the time.
b. same as above, but close by the hedged lots and keep the net lots opened only, somewhere around the end of the day, to avoid extra swaps.
How you close by one against the other by leaving opened the net lots remained, is crucial. If you have 1.0 lot buys and 0.5 lots sells and close by randomly any 0.5 buys vs any 0.5 sells is not the same as:
2. closing a buy instead of opening a new sell.
The developper I work with 4+ years already, told me it is the same (1b and 2), but in reality the result is so different. 2 can hardly being called hedging, yet it is for me, as I instead of opening a sell, just close the first buy opened, ext.
So, managing the net opened orders is all about in trading. How you get there, hedging, nedging, gridding, lot(to), ext. does not matter.
Bare with me please as I want to see if this scenario will have any adverse impact to my overall strategy. first, I base by position size only on AccountFreeMargin() and not accountEquity(). If I have free margin, i take the next available signal.
With this being the case from MM standpoint and assuming all my SL and TP for the same pair is at the same price level and away from the average entry price... Can I use two "consolidated hedge" Sell hedge orders one for SL and another one for TP with hedged size=total size of buy positions?
if the answer is yes, then it will free up AccountFreeMargin() as now the positions are hedged. This will effect the position size of my next signal i.e. increasing my exposure on the pair which the new signal is generated on. Not good BUT it is REALLY good if I am leaving the "consolidated Hedge" running at TP and Closing the "Consolidated Hedge" by immediately executing your closeby script.... this way, I am only FREEZING the profits from average entry price (i.e. TP triggered positions) and unlocking/exiting the losers right away. At the end of week/month, I can do a closeby across all positions to realize the cost savings on my profitable hedges. Win-Win at the end I think. Do I have this right?
© Forex Factory