Hi,
I'm building a strategy and I need to check if the are any open positions for the particular instrument type on which the strategy is being run.
Could someone kindly provide some sample linkson how to do that.
Thanks
Moderator: admin
strategy.parameters:addString("Account", "Account to trade on", "", "");
strategy.parameters:setFlag("Account", core.FLAG_ACCOUNT);
Account = instance.parameters.Account;
Offer = core.host:findTable("offers"):find("Instrument", instance.bid:instrument()).OfferID;
function haveTrades()
local enum, row;
local found = false;
enum = core.host:findTable("trades"):enumerator();
row = enum:next();
while (row ~= nil) do
if row.AccountID == Account
and row.OfferID == Offer
then
found = true;
break;
end
row = enum:next();
end
return found;
end
Return to Indicator Development
Users browsing this forum: No registered users and 76 guests