CloseAllBuyMarketOrders method

Created at 28 Oct 2013, 22:43
How’s your experience with the cTrader Platform?
Your feedback is crucial to cTrader's development. Please take a few seconds to share your opinion and help us improve your trading experience. Thanks!
Hyperloop's avatar

Hyperloop

Joined 23.10.2013

CloseAllBuyMarketOrders method
28 Oct 2013, 22:43


public void CloseBuyOrders(string argSymbolCode, string argLabel)
        {
            foreach (var position in Account.Positions)
            {
                if (position.Label == argLabel && position.TradeType == TradeType.Buy && position.SymbolCode == argSymbolCode)
                {
                    Close(position);
                }
            }
        }

When I try to compile this, I get the error "The name 'Close' does not exist in the current context".

I'm trying to create a library of common functions that I will use in future cBots.

Some help would be great! Thanks

 


@Hyperloop
Replies

Hyperloop
28 Oct 2013, 22:58

RE:

Hyperloop said:

public void CloseBuyOrders(string argSymbolCode, string argLabel)
        {
            foreach (var position in Account.Positions)
            {
                if (position.Label == argLabel && position.TradeType == TradeType.Buy && position.SymbolCode == argSymbolCode)
                {
                    Close(position);
                }
            }
        }

When I try to compile this, I get the error "The name 'Close' does not exist in the current context".

I'm trying to create a library of common functions that I will use in future cBots.

Some help would be great! Thanks

 

Fixed it, was just a silly mistake. 

Correction:

Trade.Close(position);


@Hyperloop