by Apprentice » Tue Feb 27, 2018 2:30 pm
function Prepare( nameOnly)
Instrument = core.host:findTable("offers"):find("Instrument", source:instrument()).Instrument;
Offer = core.host:findTable("offers"):find("Instrument", instance.bid:instrument()).OfferID;
end
function tradesCount(BuySell)
local enum, row;
local profit = 0;
enum = core.host:findTable("trades"):enumerator();
row = enum:next();
while row ~= nil do
if row.AccountID == Account and
row.OfferID == Offer and
(row.BS == BuySell ) then
profit = profit + row.GrossPL;
end
row = enum:next();
end
return profit;
end
--Use
--local NetProfitLong= tradesCount("B")
--local NetProfitShort=tradesCount("S")