Hi,
I need to store the ticket from a short order while it's running... but my variable
doesn't work?
Yes I'm sure I do... this is the first trade I have when I start backtest.
Also I have tried to call only with
But still not working better.
Please help.
Ok I can store the current short trade ticket.
So I can match when it's closed when I look into Historical data:
for(int ia=OrdersHistoryTotal()-1;ia>=0;ia--) { OrderSelect(ia, SELECT_BY_POS,MODE_HISTORY); // int LastClosedTicket_Scalp = 0; if(OrderSymbol()==Symbol() && OrderMagicNumber()==140 ){ int LastClosedTicket_Scalp = OrderTicket(); int LastClosedType = OrderType(); double LastProfit = OrderProfit(); Print(" Curent Sell Order ticket : ",LastTicketShort_Scalp, " LastClosedTicket_Scalp : ", OrderTicket() ); } if(Strategy_2 == true && Trend_Bullish == true ){ if ( Bid < lowValue && countLongTrades_Scalping() == 0 && LastClosedType == OP_SELL && LastProfit > 0 && LastClosedTicket_Scalp == LastTicketShort_Scalp ) // = > Ticket 1 == Ticket 1 {openLongTrade_Scalping();} } }
So After a wining Short trade Magic 140... I Open a Long trade Magic 140. => That's fine.
Prolem:
When this one is closed... the last closed order from historical data should be OP_BUY and ticket 1+1 So EA shouldn't open long trade anymore.
But it does because the print gives me this:
2013.09.16 16:18:06 2013.09.16 18:18 Heartbeat_Grid_FX EURUSD,M1: Curent Sell Order ticket : 1 LastClosedTicket_Scalp : 1
2013.09.16 16:18:06 2013.09.16 18:18 Heartbeat_Grid_FX EURUSD,M1: Curent Sell Order ticket : 1 LastClosedTicket_Scalp : 2
2013.09.16 16:18:06 2013.09.16 18:18 Heartbeat_Grid_FX EURUSD,M1: Curent Sell Order ticket : 1 LastClosedTicket_Scalp : 3
2013.09.16 16:18:06 2013.09.16 18:18 Heartbeat_Grid_FX EURUSD,M1: Curent Sell Order ticket : 1 LastClosedTicket_Scalp : 4
2013.09.16 16:18:06 2013.09.16 18:18 Heartbeat_Grid_FX EURUSD,M1: Curent Sell Order ticket : 1 LastClosedTicket_Scalp : 6
It prints for all the orders he founds into historical data... that macthes
if(OrderSymbol()==Symbol() && OrderMagicNumber()==140 )
So he found the ticket 1 and then open a new long position... but he shouldn't because it should bring me ONLY the last order closed.
Please help me to select only the last order that match the condition.
Cheers

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi,
I need to store the ticket from a short order while it's running... but my variable
doesn't work?
Please Help