Hello to everybody. Please, can someone help me in finding a post in the Forum? I am sure that something exists but i am not able to find what i need.
Well, i am searching for an EA, a simple trailing stop that give me the possibility to add the commission paid for the trade. I mean, for example:
Buy order GBP USD 1.21019, trailing stop to breakeven as soon as the trade is xpips in gain but with the possibility to add the pips paid as
Thank you for your help.
Have a nice evening
Buy order GBP USD 1.21019, trailing stop to breakeven as soon as the trade is xpips in gain but with the possibility to add the pips paid as commission.
Hey Fabio, stumbled across your post looking for answers myself and I recently came up against the very issue you're up against. Shame nobody has hit you back in all this time. Hope this reply finds you well bro, and that you're over this hump already and don't even need me lol.
Basically, I use the OnTrade() event method to catch and respond to all orders relayed between my bot and the brokerage server. I collect all relevant information about the order (ticket#, price, time, symbol, comment, deal type, deal entry, profit, and... Commission(C) and Volume(V). I calculate the Commission Rate per Volume (CRV = -C/V). This is your Dollar per 1.0 lot commission rate. I use the CRV value in my position management to calculate the additional points of profit necessary to cover the commissions of the round trip, since commissions are charged on the front and back end. I currently use 4x the feePoint value as a goal to set my trailing stop. I'll give an example for full clarity.
So, imagine taking a 1.0 lot trade on EURUSD and paying a commission of $3.00. In the OnTrade() method, collect all information about the order when it clears.
Calculate the CRV by dividing what ever commission you just paid by the volume of the position, in our case $3.00 for our 1.0 lot.
Commission is reported as a negative double and should be negated to make your CRV positive. So, CRV = (-C/V) = ($3.0 / 1.0 lot) = $3.00 / lot.
With this, you calculate positionFees = positionVolume * CRV = $3.00 and feePoints = pFees/(tickValue * pVolume).
My broker recently screwed one of my live bots by suddenly increasing commissions from $3 / 1.0 lot to $7!!! I was pre-calculating fees per lot size to be about $3 per lot, and this was hard coded into my bot. This opened my eyes to redesign that part of my code, which lead me to this. If I'd had my CRV blasted to my mobile notification when the trade was opened (the importance of the order response system there), I would have seen the change immediately. Luckily, I was awake and actively working on my bot like a mad scientist in my time zone and caught it through seeing completely screwy backtests. Literally, crashing out on re-run sims that were doing great! It took me a day or so to root out the commission increase. Jeez... from $3 to $7?! Now it's testing at $5. It almost feels like sabotage... I might be looking for a new broker soon.
Moral of the story, avoid commissions at all cost! Spreads are already and always a thing, but they're also only paid once over the course of the trade. Commissions hit you on the front and back, plus the spread, however small they claim it to be. I'm literally just trying to get a couple live boats in the water and these are already the lessons I'm learning. Hopefully this will bring some value to you or another passerby.
Peace and Blessings, fam.
You don't have to avoid them.
Just don't hardcode them into your EA so you can code a dynamic function that changes when commission changes.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.