Open Position for Instrument Type

Moderator: admin

Open Position for Instrument Type

Postby pesh123 » Wed Mar 08, 2017 12:49 am

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.
Posts: 5
Joined: Mon Mar 06, 2017 6:08 am

Re: Open Position for Instrument Type

Postby Apprentice » Sun Mar 12, 2017 4:35 pm

Code: Select all
strategy.parameters:addString("Account", "Account to trade on", "", "");
strategy.parameters:setFlag("Account", core.FLAG_ACCOUNT);
Account = instance.parameters.Account;
Offer ="offers"):find("Instrument",;

function haveTrades()
    local enum, row;
    local found = false;
    enum ="trades"):enumerator();
    row = enum:next();
    while (row ~= nil) do
        if row.AccountID == Account
      and row.OfferID == Offer
            found = true;
        row = enum:next();

    return found;
User avatar
FXCodeBase: Confirmed User
Posts: 19800
Joined: Thu Dec 31, 2009 11:59 am
Location: Zagreb, Croatia

Return to Indicator Development

Who is online

Users browsing this forum: No registered users and 5 guests