Stop & Reverse

 

If I open a Buy signal with the code OrderSend(....), how can I launch a Sell order if (only if) the first order go in Stop Loss?

Example: 1° Order Long --> 1.0100; TP 1.0150; SL 1.0080;

if TP in taken --> end the EA,

if SL is taken go Short with the 2° order at the close price of the 1° order (= SL price).

 
Paolo Castelli :

If I open a Buy signal with the code OrderSend(....), how can I launch a Sell order if (only if) the first order go in Stop Loss?

Example: 1° Order Long --> 1.0100; TP 1.0150; SL 1.0080;

if TP in taken --> end the EA,

if SL is taken go Short with the 2° order at the close price of the 1° order (= SL price).


Look at the examples: Opposite tradeStop Loss Take Profit.

 
Vladimir Karputov:

Look at the examples: Opposite tradeStop Loss Take Profit.

Thankyou Vladimir, but these codes are also for mt4?
 
Paolo Castelli :
Thankyou Vladimir, but these codes are also for mt4?

No. Only for MetaTrader 5. You asked a question on the MQL5 forum. For the old terminal there is a special branch: MQL4 and MetaTrader 4

 

In MQL5 now there are wonderful reasons for the execution of deals ENUM_DEAL_REASON:

Identifier

Description

DEAL_REASON_CLIENT

The deal was executed as a result of activation of an order placed from a desktop terminal

DEAL_REASON_MOBILE

The deal was executed as a result of activation of an order placed from a mobile application

DEAL_REASON_WEB

The deal was executed as a result of activation of an order placed from the web platform

DEAL_REASON_EXPERT

The deal was executed as a result of activation of an order placed from an MQL5 program, i.e. an Expert Advisor or a script

DEAL_REASON_SL

The deal was executed as a result of Stop Loss activation

DEAL_REASON_TP

The deal was executed as a result of Take Profit activation

DEAL_REASON_SO

The deal was executed as a result of the Stop Out event

DEAL_REASON_ROLLOVER

The deal was executed due to a rollover

DEAL_REASON_VMARGIN

The deal was executed after charging the variation margin

DEAL_REASON_SPLIT

The deal was executed after the split (price reduction) of an instrument, which had an open position during split announcement

 

Please do not double post.

I have deleted your duplicate topic and moved this to the MQL4 section (some of the above answers relate to MQL5 as was posted in the wrong section)