OrderSend() and ticket# in backtests

 

Hello,

int ticketId = OrderSend(...) always returns 1 for me inseatd of a (fake) ticket number. Is the the correct behaviour for backtests? I want to select the (just) opened order to read some information from it.

 
That's odd.
 
Marco vd Heijden:
That's odd.
I tested it with the MA / MACD samples and it works fine. Must be a problem in front of the computer.
 
agreed, that is odd... but if you're using the Strategy Tester and running OrderSend() only once, then I think you will always get a ticket ID# of 1... if you alter that line of code to add another order and label your variables like "ticketId1 = OrderSend(...);" and "ticketId2 = OrderSend(...)" - do you get "1" and "2"? If so, then I suspect this might be culprit and if/when you run it through OnTick(), you should get a proper ID#.
 

hello

I had the same problem on MT4,this because you use rong tpye

int temp_tick_id=0;//befor  i define this  variate as bool,so i always get 1,just change it to int

temp_tick_id = OrderSend(aTrend_3k.symbol_now, OP_BUY, order_lots, Ask, 0, frist_sl[0], 0, "trend_3k_0p1_buy"+uuid, 0, clrGreen);

printf("buy oreder_id=%d  at %s,price=%6.5f,sl=%6.5f",temp_tick_id,TimeToStr(TimeCurrent(),TIME_DATE|TIME_SECONDS),Ask,frist_sl[0]);


==>why temp_tick_id always get 1

Reason: