{ User function: NConFF
Calculate the number of contracts for the current trade assuming a fixed percentage
of account is risked on each trade.
This function implements a fixed fractional approach to position sizing; see R. Vince, Portfolio
Management Formulas, 1990 for a complete discussion of fixed fractional trading. The function is
intended to be called by a trading system prior to each trade to determine the number of contracts
to trade based on the accumulated trading equity, the risk of the current trade, and the amount to
risk on each trade.
INPUTS:
StEqty: initial account size (starting equity) in dollars.
RiskPer: percentage risk per trade. This is the so-called "fixed fraction" of fixed
fractional trading.
TrRisk: risk for current trade in dollars; should be positive. This number can be different
for each trade if desired.
MinNEq1: Set MinNEq1 to either 1 or 0. If equal to 1, the number of contracts is always
at least equal to 1. In other words, if the number of contracts would otherwise be equal
to 0 because of a small account size or high trade risk, this sets the number of contracts
equal to 1.
OUTPUT:
The function returns the number of contracts for the current trade. If the account equity falls below
zero, the number zero ("0") will be returned. This is true even if MinNEq1=1.
You can use the "Expert Commentary" tool in charting to see the account equity, current profits,
trade risk, risk percentage, and number of contracts for the next trade on each bar.
NOTES:
1. This version writes error messasges to the TradeStation MessageLog, so it will only work in
TradeStation version 2000i. Use NConFF2 for TradeStation 4.0, which writes to Print log.
Michael R. Bryant
Breakout Futures
www.BreakoutFutures.com
mrb@BreakoutFutures.com
11/28/00
Copyright 2000 Breakout Futures
}
input: StEqty (NumericSimple), { starting account size, $ }
RiskPer (NumericSimple), { risk percentage }
TrRisk (NumericSeries), { risk for current trade }
MinNEq1 (NumericSimple); { =1 --> # contracts at least 1 }
Var: NCon (0), { number of contracts }
Equity (0); { account equity }
Equity = StEqty + NetProfit + OpenPositionProfit;
If ABSVALUE(TrRisk) > 0 then
NCon = IntPortion(RiskPer/100 * Equity/ABSVALUE(TrRisk))
else Begin
MessageLog("**Error: Trade risk <= 0. Assign positive value to TrRisk.");
NCon = 0;
end;
If MinNEq1 > 0 and NCon < 1 then
NCon = 1;
If Equity <= 0 then Begin
MessageLog("**Warning: Account equity <= 0.");
NCon = 0;
end;
#BeginCmtry
If CheckCommentary then Begin
Commentary("Starting Equity: $", StEqty:0:2, NewLine);
Commentary("Net Profit (closed + open): $", (NetProfit + OpenPositionProfit):0:2, NewLine);
Commentary("Current Equity: $", Equity:0:2, NewLine);
Commentary("Trade Risk: $", TrRisk:0:2, NewLine);
Commentary("Risk Percentage: ", RiskPer:0:2,"%", NewLine);
Commentary("Number of Contracts for Next Trade: ", NCon:0:0);
end;
#End;
NConFF = NCon;
{ User function: NConFF2
Calculate the number of contracts for the current trade assuming a fixed percentage
of account is risked on each trade.
This function implements a fixed fractional approach to position sizing; see R. Vince, Portfolio
Management Formulas, 1990 for a complete discussion of fixed fractional trading. The function is
intended to be called by a trading system prior to each trade to determine the number of contracts
to trade based on the accumulated trading equity, the risk of the current trade, and the amount to
risk on each trade.
INPUTS:
StEqty: initial account size (starting equity) in dollars.
RiskPer: percentage risk per trade. This is the so-called "fixed fraction" of fixed
fractional trading.
TrRisk: risk for current trade in dollars; should be positive. This number can be different
for each trade if desired.
MinNEq1: Set MinNEq1 to either 1 or 0. If equal to 1, the number of contracts is always
at least equal to 1. In other words, if the number of contracts would otherwise be equal
to 0 because of a small account size or high trade risk, this sets the number of contracts
equal to 1.
OUTPUT:
The function returns the number of contracts for the current trade. If the account equity falls below
zero, the number zero ("0") will be returned. This is true even if MinNEq1=1.
You can use the "Expert Commentary" tool in charting to see the account equity, current profits,
trade risk, risk percentage, and number of contracts for the next trade on each bar.
NOTES:
1. This version is intended for Tradestation version 4. It writes error messasges to the
print log, rather than the MessageLog. If used in 2000i, the error messages will appear in the
Debug window in the editor.
Michael R. Bryant
Breakout Futures
www.BreakoutFutures.com
mrb@BreakoutFutures.com
11/30/00
Copyright 2000 Breakout Futures
}
input: StEqty (NumericSimple), { starting account size, $ }
RiskPer (NumericSimple), { risk percentage }
TrRisk (NumericSeries), { risk for current trade }
MinNEq1 (NumericSimple); { =1 --> # contracts at least 1 }
Var: NCon (0), { number of contracts }
Equity (0); { account equity }
Equity = StEqty + NetProfit + OpenPositionProfit;
If ABSVALUE(TrRisk) > 0 then
NCon = IntPortion(RiskPer/100 * Equity/ABSVALUE(TrRisk))
else Begin
Print("**Error: Trade risk <= 0. Assign positive value to TrRisk.");
NCon = 0;
end;
If MinNEq1 > 0 and NCon < 1 then
NCon = 1;
If Equity <= 0 then Begin
Print("**Warning: Account equity <= 0.");
NCon = 0;
end;
#BeginCmtry
If CheckCommentary then Begin
Commentary("Starting Equity: $", StEqty:0:2, NewLine);
Commentary("Net Profit (closed + open): $", (NetProfit + OpenPositionProfit):0:2, NewLine);
Commentary("Current Equity: $", Equity:0:2, NewLine);
Commentary("Trade Risk: $", TrRisk:0:2, NewLine);
Commentary("Risk Percentage: ", RiskPer:0:2,"%", NewLine);
Commentary("Number of Contracts for Next Trade: ", NCon:0:0);
end;
#End;
NConFF2 = NCon;