Hedging Feature in MT5 and changing of SL

 

I am running identical code on 2 MT5 accounts on FXChoice.  One with Hedging and one normal using the same code. I also test on Metaquotes with hedging

I have an EA that just does trailing stops. The code works fine on the non hedging account.  On the hedging account I get Error  10036  Invalid Request

on both FXChoice and on Metaquotes. Doing it manually on screen works fine, nothing wrong with the values and the code works fine on a non hedging account on FXChoice

It seems like I will spend the weekend rewriting the EA in MQL4. Spent to much time on this already.

If someone else has experienced the same type of problem maybe an error report would be the right way to go.

 
Fix your code.
 
Alain Verleyen:
Fix your code.
And a Happy New Year for you too!!
 
Alain Verleyen:
Fix your code.

Are you implying that the code should be different for hedging and non hedging accounts?

If so, please tell me where I can find documentation on that. The code works fine on the non hedging account and iot is quite atraigth forward

 
Ingvar Engelbrecht:

Are you implying that the code should be different for hedging and non hedging accounts?

If so, please tell me where I can find documentation on that. The code works fine on the non hedging account and iot is quite atraigth forward

If you get an error 10036 that means something need to be fixed. I can't say more with all the code you provided.
 
Alain Verleyen:
If you get an error 10036 that means something need to be fixed. I can't say more with all the code you provided.
 
Ingvar Engelbrecht:
Great now we will be able to help :D
 

Got things sorted out.

The real problem was a coy that I made in error. Copying a library from one instance of MT to another. I copied it to the expert folder. And thats what MT used instead of the one I had in the library folder.

Shoot in foot Ingvar!

Anyway. The hedging feature works fine. I am not using it for hedging. My EA uses a trailing stop and checks when a position has reached SL. That means I can place a new trade on this pair if the conditions are right without increasing my risk.

This works fine in MT4. In MT5 with a consolidated position it works fine as long as the trades goes in the profit direction. The profit can be considerable when you have added 10 trades. The problem is if it goes against you you might lose it all. It is possible to use pending orders for closing and take profit in parts of the position. I tried that a couple of years ago but gave up. If the position get closed out completely you might end up wit a number of "loose cannons" in the form of pending orders that has to be cleaned out. I gave up the idea.

With the new hedging feature in MT5 it works like MT4. You can have several positions on a pair in the same direction. Great!

 
Ingvar Engelbrecht:

Got things sorted out.

The real problem was a coy that I made in error. Copying a library from one instance of MT to another. I copied it to the expert folder. And thats what MT used instead of the one I had in the library folder.

Shoot in foot Ingvar!

Anyway. The hedging feature works fine. I am not using it for hedging. My EA uses a trailing stop and checks when a position has reached SL. That means I can place a new trade on this pair if the conditions are right without increasing my risk.

This works fine in MT4. In MT5 with a consolidated position it works fine as long as the trades goes in the profit direction. The profit can be considerable when you have added 10 trades. The problem is if it goes against you you might lose it all. It is possible to use pending orders for closing and take profit in parts of the position. I tried that a couple of years ago but gave up. If the position get closed out completely you might end up wit a number of "loose cannons" in the form of pending orders that has to be cleaned out. I gave up the idea.

With the new hedging feature in MT5 it works like MT4. You can have several positions on a pair in the same direction. Great!

Really happy I was able to help you 
Reason: