is it possible to use Take Profit = TP in to reverse position

 

On this example below


Line 1 receives a signal to sell and checks for any open short positions

Line 2 defines the Vol, Price, SL, TP 

if (signal =="sell" && PositionsTotal()<1)

trade.Sell(1.0,NULL,Bid,0,(Bid-200 * _Point),NULL);

My question is :

Can I pass as Argument here that TP is a condition not a value ?

 
AdnanSyed:

Can I pass as Argument here that TP is a condition not a value ?

yes, you can use OrderClose() to close the order, once TP condition is met.

 
AdnanSyed:

On this example below


Line 1 receives a signal to sell and checks for any open short positions

Line 2 defines the Vol, Price, SL, TP 

if (signal =="sell" && PositionsTotal()<1)

trade.Sell(1.0,NULL,Bid,0,(Bid-200 * _Point),NULL);

My question is :

Can I pass as Argument here that TP is a condition not a value ?

No. A TP is a price associated with an order sent to the broker. If you want a conditional TP it has to be managed by code as answered by Mohamad.
 
Alain Verleyen:
No. A TP is a price associated with an order sent to the broker. If you want a conditional TP it has to be managed by code as answered by Mohamad.

Perhaps he wants TP to be triggered after some value, like a buy stop-limit...

 
AdnanSyed:

On this example below


Line 1 receives a signal to sell and checks for any open short positions

Line 2 defines the Vol, Price, SL, TP 

if (signal =="sell" && PositionsTotal()<1)

trade.Sell(1.0,NULL,Bid,0,(Bid-200 * _Point),NULL);

My question is :

Can I pass as Argument here that TP is a condition not a value ?

If you get a BUY signal or at a given price level, you can send a CLOSE_BY request for closing a SELL with a BUY. If the BUY has larger volume it will result in a reverse trade.

 
Arthur Albano:

Perhaps he wants TP to be triggered after some value, like a buy stop-limit...

Yes but then it's not more a TP in the MT5 sense.