NeedForTrade Documentation

Buy To Cover Methods

Buy To Cover method names are constructed as follows:

BuyToCover<When><Price>[<ExitOptions>]([<Parameters>])

 

<ExitOptions> and <Parameters> are optional and may vary depending on your needs.

 

For example:

BuyToCoverNextBarAtMarket();

 

Available When variants:

 

Available Price variants:

 

Tip: relativePrice can be negative to specify price less then Open price of the next bar.

 

Available ExitOptions variants:

 

Tip: use FromEntry exit option to to close specific entries named with tradeName parameter.

 

Backtesting Real Time Strategies on historical data:

 

List of available BuyToCover methods with possible parameters:

// BackTestBuyToCover
    void BackTestBuyToCover(double price);
    void BackTestBuyToCover(double price, int tradeSize);
    void BackTestBuyToCover(string tradeName, double price);
    void BackTestBuyToCover(string tradeName, double price, int tradeSize);
    void BackTestBuyToCoverFromEntry(string tradeName, double price, int tradeSize);
    void BackTestBuyToCoverFromEntryTotal(string tradeName, double price, int tradeSize);
    void BackTestBuyToCoverTotal(double price, int tradeSize);
    void BackTestBuyToCoverTotal(string tradeName, double price, int tradeSize);
    
// BuyToCoverAtLimit     
    void BuyToCoverAtLimit(double limitPrice);
    void BuyToCoverAtLimit(double limitPrice, int tradeSize);
    void BuyToCoverAtLimit(string tradeName, double limitPrice);
    void BuyToCoverAtLimit(string tradeName, double limitPrice, int tradeSize);
    void BuyToCoverAtLimitFromEntry(string tradeName, double limitPrice, int tradeSize);
    void BuyToCoverAtLimitFromEntryTotal(string tradeName, double limitPrice, int tradeSize);
    void BuyToCoverAtLimitTotal(double limitPrice, int tradeSize);
    void BuyToCoverAtLimitTotal(string tradeName, double limitPrice, int tradeSize);

// BuyToCoverAtMarket     
    void BuyToCoverAtMarket();
    void BuyToCoverAtMarket(int tradeSize);
    void BuyToCoverAtMarket(string tradeName);
    void BuyToCoverAtMarket(string tradeName, int tradeSize);
    void BuyToCoverAtMarketFromEntry(string tradeName, int tradeSize);
    void BuyToCoverAtMarketFromEntryTotal(string tradeName, int tradeSize);
    void BuyToCoverAtMarketTotal(int tradeSize);
    void BuyToCoverAtMarketTotal(string tradeName, int tradeSize);

// BuyToCoverAtStop     
    void BuyToCoverAtStop(double stopPrice);
    void BuyToCoverAtStop(double stopPrice, int tradeSize);
    void BuyToCoverAtStop(string tradeName, double stopPrice);
    void BuyToCoverAtStop(string tradeName, double stopPrice, int tradeSize);
    void BuyToCoverAtStopFromEntry(string tradeName, double stopPrice, int tradeSize);
    void BuyToCoverAtStopFromEntryTotal(string tradeName, double stopPrice, int tradeSize);
    void BuyToCoverAtStopTotal(double stopPrice, int tradeSize);
    void BuyToCoverAtStopTotal(string tradeName, double stopPrice, int tradeSize);