# Option Combos

The following functions can be used for handling combinations of options, such as Straddles, Strangles, Condors, Butterflies, etc. Option combos are mainly used for limiting risk. For an introduction to options trading, see Financial Hacker. The image below shows the profit or loss of an Iron Condor combo dependent of the underlying price, at expiration (blue) and halfway to expiration (red).

Iron Condor payoff diagram (Payoff.c)

## combo (CONTRACT* C1, int N1, CONTRACT* C2, int N2, CONTRACT* C3, int N3, CONTRACT* C4, int N4): int

Combines up to 4 option contracts C1..C4 to a combo. The number and trade direction of contracts are given by N1..N4; use negative numbers for selling and positive numbers for buying that contract, f.i. -2 for short selling two contracts. Use 0 for not used contracts. Returns the number of combo legs, i.e. the number of different contracts of the combo. If any CONTRACT* pointer is zero, but the associated number N is nonzero, it deletes the combo and returns 0. Source code in contract.c.

## comboAdd (CONTRACT* C, int N): int

Adds a copy of the option contract C to the current combo. Amount and trade direction of the contract is given by N; use a negative number for selling and a positive number for buying. Returns the number of the current combo leg. If C is 0, the function deletes all contracts from the combo and returns 0.

## comboLegs (): int

Returns the number of legs of the current combo that was defined before with combo() or comboAdd() calls.

## comboContract (int Leg): CONTRACT*

Pointer to the CONTRACT struct of the combo leg with the given number (1..4). Macro defined in contract.c.

## comboLeg (int Leg): int

Selects the contract of the combo leg with the given number (1..4), and returns the number assigned to that contract as defined in the combo() function. The number is negative for selling and positive for buying, so it can be directly used for the Lots parameter passed to enterLong

## comboStrike (int Leg): var

Returns the strike value of the given combo Leg (1..4). Source code in contract.c.

## comboRisk (int Type): var

Returns the maximum loss of the current short (Type == -1) or long (Type == 1) combo. For combos with unlimited loss, returns the loss when the price drops to zero or ends up at twice the strike, whichever is worse. Type, fAsk, fBid, and fStrike of all contracts must be set, so contractPrice must have been called before; the other contract parameters don't matter. Multiplier and transaction costs are not included. Source code in contract.c.

Returns the total premium of the current short (Type == -1) or long (Type == 1) combo. Positive premium is earned, negative premium is paid. fAsk and fBid of all contracts must be set, so contractPrice must have been called before; the other contract parameters don't matter. Multiplier and Transaction costs are not included. Source code in contract.c.

### Parameters:

 C1..C4 CONTRACT* pointer for leg 1..4, or 0 when the leg is not used in the combo. N1..N4 Number of contracts for leg 1..4, negative for selling and positive for buying contracts. 0 when the leg is not used in the combo. Leg Number of the combo leg, 1..4, starting with 1 for the first contract.

### Remarks:

• contract.c must be included for all above functions.
• Combo trades should be opened or closed in the order of legs, starting with leg 1. They are then automatically combined to a combo order which is sent to the broker. Many brokers offer reduced margin and commission on combos. The combo order internally uses the SET_COMBO_LEG command, which must be supported by the broker plugin. Otherwise the combo is split in separate contract orders.
• Combos orders can take several minutes for being executed, even at market. For this reason it is recommended to use GTC orders and/or to increase the wait time with the SET_WAIT command.
• The elements of the current combo can be accessed through the ThisCombo pointer, defined in trading.h.
• Use the algo function for getting separate combo-specific statistics.
• The script Payoff.c contains some definitions of often used combos, such as spread, strangle, butterfly, condor. Call the combo from the main function for plotting its profit/loss curve.

```if(combo(
contract(CALL,Days,Strike),1,
contract(PUT,Days,Strike),1,
0,0,0,0)) // Strangle combo
{
enterLong(comboLeg(1));
enterLong(comboLeg(2));
}```