: | : | :期货量化学习 | :期货量化 |
返回列表 发帖

鼎元全自动C++软件【函数公式设计:统一调用模板】说明

鼎元全自动C++软件【函数公式设计:统一调用模板】说明

1、鼎元C++全自动化软件使用函数或公式计算价格及其它变量可以在主程序中直接设计并计算,也可以通过调用函数公式来计算。

2、因为调用函数或公式计算,一会减少主程序的代码量,二是会比较有条理,这也是我建议大家将一些常用的函数与指标写到专门的模板里面,模块化函数指标会减少学习难度。

3、如何新建一个公式模板:

(1)、资源管理器---源文件---右键单击 ---填加---选择cpp文件 --- 取名“function.cpp”

(2)、配置一下外部引用项:
  1. //****************************************************************外部引用文件开始(谨慎修改)
  2. #include "pch.h"
  3. #include "test.h"
  4. #include <vector>
  5. #include <windows.h>
  6. #include <fstream>
  7. #include <stdio.h>
  8. #include <mmsystem.h>
  9. #include <thread>
  10. #pragma comment(lib,"winmm.lib")
  11. #include <algorithm> // For std::min_element and std::max_element
  12. #include <deque>
  13. using namespace std;
复制代码
(3)、新建完成,新加了一个空白的公式函数专用cpp文件。可以将我设计的公式函数放进去。参考地址:http://www.qhlt.cn/thread-160230-1-1.html
(4)、还在test.h文件中声明一下全局变量才能在后面调用。若是不声明,是没法使用的。如下:

在一个private 里面即可,声明后就可以在主程序设计区任意位置来调用它了。重要说明:这个全局的声明与上面的函数公式要对应起来,其时出现不同版本,容易导致报错
  1. //指标公式变量声明******************************************************************test头文件指标公式变量名称模块开始(修改与编辑指标参数变量)
  2.         double iff(bool cond1, int num, int ref);//iff函数
  3.         double max2(double a, double b);//返回a,b中较大值
  4.         double max3(double a, double b, double c);//返回a,b,c中最大值
  5.         double min2(double a, double b); //返回a,b中较小值
  6.         double min3(double a, double b, double c);//返回a,b,c中最小值
  7.         double waverage(string period, string inst, int num);//计算Weighted Moving Average,加权移动平均线
  8.         double average(string period, string inst, int num); //average,ma函数变量,atr计算功能
  9.         double highest(string period, string inst, int num);//计算NUM周期最高价格
  10.         double highestN(string period, string inst, int num, int ref);//计算REF前个bar的num周期最高价格
  11.     double lowest(string period, string inst, int num); //计算NUM周期最低价格
  12.         double lowestN(string period, string inst, int num, int ref);//计算ref前个bar的num周期的最低价格
  13.         double closeN(string period, string inst, int ref);//计算ref前个bar的收盘价格
  14.         double avgtruerange(string period, string inst, int num); //计算真实波动幅度平均值(average true range)
  15.         double Variance(string period, string inst, int num);//计算方差公式变量
  16.         double StandardDev(string period, string inst, int num);//计算标准差公式变量
  17.         double Volatility(string period, string inst, int num);//计算历史波动率(CALCULATING HISTORICAL VOLATILITY)
  18.         double bollingerbands(string period, string inst, int num, int ref); //计算boll布林带变量
  19.         //指数移动平均返回具体数据时调用xaverage,返回数组时则用ema调用。数组形式多用于指标计算中间变量
  20.         double xaverage(string period, string inst, int num);//计算num周期指数移动平均(Exponential Moving Average)值
  21.         vector<double>ema(vector<double>pc, int num);//ema计算返回数组vector形式指数移动平均
  22.         //指数移动平均返回具体数据时调用xaverage,返回数组时则用ema调用。数组形式多用于指标计算中间变量
  23.         vector<double>EMAvectorCaL(vector<double>pc, int num);//EMA容器计算形式
  24.         vector<double>MACDcalculate(vector<double>pc, int shortPeriod, int longPeriod);//计算MACD
  25.         double mav(vector<double>pc, int num);//计算简单MA数组形式
  26.         double hhv(vector<double> pc, int num);
  27.         double llv(vector<double> pc, int num);
  28.         double AEMA(string period, string inst, int num, int pds);//自适应移动平均线(Adaptive Exponential Moving Average, AEMA)
  29.         vector<double>aema, highs, lows; //vector变量容器
  30.         double a0, a1, a2, a3, a4, value2, value3, mltp1, mltp2, rate, aema1, aema2;//必要变量,自适应移动平均线
  31.         double marketstrength(string period,string inst, int num);//marketstrength函数调用与计算
  32.         double Momentum(string period, string inst, int num); //动量指标(Momentum Index,MTM)计算与指标调用
  33. //指标公式变量声明******************************************************************test头文件指标公式变量名称模块结束(修改与编辑指标参数变量)
复制代码

论坛官方微信、群(期货热点、量化探讨、开户与绑定实盘)
 
期货论坛 - 版权/免责声明   1.本站发布源码(包括函数、指标、策略等)均属开放源码,用意在于让使用者学习程序化语法撰写,使用者可以任意修改语法內容并调整参数。仅限用于个人学习使用,请勿转载、滥用,严禁私自连接实盘账户交易
  2.本站发布资讯(包括文章、视频、历史记录、教材、评论、资讯、交易方案等)均系转载自网络主流媒体,内容仅为作者当日个人观点,本网转载此文出于传递更多信息之目的,并不意味着赞同其观点或证实其描述。本网不对该类信息或数据做任何保证。不对您构成任何投资建议,不能依靠信息而取代自身独立判断,不对因使用本篇文章所诉信息或观点等导致的损失承担任何责任。
  3.本站发布资源(包括书籍、杂志、文档、软件等)均从互联网搜索而来,仅供个人免费交流学习,不可用作商业用途,本站不对显示的内容承担任何责任。请在下载后24小时内删除。如果喜欢,请购买正版,谢谢合作!
  4.龙听期货论坛原创文章属本网版权作品,转载须注明来源“龙听期货论坛”,违者本网将保留追究其相关法律责任的权力。本论坛除发布原创文章外,亦致力于优秀财经文章的交流分享,部分文章推送时若未能及时与原作者取得联系并涉及版权问题时,请及时联系删除。联系方式:http://www.qhlt.cn/thread-262-1-1.html
如何访问权限为100/255贴子:/thread-37840-1-1.html;注册后仍无法回复:/thread-23-1-1.html;微信/QQ群:/thread-262-1-1.html;网盘链接失效解决办法:/thread-93307-1-1.html

鼎元C++量化程式码技术指标源码C++版模板【C++期货技术指标模板,建议在test.h和test.cpp中同步至最新,方便统一调用和使用,一次编辑多次使用!】http://www.qhlt.cn/thread-160230-1-1.html
如何访问权限为100/255贴子:/thread-37840-1-1.html;注册后仍无法回复:/thread-23-1-1.html;微信/QQ群:/thread-262-1-1.html;网盘链接失效解决办法:/thread-93307-1-1.html

TOP

这个公式调用主要是看个人的喜好,若是不想将不用的指标也放进代码里面,而是喜欢简洁的代码,也可以使用哪个代码时就使用相应的模块。这样也是挺好的。
如何访问权限为100/255贴子:/thread-37840-1-1.html;注册后仍无法回复:/thread-23-1-1.html;微信/QQ群:/thread-262-1-1.html;网盘链接失效解决办法:/thread-93307-1-1.html

TOP

返回列表