Profit = gross win - gross loss
Profit factor = gross win / gross loss
Annual return = annual profit / capital
Capital = normalized max drawdown + max margin
Sharpe ratio = profit% per bar mean / stddev, annualized
That are the basic performance parameters.
Zorro
-
garyfritz
Re: Zorro
gross win & gross loss for what? 0.1 lot? Though since everything else is scaled by gross win / gross loss, I guess it may not be an issue.
So you define "capital" to be the minimum amount it would take to trade the account. Reasonable, if a bit optimistic. (Nobody knows ahead of time how much they'll need because they don't know what the drawdown will be.)
The biggest problem I have with this approach is that it totally ignores position sizing -- which can have a huge impact on real results, and on system design. Assuming you use sensible risk-based position sizing, an approach that makes 10,000 pips per year but risks 500 pips per trade will have entirely different different results than an approach that makes 10,000 pips but risks 50 per trade. You wouldn't see that difference if you only look at gross win and gross loss. (Though in this example it would probably show up in max drawdown.) You might want to consider that in your system design, trying to find a better entry for the first system so you don't need to run with such a huge stop.
So you define "capital" to be the minimum amount it would take to trade the account. Reasonable, if a bit optimistic. (Nobody knows ahead of time how much they'll need because they don't know what the drawdown will be.)
The biggest problem I have with this approach is that it totally ignores position sizing -- which can have a huge impact on real results, and on system design. Assuming you use sensible risk-based position sizing, an approach that makes 10,000 pips per year but risks 500 pips per trade will have entirely different different results than an approach that makes 10,000 pips but risks 50 per trade. You wouldn't see that difference if you only look at gross win and gross loss. (Though in this example it would probably show up in max drawdown.) You might want to consider that in your system design, trying to find a better entry for the first system so you don't need to run with such a huge stop.
-
jcl
- Trader
- Posts: 82
- Joined: Wed Oct 31, 2012 8:04 am
- Location: Frankfurt / Germany
Re: Zorro
Yes, the lot size is not an issue as it affects profit and drawdown likewise and thus does not appear in the final performance parameters. Measuring the quality of a strategy can obviously not be dependent on a lot size.
Capital is defined as the minimum amount to trade the strategy. You're right that nobody can predict future drawdown; but you nevertheless need quantitative parameters when you develop a trade algorithm.
The problem that you have seems to arise from confusing two different concepts. When you create a trade system, you first develop the strategy algorithm. Position sizing is not only irrelevant here - it would in fact lead to wrong results. The goal is not to optimize your position sizing. It is optimizing the algorithm performance and robustness. Normally the lot size plays no role here, unless your strategy is a martingale system or something like that.
If the strategy is ready, then you add money management. Then you use Kelly factors or - in the case of Zorro - Optimal-F for position sizing. Optimal-F is not calculated from drawdown alone, but from the whole equity curve. This is however an entirely different process. It is not really a part of strategy development, because once you have a money management concept, it's normally the same for all your strategies.
I hope this illustrates more clearly how we understand strategy development and performance parameters.
Capital is defined as the minimum amount to trade the strategy. You're right that nobody can predict future drawdown; but you nevertheless need quantitative parameters when you develop a trade algorithm.
The problem that you have seems to arise from confusing two different concepts. When you create a trade system, you first develop the strategy algorithm. Position sizing is not only irrelevant here - it would in fact lead to wrong results. The goal is not to optimize your position sizing. It is optimizing the algorithm performance and robustness. Normally the lot size plays no role here, unless your strategy is a martingale system or something like that.
If the strategy is ready, then you add money management. Then you use Kelly factors or - in the case of Zorro - Optimal-F for position sizing. Optimal-F is not calculated from drawdown alone, but from the whole equity curve. This is however an entirely different process. It is not really a part of strategy development, because once you have a money management concept, it's normally the same for all your strategies.
I hope this illustrates more clearly how we understand strategy development and performance parameters.
-
garyfritz
Re: Zorro
I understand very well the distinction between system design vs. position sizing. I'm just saying that you ignore an important aspect if you don't consider position sizing at all. Going back to my example -- same profit, vastly different risk.
I guess you're saying that if the two systems have same profit and same drawdowns, then you don't care about the sizing. The second system could take much bigger positions based on its smaller risk size, but then that increases your drawdown too.
I guess you're saying that if the two systems have same profit and same drawdowns, then you don't care about the sizing. The second system could take much bigger positions based on its smaller risk size, but then that increases your drawdown too.
-
jcl
- Trader
- Posts: 82
- Joined: Wed Oct 31, 2012 8:04 am
- Location: Frankfurt / Germany
Re: Zorro
When the drawdown of the second system is 10 times smaller than the drawdown of the first system, but the profit is the same, then the second system has obviously a ten times higher annual return - no matter if you invest 50 pips or 500 pips per trade.
If both drawdowns however are the same, then both systems have the same performance - again no matter how much you invest. You achieve the second system performance with 1/10 the margin, but must provide accordingly more capital for covering the drawdown. The return on capital is the same for both systems.
If both drawdowns however are the same, then both systems have the same performance - again no matter how much you invest. You achieve the second system performance with 1/10 the margin, but must provide accordingly more capital for covering the drawdown. The return on capital is the same for both systems.
- parrondo
- Posts: 3
- Joined: Thu Nov 17, 2011 6:10 am
Re: Zorro
jcl,jcl wrote:When the drawdown of the second system is 10 times smaller than the drawdown of the first system, but the profit is the same, then the second system has obviously a ten times higher annual return - no matter if you invest 50 pips or 500 pips per trade.
If both drawdowns however are the same, then both systems have the same performance - again no matter how much you invest. You achieve the second system performance with 1/10 the margin, but must provide accordingly more capital for covering the drawdown. The return on capital is the same for both systems.
Congratulation for your excelent platform.
About minimum capital to trade one strategy, if we consider only past performance and included walk forward optimization then it is necessary to take into account not max. drawdown (defined as consolidated or closed) but Maximum Adverse Excursion (MAE, also provided by Zorro). That is,
minimum required capital = MAE + Margin
As theoretical concept for strategy performance, this minimum required capital is a right concept and good data. Obviously all of us know we should add a safe factor to the left side of this equality (that is, an aditional amount of capital) to be tradeable in real accounts.
Again, congratulation to you and zorro team for this altruistic initiative and very comprehensive theory and tools for strategy development and trading.
Edit: OK forget this post. Capital is perfectly coherent with your max. DD definition (well, do not forget my congratulations!
http://manual.zorro-trader.com/performance.htm
-
falsedave
- Trader
- Posts: 53
- Joined: Sun Aug 26, 2012 5:00 pm
Re: Zorro
Been looking into Zorro for a while now. Although I have to say without much success.
I thought this would be a great tool for testing out ideas for entry's and exits, but i'm having a great deal of trouble learning the language. I've learnt to code in MQL and found that i could use Print() and Alert() statements to debug my code give me feedback and find out what value a variable is at a certain point in time. With Zorro I dont seem to be able to do this. Its probably something I'm doing wrong somewhere. How does everyone else do it ?
Below is a script I have been trying to write to trade TMAslope > 0.4 and TMASlope < -0.4.
I think CalculateSlope is always returning 0.0 but I cant test to be sure.
Anyhelp would be great.
Dave
I thought this would be a great tool for testing out ideas for entry's and exits, but i'm having a great deal of trouble learning the language. I've learnt to code in MQL and found that i could use Print() and Alert() statements to debug my code give me feedback and find out what value a variable is at a certain point in time. With Zorro I dont seem to be able to do this. Its probably something I'm doing wrong somewhere. How does everyone else do it ?
Below is a script I have been trying to write to trade TMAslope > 0.4 and TMASlope < -0.4.
Code: Select all
function CalcTMATrue(inx)
{
var *Close = series(priceClose());
var dblSum = 0;
var dblSumw = 0;
int jnx, knx;
int sundayCandles = 0;
for ( jnx = 0, knx = 21; jnx < 21; jnx++, knx-- )
{
var temp = Close[inx+jnx];
dblSum += temp * knx;
dblSumw += knx;
}
return ( dblSum / dblSumw );
}
function CalcPrevTrue(inx)
{
var *Close = series(priceClose());
var dblSum = Close[inx] * 20;
var dblSumw = 20;
int jnx, knx;
int sundayCandles = 0;
for ( jnx = 1, knx = 21; jnx < 22; jnx++, knx-- )
{
var temp = Close[inx+jnx];
dblSum += temp * knx;
dblSumw += knx;
}
return ( dblSum / dblSumw );
}
function CalculateSlope(shift)
{
var ATRValue = ATR(60);
var dblTMA;
var dblPrev;
if (ATR(60) != 0){
dblTMA = CalcTMATrue(shift);
dblPrev = CalcPrevTrue(shift);
}
var gadblSlope = ( dblTMA - dblPrev ) / ATRValue;
printf("Bollocks %f",gadblSlope);
return(gadblSlope);
}
function run()
{
Stop = 3*ATR(20);
Profit = 100*PIP;
if(CalculateSlope(0) > 0.4){
enterLong();
}
if (CalculateSlope(0) < -0.4){
enterShort();
}
}
I think CalculateSlope is always returning 0.0 but I cant test to be sure.
Anyhelp would be great.
Dave
-
jcl
- Trader
- Posts: 82
- Joined: Wed Oct 31, 2012 8:04 am
- Location: Frankfurt / Germany
Re: Zorro
The lite-C debugger is not yet implemented in the current Zorro version. So you need to print your variables for debugging, just as with Empty4. I'm aware that this is no professional debugging method, but it will have to do for the moment.
For printing a variable to the message window, use the printf function. In your case, it would look like this:
printf("#\nCalculateSlope: %f",CalculateSlope(0));
or
printf("#\nBollocks %f",gadblSlope);
And by the way, isn't a TMA just a double SMA?
function TMA(var *data,int period) { return SMA(series(SMA(data,period),period)); }
For printing a variable to the message window, use the printf function. In your case, it would look like this:
printf("#\nCalculateSlope: %f",CalculateSlope(0));
or
printf("#\nBollocks %f",gadblSlope);
And by the way, isn't a TMA just a double SMA?
function TMA(var *data,int period) { return SMA(series(SMA(data,period),period)); }
Last edited by jcl on Sun Nov 18, 2012 5:41 pm, edited 3 times in total.
-
jcl
- Trader
- Posts: 82
- Joined: Wed Oct 31, 2012 8:04 am
- Location: Frankfurt / Germany
Re: Zorro
Here is an example of a simple MQL4 EA, and the same EA in Zorro lite-C.
MQL4:
Zorro:
MQL4:
Code: Select all
// trade when the RSI goes above or below a level
int start()
{
string algo = "RSI"
int rsi_period = 12;
double rsi_buy_level = 75.0;
double rsi_sell_level = 25.0;
// get the rsi value
double rsi_value = iRSI(Symbol(), Period(), rsi_period, PRICE_CLOSE, 0);
// set up stop / profit levels
int stoploss = 200;
int takeprofit = 200;
int magic_number = 12345;
// number of trades open for this EA (as defined by magic number)
int num_long_trades = 0;
int num_short_trades = 0;
// total number of trades for the entire account
int all_trades = OrdersTotal();
// cycle through all trades, from 0 up to all_trades
int i;
for(i = 0; i < all_trades; i++)
{
// use OrderSelect to get the info for each trade.
if(OrderSelect(i, SELECT_BY_POS, MODE_TRADES) == false)
continue;
// compare the magic_number of our EA to the order's magic number
if(magic_number == OrderMagicNumber())
{
if(OrderType() == OP_BUY)
{
// count the trades
num_long_trades++;
// close all long trades if rsi is below the sell level
if(rsi_value < rsi_sell_level)
OrderClose(OrderTicket(), OrderLots(),
Bid, 3, Green);
}
if(OrderType() == OP_SELL)
{
// count the trades
num_short_trades++;
// close all short trades if rsi is above the buy level
if(rsi_value > rsi_buy_level))
OrderClose(OrderTicket(), OrderLots(),
Ask, 3, Green);
}
}
}
// if the rsi_value is above the rsi_buy_level,
// enter a long trade
if((rsi_value > rsi_buy_level) && (num_long_trades == 0))
OrderSend(Symbol(), OP_BUY,
1.0, Ask, 3,
Ask - (stoploss*Point),
Bid + (takeprofit*Point),
algo, magic_number,
0, Green);
// if the rsi_value is below the rsi_sell_level,
// enter a short trade
if((rsi_value < rsi_sell_level) && (num_short_trades == 0))
OrderSend(Symbol(), OP_SELL,
1.0, Bid, 3,
Bid + (stoploss*Point),
Ask - (takeprofit*Point),
algo, magic_number,
0, Green);
return(0);
}Code: Select all
// trade when the RSI goes above or below a level
function run()
{
algo("RSI");
int rsi_period = 12;
double rsi_buy_level = 75.0;
double rsi_sell_level = 25.0;
// get the rsi value
double rsi_value = RSI(series(priceClose()),rsi_period);
// set up stop / profit levels
Stop = 200*PIP;
TakeProfit = 200*PIP;
// if the rsi_value is above the rsi_buy_level,
// close all open short trades and enter a long trade
if(rsi_value > rsi_buy_level) {
exitShort();
if(!NumOpenLong) enterLong();
}
// if the rsi_value is below the rsi_sell_level,
// close all open long trades and enter a short trade
if(rsi_value < rsi_sell_level) {
exitLong();
if(!NumOpenShort) enterShort();
}
}
Last edited by jcl on Mon Nov 19, 2012 10:30 am, edited 5 times in total.
-
garyfritz
Re: Zorro
Dave, I think you have a logic error. You call calcTMATrue(shift) and calcPrevTrue(shift). But calcTMATrue starts with a zero sum and sums up jnx=0 (so you start on bar inx) to 20 with an initial weight of 21 on the jnx=0 bar. Then calcPrevTrue starts with a sum starting on the inx bar with a weight of 20. The prev TMA shouldn't include bar inx.
I would calculate it as (calcTMATrue(shift) - calcTMATrue(shift+1)) / ATRvalue. That way you know you're using the same logic in the current and previous TMA, and you don't need calcPrevTrue at all.
I would calculate it as (calcTMATrue(shift) - calcTMATrue(shift+1)) / ATRvalue. That way you know you're using the same logic in the current and previous TMA, and you don't need calcPrevTrue at all.