BuyNetPL

If you need an Indicator or Signal developed or translated from other language, please post all Indicator development REQUESTS to this section here.

Moderator: admin

BuyNetPL

Postby conjure » Sun Feb 25, 2018 8:33 pm

Hi.I was wondering how can i get in my code the BuyNetPL of all opened trades of an instrument?
conjure
FXCodeBase: Initiate
 
Posts: 135
Joined: Sat Jul 22, 2017 7:27 am

Re: BuyNetPL

Postby 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")
User avatar
Apprentice
FXCodeBase: Confirmed User
 
Posts: 36435
Joined: Thu Dec 31, 2009 11:59 am
Location: Zagreb, Croatia


Return to Indicator and Signal Requests

Who is online

Users browsing this forum: No registered users and 14 guests