HistoryDealsTotal() is returning only 1

 

Hi , I am writing a code in OnTradeTransaction() event handler ,that whenever order hit stoploss i am taking it's position id of deal type DEAL_ENTRY_OUT  and iterating HistoryDealTotal() to find DEAL_ENTRY_In for that position_id but problem is  HistoryDealTotal() is holding only latest deal for given position_id , and margin_mode of my account type is Hedging . 


int total_deals = HistoryDealsTotal();

Print("55  Inside OnTradeTransaction  total deals ",total_deals);

for (int i = total_deals - 1; i >= 0; i--)

}

output : 

55  Inside OnTradeTransaction  total deals 1


expected result: when order closed by hitting stoploss then HistoryDealsTotal() should return 2 but i am getting 1.


 
Arun s:


Unless you post your coding attempt then your only responses will be "we can not see your screen", or "we can not read your mind", or our fav "our crystal balls are cracked and broken".

the 5 line code you added is not the full code, therefore, how do you expect to get any help with that?