simple question...

 

how do i add a trailing stop to the following order placement script?


int start()
{
OrderSend(Symbol(),OP_BUY,Lots,Ask,3,Ask-15*Point,0,"JMBUYER",0,0,CLR_NONE);
}

 

you cannot 'add' a trailing stop within your program at OrderSend() time.

.

ie, you say script and they generally speaking are of a one shot type - no recall by terminal so cannot have ongoing order management [generally speaking ;].

An EA gets called whenever a new data tick received from server and is related chart EA runs on. This data tick contains all data needed to make decisions as to making/or not, an OrderModify(..,..,NewStopLossValue,..) call.

you can, set up a trailing stop loss at time of manual order placement via terminal... read terminal docs for that.

or you use script > watch price > manually modify order via terminal.

some use script to 'pull the trigger' because can be onerous task getting all the order form fields set up FAST, and mistakes often arise do to funny fingers :o)

if want program code ideas etc, because you would like to order send + order modify in an Expert, use top right search box. you will find many examples.

hth

 
deymer:

how do i add a trailing stop to the following order placement script?


int start()
{
OrderSend(Symbol(),OP_BUY,Lots,Ask,3,Ask-15*Point,0,"JMBUYER",0,0,CLR_NONE);
}

The short version: Trailing Stop is not a function or parameter... It has to be "synthesized" by modifying the order with a new SL... multiple times as the price moves.