Running a script using the selected order

 

Hi,

I am trying to write a verys simple script that carries out an action on the order that you have selected. And by selected I mean the order that you have selected with the mouse and cursor. At the moment the only way i know how to do this is manually type in teh ticket number into my code and the recompilethe code then run it. Ideally i want the script to identify which order has been selected (as is indicated as it is highlighted in blue) and then carry out the operation on that order (in this case its an ordermodify function).

 
epictrader:

Hi,

I am trying to write a verys simple script that carries out an action on the order that you have selected. And by selected I mean the order that you have selected with the mouse and cursor. At the moment the only way i know how to do this is manually type in teh ticket number into my code and the recompilethe code then run it. Ideally i want the script to identify which order has been selected (as is indicated as it is highlighted in blue) and then carry out the operation on that order (in this case its an ordermodify function).

Hi epictrader

I don't know how to apply a script to an order selected in the terminal window, but there is an easier way to enter the ticket number. You can use the "#property show_inputs" to get the script to open the input window before it runs. For example:

//--------------------------------------------------------------------
// GetOrderInfo.mq4
//--------------------------------------------------------------------
#property show_inputs

extern int Ticket = 0;

//--------------------------------------------------------------------
// start()
//--------------------------------------------------------------------

int start()
{

   OrderSelect( Ticket, SELECT_BY_TICKET );
   Alert( "Ticket #: ", Ticket,
          "\nOpen: ", DoubleToStr( OrderOpenPrice(), Digits ),
          ", SL: ", DoubleToStr( OrderStopLoss(), Digits ),
          ", TP: ", DoubleToStr( OrderTakeProfit(), Digits ),
          "\nMagic #: ", OrderMagicNumber(), ", Comment: ", OrderComment() );

}
//====================================================================

Cheers

Jellybean