matlab中均线交易策略,【每日一策】Matlab量化交易策略之 均线选股策略

策略名称:均线选股策略

策略说明:

对沪深300全市场扫描

买入条件:

1 短均线大于长均线

2 最近N个交易日短均线大于长均线的次数满足某个阈值

3 当前交易日的长均线值处于某个高位

出场条件:

止损:价格跌破入场价的一定百分比

止盈:价格高出入场价的一定百分比

回测曲线(由Auto-Trader提供回测报告)

08b05ce0d596c72a04d00d75c1365631.gif

2017-3-17 10:59:44 上传

下载附件 (64.98 KB)

策略代码:

function MATrading(ShareNum,Freq,N1,N2)global s;%获取账户句柄targetList = traderGetTargetList(); %获取交易标的句柄HandleList = traderGetHandleList();pctloss=0.05;pctprofit=0.2;pctclose=0.02;lags=25;for j=1:length(targetList)        [time,open,high,low,close,volume,turnover,openinterest] = traderGetKData(targetList(j).Market,targetList(j).Code,'day',Freq, -lags, 0,false,'FWard');        if length(close)MAl(end);    a=sum(  MAs(end-N1+1:end-1) > MAl(end-N1+1:end-1) );    opencon2=(a==0);    opencon3=(MAl(end)/MAl(end-1))>0.995;    opencon4=close(end-1)>0.9*max(high(end-10:end-1));        %% 开仓    if mp==0 && opencon1 && opencon2 && opencon3 && opencon4        OrderID=traderDirectBuy(HandleList(1),targetList(j).Market,targetList(j).Code,ShareNum,0,'market','1');        s(j).openprice=traderOrderFilledPrice(HandleList(1),OrderID);    end        %% 平仓条件    closecon1=close(end)(1+pctprofit)*(s(j).openprice);    b=(max(high(end-N1+1:end))-min(low(end-N1+1:end)))/mean(close(end-N1:end));    closecon3=b0 && closecon1 && closecon2 && closecon3        traderPositionTo(HandleList(1),targetList(j).Market,targetList(j).Code,0,0,'market','1');        s(j).openprice=0;    endend

更多免费策略代码下载请登录DigQuant社区-策略资源下载~

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/440468.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

docker php 乱码,如何解决docker安装zabbix5.0界面乱码

如何解决docker安装zabbix5.0界面乱码?zabbix图形界面乱码如下:解决:docker部署zabbix-web和源码安装zabbix-web一样,字体都是存储在/usr/share/zabbix/assets/fonts/1、从windown拷贝simkai.ttf(楷体)文件到docker的zabbix-web里…

【POJ - 1330】Nearest Common Ancestors(lca,模板题)

题干: A rooted tree is a well-known data structure in computer science and engineering. An example is shown below: In the figure, each node is labeled with an integer from {1, 2,...,16}. Node 8 is the root of the tree. Node x is an ancestor o…

java redis 流水线,Redis系列(1) —— 流水线

写在前面去年下半年,出于学习Redis的目的,在看完《Redis in Action》一书后,开始尝试翻译Redis官方文档。尽管Redis中文官方网站有了译本,但是看别人翻译好的和自己翻译英文原文毕竟还是有很大的不同。这一系列文章之前发布在GitB…

【HDU - 6187】Destroy Walls(思维,最大生成树)

题干: Long times ago, there are beautiful historic walls in the city. These walls divide the city into many parts of area. Since it was not convenient, the new king wants to destroy some of these walls, so he can arrive anywhere from his castl…

【HDU - 6184】Counting Stars(三元环计数,二分,优化暴力,O(m*sqrt(m)),图论)

题干: Little A is an astronomy lover, and he has found that the sky was so beautiful! So he is counting stars now! There are n stars in the sky, and little A has connected them by m non-directional edges. It is guranteed that no edges connec…

php 取oracle图片,在PHP中将图片存放ORACLE中_php

我这里提供一个用php操纵blob字段的例子给你,希望能有所帮助!这个例子是把用户上传的图片文件存放到BLOB中。假设有一个表,结构如下:CREATE TABLE PICTURES (ID NUMBER,http://www.gaodaima.com/44856.html在PHP中将图片存放oracl…

【HDU - 6183】Color it(CDQ分治 或 动态开点线段树)

题干: Do you like painting? Little D doesnt like painting, especially messy color paintings. Now Little B is painting. To prevent him from drawing messy painting, Little D asks you to write a program to maintain following operations. The speci…

php create()方法,ThinkPHP中create()方法自动验证实例

ThinkPHP中create()方法自动验证实例2020-06-16 04:24:32自动验证是ThinkPHP模型层提供的一种数据验证方法,可以在使用create创建数据对象的时候自动进行数据验证。原理:create()方法收集表单($_POST)信息并返回,同时触发表单自动验证&#x…

【蓝桥杯官网试题 - 历届试题】格子刷油漆(dp)

题干: 问题描述 X国的一段古城墙的顶端可以看成 2*N个格子组成的矩形(如下图所示),现需要把这些格子刷上保护漆。   你可以从任意一个格子刷起,刷完一格,可以移动到和它相邻的格子(对角相邻也…

oracle软件静默安装程序,【oracle】静默安装 oracle 11gr2

【序言】oracle 提供了静默安装方法在不适用图形界面的情况下安装 oracle 软件 ,创建db,配置netca,快速完成oracle 的部署。在以下情形中可以使用静默安装a OUI 的 GUI 界面远程交互比较慢 .b 数据库服务器无法使用图形界面访问.c 批量部署oracle (标准环境统一情况下可以使用o…

【2050 Programming Competition - 2050 一万人码 】非官方部分题解(HDU)

1001 开场白 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 12147 Accepted Submission(s): 3502 Problem Description 来自世界各地的年青人在 https://2050.org.cn 握手团聚, 他们是航空…

oracle数据库建表视频,Oracle数据库的创建表全

CREATE TABLE "库名"."表名" ("FEE_ID" VARCHAR2(10 BYTE) constraint ABS_FEE_ID primary key,--主键,必须要有序列"BANK_GROUP_ID" VARCHAR2(5 BYTE),"ABS_PRODUCT_ID" VARCHAR2(30 BYTE))TABLESPACE "表…

oracle dump enq hw,经典故障分析 - ASSM引发的索引争用与 enq HW -contentio

作者介绍:孙加鹏 云和恩墨技术顾问六年Oracle技术顾问经验,所服务的行业包括电信运营商、金融业、制造业等。擅长Oracle的故障诊断、高可用架构、升级迁移等。目前主要服务于上海金融类客户。1故障概述2017年07月24日11:58左右,客户核心数据库…

【ZOJ - 3946】Highway Project(最短路子图,维护双权值,贪心,最小树形图)

题干: Edward, the emperor of the Marjar Empire, wants to build some bidirectional highways so that he can reach other cities from the capital as fast as possible. Thus, he proposed the highway project. The Marjar Empire has N cities (including…

【ZOJ - 3956】Course Selection System(01背包)

题干: There are n courses in the course selection system of Marjar University. The i-th course is described by two values: happiness Hi and credit Ci. If a student selects m courses x1, x2, ..., xm, then his comfort level of the semester can be…

Linux把文件移动到容器外,Docker容器与主机之间拷贝文件的方法

一般情况下,我们在启动Docker容器的时候可以使用-v参数映射宿主机的文件或者目录到容器里,这样的话,在宿主机相关目录下的文件修改会自动在容器里生效。但是,如果我们已经启动了一个容器的话,就只能使用下面的这种方式…

【计蒜客 - 2019南昌邀请赛网络赛 - H】Coloring Game(找规律,思维dp)

题干: David has a white board with 2 \times N2N grids.He decides to paint some grids black with his brush.He always starts at the top left corner and ends at the bottom right corner, where grids should be black ultimately. Each time he can mov…

【HDU - 6514】Monitor(二维差分,前缀和)

题干: Monitor Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 163840/163840 K (Java/Others) Total Submission(s): 872 Accepted Submission(s): 145 Problem Description Xiaoteng has a large area of land for growing crops, and the land…

【CodeForces - 1153D】Serval and Rooted Tree(树形dp)

题干: Now Serval is a junior high school student in Japari Middle School, and he is still thrilled on math as before. As a talented boy in mathematics, he likes to play with numbers. This time, he wants to play with numbers on a rooted tree. …

实验楼Linux基础挑战2答案,实验楼-Linux基础-实验二 Linux的基本概念及操作

一、实验介绍1.1 实验内容实验楼环境介绍常用 Shell 命令及快捷键Linux 使用小技巧1.2 实验知识点Linux 基本命令通配符的使用查看帮助文档二、桌面环境1.Linux 桌面环境介绍相对于现在的 Windows 系统,UNIX/Linux 本身是没有图形界面的,我们通常在 UNIX…