How do I get this very basic information from a strategy: how many contracts have been traded in total ?
The performance report does not provide this info, and I can't figure out how to accurately calculate it, specially when doing some scaling In/out. Why there is not a keyword such as "TotalContracts" available in PowerLanguage while we do have "MaxContracts" or "CurrentContracts" ?
I tried to dig into positions in order to count contracts from each entries, but it does not work as expected. See my code attempt below:
Code: Select all
Vars: TotalQty(0), MP(0), Trade(0) ;
MP= marketposition ;
If MP <> MP[1] and MP[1] <> 0 then // when position closed
begin
For Trade = 0 to PosTradeCount(1)
begin
TotalQty = TotalQty + PosTradeSize(1, Trade) ;
end;
end;
Many thanks for your help !