Math Question: How much volume do I need to scale up a position while keeping the net position open behind my trailing stop?

Greetz peepz :v:t5::sunglasses: I’m not a frequent forum poster, so I’ll keep it short. I’m working on an EA in MT5 and have a math question for y’all.

Say I have a netting account and I placed a BUY position on EURUSD from 1.0 lot (V1 = 1.0) at my opening price (P1) with an profit target of 100 points for $100. This is not a concrete “Take Profit” order, but my first profit target in what is expected to be a long-term trend. At this target (P2), I intend to place a trailing stop half way between P1 and P2, at 50 points for $50 of protected profits, minus pre-calculated fees (swap, commission, etc.), so let’s say $40 secure profit. Also at this point, I’d like to increase my position size such that the new opening price is exactly $10 behind my trailing stop, covering my fees at the TS and still leaving some wiggle room for the trend to continue.

I’d like to pre-calculate several of these “scale-up” points in advance to create a sort of protected grid position management system. When a position is placed, I want to pre-calculate and place the stop orders necessary to always scale up at a volume that keeps my opening price and fee coverage protected behind my trailing stop.

I’m currently working on this problem, but it seemed like a good idea to put it out to all of you too.
Thanks in advance. Check back to find out what I come up with.

-Zee :sunglasses: :+1:t5:

I only know MQL4, so I can’t help you with the code, but philosophically I approach a similar idea a bit differently in my code. When an order is placed, in addition to all the normal stuff I’ll also set an int variable (to be used for a trailing stop) of X pips. When I hit my tier 1 profit target, I liquidate half of the position and move the stop loss up/down to the original entry point, to lock in quick profits and make sure that losses are not possible going forward. From there, if the remaining half of the position continues profitable movement for an amount of pips equal to the trailing stop value x2, it will move the stop loss X pips (as defined in the trailing stop variable) away from the current Bid or Ask price (depending on long or short). I move the trailing stop X pips away after X*2 pips of movement to create a bit of a buffer and prevent spammy stop loss modification. Position is exited when reversal breaks that trailing stop, wherever it ended up. Hope that all makes sense! Good Luck!

DUDE!! I owe you a beer… or 12! Thinking about my response to your OP made me realize I missed something stupid and obvious in my EA. Somewhere on my list of things to do was “figure out what all those tiny little losses are from”. OF COURSE if I only move my stop loss to the entry point I’m going to eat spread cost every time I hit a T1 target but fail to hit a T2 target. DUH!!!

It was a simple matter to modify the function that moves stop loss to entry point to have it pull the spread from marketinfo and add it to the value. Look at the change that made to my profit curve and performance!!

This is EUR/USD from 2005-today. It improved my profit factor from 1.14 to 1.20. Thanks for making that light bulb go off, bro! CHEERS!

Hey, enickma! Thanks for the reply! Glad it got you thinking and spurred some improvements to your bot. Those are certainly excellent gains and steady growth curves. Looks a lot like some of the Martingale recovery trading I was working on. Respect bro! :sunglasses: :+1:t5: I’m curious about what time frame you’re trading and average trade length. I’d love to talk shop wit ya more privately as well.

Reporting back on my progress: Let me describe the logic. Mine is a bot that capitalizes on large violent moves or steady strong trends in the market. After finding an entry into the market with a secure 1% SL, the bot waits for price to move far enough into profit to cover the commission of the trade times four (2 x (entryCommission + exitCommission). Basically enough to cover commission in/out twice and leave some wiggle room for the trade to continue. After covering the commission (plus an extra point or two, to cover for slippage or whatever), I gauge my scale up. Each scale up takes an additional position equal to the size of the previous position volume, causing exponential growth. By a simple formula, I know that taking two positions at the same volume, yields a net position with an open price halfway between the two entry prices. If I know what price I’m buying in at I can place my stop loss above it. At each scale up it increases in volume, but resets the progress of the trade. What this does is create basically a break even zone as opposed to a break even point. It has to clear a series of quick short-gap targets within the span of one complete TP distance. After the span of 1 TP, the trade just slides behind the current price at half trailing stop. The bot only manages one position at a time, but looks for stop order opportunities on multiple currencies. These large scaling events happen 2-3 times a week and usually have > 10% returns per trade with bigger trades able to give 50%-100% returns. The bot I’m working on should hopefully turn over 200%-300% in about a month. Here’s some back testing I did for the year of 2020 starting with $1000 (x500 Leverage) in January. I ended the test early if it hit 100k from 1k, because frankly I’d heard enough :money_mouth_face: :money_mouth_face: :money_mouth_face:!

Notice how the price hovers around break even for a time, then takes a large step up. And this is just one currency pair (EURUSD) on the M5 timeframe and you can see it primarily trades during specific hours of the day. This power is scaled up when looking for opportunities on currency pairs that are more active during the Asian session. Give my scaling method some thought and see how it applies to what you’re doing. I’m trying to go live for the election and eat up those violent moves.

That’s really interesting! I’m going to have to read that over a few more times to fully grasp it I think. Good luck with it, and please keep us updated on how it’s going!

Furthermore, my simple rule set isn’t curve fitted or just a fluke. Here are just the top ten performers of the same bot run against multiple currency pairs over the same time frame.

Would you believe that I went from seeing these numbers on like Tuesday to hemorrhaging commission fees on Wednesday. I’ll literally have positive profits because I’m definitely capturing points, but my broker apparently increased my commission rate from about $3 to over $5 per 1.0 lot completely killing my bot in backtest… This is the only thing keeping me from trading this bot live right now!