How to write EA with hidden takeprofit and stoploss?

 

Hello all,

I have a problem with using hidden TP and SL in mql5. How to write it ?

Many thank for your help.

 

I'm fairly new to mt5,

But I calculate my TP levels based on the deals i made (Not on the open position), I don't send a TP or SL order, I just send a trade request to close the deal when the TP or SL is is reached.

Still new to the 1 position only for each instrument.
So what I do:

- calculate your profits and losses based on deals made.
- when TP or SL is reached send trade request to close the deal

I find that doing it this way it's still the same as having x amount of open positions for in mt4 an up position cancels out a down position, it's all about the net worth result now.
If your having trouble knowing which deal to compensate, use magic numbers for each session/deal/signal depending on your trading style/ code writing

Hope this helps. 

Documentation on MQL5: Trade Functions / OrderSend
Documentation on MQL5: Trade Functions / OrderSend
  • www.mql5.com
Trade Functions / OrderSend - Documentation on MQL5
 
I prefer using taking profit or stop loss base on Balance credit, which mean if your trade reach certain Profit or Loss according your setup than it's close the trade. It's more safer.
Reason: