字号:大 中 小
是否需要优化?0,1——0
本期平仓后不开仓 (如果允许平仓当期可以以收盘价开仓,收益会增加一倍)
----------策略参数--------------------------------
敏感参数: 0.500
最小周期: 4
最大周期: 20
长周期参数: 30.000
价格最小变动单位: 1.00
交易费用/每手: 0
合约规模/手: 1
**************************************************
----------统计报表--------------------------------
盈利次数: 125
获胜盈利所得 : 2.3282
亏损次数: 94
亏损总额 : -0.4213
总交易次数 : 219
总获利: 5.3348
交易费用: 0.6549
净利润: 4.6799
对象买入持有应该能得收益: -0.98
最大资金回撤: -0.1531
最大资金回撤比例:-0.0384
最长不盈利时长: 42
单次最大获利 : 0.2294
单次最大亏损: -0.0186
平均每笔利润: 0.0087
获胜每笔利润: 0.0186
亏损每笔利润: -0.0045
每笔交易波动: 0.0229
总样本时间长度: 692
买入持有时间均值: 1.8
买入持有时间方差: 1.2
买入持有总长度: 213
卖出持有时间均值: 1.9
卖出持有时间方差: 1.7
卖出时间总长度: 188
交易占总时长比例: 0.6
Sharper比值: 0.38
获胜比例: 0.57
回报风险比: 5.53
真实胜率: 0.85
现有持仓浮动收益: 0.0356
Kelly 比值: 0.4675


function [Report Record] = frontierstation (data,P)
%
% function dualstation (data)
%
% purpose:
% frontier station for single object
%
% input:
% data: open ,high ,low ,close
%
% output:
% statistical report of trading station
% reference:
%{
%}
% author: jemnbo@gmail.com
%
% controls:
close all;
num = P.num; % 敏感系数(标准差)
W = P.W; % 长周期(标准差)
X = P.X; % 考察窗口长度(向量)
fee = P.fee ;
DeltaP = P.DeltaP;
Siz = P.Siz;
out=fopen('Report Station','at');
fprintf(out,'**************************************************\n');
fprintf(out,'----------策略参数--------------------------------\n');
fprintf(out,'敏感参数: %6.3f\n',num);
fprintf(out,'最小周期: %6.0f\n',X(1,1));
fprintf(out,'最大周期: %6.0f\n',X(end,1));
fprintf(out,'长周期参数: %6.0f\n',W);
fprintf(out,'价格最小变动单位: %6.2f\n',DeltaP);
fprintf(out,'交易费用/每手: %6.5f\n',fee);
fprintf(out,'合约规模/手: %6.0f\n',Siz);
fprintf(out,'\n');
fclose(out);
fprintf('----------策略参数--------------------------------\n');
fprintf('敏感参数: %6.3f\n',num);
fprintf('最小周期: %6.0f\n',X(1,1));
fprintf('最大周期: %6.0f\n',X(end,1));
fprintf('长周期参数: %6.0f\n',W);
fprintf('价格最小变动单位: %6.2f\n',DeltaP);
fprintf('交易费用/每手: %6.5f\n',fee);
fprintf('合约规模/手: %6.0f\n',Siz);
% procedure begin:
[T, r] = size(data);
if r~=4
error('input data must be a T*4 matrix')
end
if T <= W+ X(end)+50
error('not enough data for invalue')
end
Position = zeros(1,3); % direction ,hold price,point start
Record = [] ; % direction ,start price , clear price, time beg, time end
N = 1; % count num
D = 0; % clear today
%{
New volatility breakout logic:
Buy if close – close of x days ago > num *SQRT(x)* standard deviation of price
changes over the past 100 days
Sell if close – close of x days ago < –1 * num * SQRT(x)* standard deviation of
price changes over the past 100 days
Each trading day, I search for buy and sell signals by calculating signals from
the rules above for all values of x from 5 to 20. We start by comparing the five-day
price change with the standard deviation of price changes over the past 100 days.
If the price change is greater than num times the standard deviation, we have a
potential buy signal. If the price change is less than negative num times the standard
deviation, we have a potential sell signal. After running the five-day price
change through our model, we compare the six-day price change. After evaluating
the six-day price change, we examine the seven-day price change, then the eightday
price change, the nine-day price change, and so forth until we have compared
the 20-day price change.We can use the standard deviation to project price changes over multiple
days. To accomplish this transformation, we need to multiply the standard deviation
by the square root of the number of days in our new price change interval.For
example, suppose the standard deviation of daily price changes is $1. We would
expect 68 percent of future one-day price changes to lie within ±$1, 95 percent to
lie within ±$2, and 99 to lie within ±$3.We can make similar predictions about
future two-day price changes by multiplying the standard deviation by the square
root of 2. We would expect 68 percent of future two-day price changes to lie within
±$1.41, 95 percent to lie within ±$2.83, and 99 percent to lie within ± $4.24.
It is possible to generate conflicting signals using this method as we look for
signals when running x between 5 and 20. For example, the five-day price change
might generate a long signal due to a recent rally. At the same time, a previous
sharp decline might cause the 15-day price change to generate a sell signal. In
these cases, the longer term signal always overrides the shorter term signal. We
would take the short entry associated with the 15-day price change and ignore the
long entry associated with the five-day price change.
Our new volatility breakout strategy can probably be improved by adding an
exit rule to signal when trades have run their course.So, in addition to the entry
rules, we will exit long and short positions using a trailing stop. We’ll trail our best
position profit by two times the 100-day standard deviation of price changes. If
we’re long and prices fall from the highest high seen during the trade by twice the
100-day standard deviation of price returns, we’ll exit our long position. If we’re
short and prices rise from the lowest low seen during the trade by twice the 100-
day standard deviation of price returns, we’ll exit our short position. Using this
trailing exit will help ensure that we close losing trades early and that winning
trades will be closed with a profit before prices turn, leading to a losing trade.
。。。。。。