Cannot call OrderSend inside an indicator.

 

I've got an indicator that signals an action by sound and alert:

PlaySound("news.wav");
Alert(Symbol()," make an action"); 

I wanted to add there the OrderSend function to auto buy-sell and it looks this way:

int ticket;        
PlaySound("news.wav");
Alert(Symbol()," make an action"); 
ticket=OrderSend(Symbol(),OP_SELL,1.0,Bid,2,Bid+7*Point,Bid-7*Point,"Sell",0,0, Red); 

When the time comes, there is the signal, there is the alert but there are no orders.

Any ideas what is wrong?

 
Biertago:

I've got an indicator that signals an action by sound and alert:

I wanted to add there the OrderSend function to auto buy-sell and it looks this way:

When the time comes, there is the signal, there is the alert but there are no orders.

Any ideas what is wrong?

Trading functions don't work from Indicators . . . only from Scripts and EAs. Please read the documentation: Trading Functions "Trading functions can be used in experts and scripts."
 
Okay, I see, is there any way I can make it work? Can I call a script from the indicator?
 

No. Indicators do not call anything. They indicate.

Write a script or EA. Get the indicators values via iCustom and when the condition is correct open.

Reason: