close opened order from inside indicator

 

Hi

i have an indicator that shows entry and exit points ( not accurate, but not bad), i want to open order manually, and let the indicator close the position.

if (madiff > 0.0 && rsi0>50 ) UP = 1;
else
if (madiff < 0.0 && rsi0<50 ) UP = 2;

Because after the signal can send email

i thought why not send order to close position??

i tried to enter after the signal ( if OrderType()==OP_SELL) OrderClose(OrderTicket(),0,Ask,3); OR if(OrderType()==OP_SELL) OrderClose(0,0,Ask,3); OR.....

they didn't work.

how can do that ?!!

Regards,

SG

 
samirgham:

i have an indicator [...]

i thought why not send order to close position??

Trading functions of OrderSend(), OrderClose, OrderCloseBy, OrderDelete, and OrderModify cannot be called from custom indicators.

See here -> https://docs.mql4.com/trading.