why it run many times

 
int start()
{
int LARGENUMBER = 100000;
int _orderIdBuy = -1;
int _orderIdSell = -1;

//step1
OrderSend(Symbol(), OP_BUYSTOP, _number, Bid + _pendingPoint * Point, 0, Bid + _pendingPoint * Point - _lossPoint * Point, Bid + _pendingPoint * Point + _getPoint * Point, "some comment", 16384, 0, Green);
OrderSend(Symbol(), OP_SELLSTOP, _number, Ask - _pendingPoint * Point, 0, Ask - _pendingPoint * Point + _lossPoint * Point, Ask + _pendingPoint * Point - _getPoint * Point, "some comment", 16384, 0, Green);
//step2


}
 

Since start() Run once per tick, many ticks own same openorder conditions.

 
how to avoid it?
 

Hi,

I'm not a programer but I think you should try this: Count the bars and only if your bar counter is bigger then the value of the Bars when your condition is matched

---------------------------------------------------------------------------------------------------------------

int cBars;

int start()
{

cBars=Bars;

int LARGENUMBER = 100000;
int _orderIdBuy = -1;
int _orderIdSell = -1;

if (cBars>Bars && .....your conditions...) // i.e .: only if the Bar counter is bigger then the Bars value;
//step1
OrderSend(Symbol(), OP_BUYSTOP, _number, Bid + _pendingPoint * Point, 0, Bid + _pendingPoint * Point - _lossPoint * Point, Bid + _pendingPoint * Point + _getPoint * Point, "some comment", 16384, 0, Green);
OrderSend(Symbol(), OP_SELLSTOP, _number, Ask - _pendingPoint * Point, 0, Ask - _pendingPoint * Point + _lossPoint * Point, Ask + _pendingPoint * Point - _getPoint * Point, "some comment", 16384, 0, Green);
//step2


}

 

PLG

See this thread 'bool variable for new bar'

for an example of how to prevent multiple orders per bar

Good Luck

-BB-

Reason: