欢迎光临散文网 会员登陆 & 注册

期货量化交易软件:交易者的工具箱设计指标

2023-08-16 17:05 作者:bili_45793681098  | 我要投稿

简介

什么是指标? 指标是显示特定数据类型的指定工具。 通常这是关于价格系列属性的信息,赫兹量化正是会对这种指标类型做进一步的讨论。

每个指标还拥有自己的属性和特性:例如,值的范围,超买/超卖区间,交叉线、顶部和底部... 这些大量的属性可连续地与主指标值共同使用。 但是,这些属性并不总是有效。 有多种原因 - 指标窗口过小,低密度等。

本文目的旨在协助你改善描述性和信息性的指标值,以及促进代码实施过程的部分自动化和简易化。 我希望以下的代码对专业开发人员和新手都不会造成困难。

本文主要面向的人群需至少拥有 赫兹量化入门水平知识,可以在代码中实施简单想法和算法,了解终端内的代码存储架构,并且可以使用库(experts/libraries)和头文件(experts/include)。

编辑切换为居中


1. 设置一项任务

所有指标中,我想要列出最具信息性的常用指标:

  • 交叉线。


编辑


  • 水平 - 不仅是交叉点的水平,整个水平都将高亮。


编辑

  • 顶部/底部为简单说明。


编辑

  • 上行/下行方向使用不同配色。


编辑

赫兹量化来对其进行讨论。



2. 基本概念

为避免误解,赫兹量化花些时间来查看指标架构。

#property indicator_separate_window // number of visible buffers of the indicator #property indicator_buffers 3 // setting the range of indicator values #property indicator_minimum 0 #property indicator_maximum 100 // setting indicator colors #property indicator_color1  White #property indicator_color2  Red #property indicator_color3  Blue // external settings extern int RSIPeriod       = 9; extern int AppliedPrice    = 0; extern int MAPeriod        = 5; // declaring indicator buffers. Here they can be declared in any order. // Any names can be given to buffers, though better meaningful double Values[];           // Values double SmoothedValues[];   // Smoothed values double Crosses[];          // intersections // Significant number of digits after a decimal point in indicator values int DigitsUsed = 5; // Used empty value. In MQL4 there are two empty values -- EMPTY (-1) // -- used as an empty parameter when calling functions // EMPTY_VALUE (0x7FFFFFFF) -- used as an unacceptable value // (or default value) of a variable in indicators and function calls. // The fact is, most built-in indicators return 0 if there is no value // Besides, in custom (iCustom) indicators the empty value can be // set as any, this must be noted. int EmptyValueUsed = 0; // Initialization function. int init() {   // Number of used buffers can be larger than that of displayed ones; some   // may contain intermediate calculations and additional information. The total   // number of buffers including additional ones is displayed here.   // If there are no additional buffers,   // this line is not needed. Total number must not exceed 8   // IndicatorBuffers(3);   // associate buffers. Indexes must go from 0 till the declared number (not including)   // buffers are drawn in the order of index growing, this is important and can be   // used when righting indicators further.   // It means that a buffer with a larger index is drawn above the buffer with lower one   SetIndexBuffer(0, Values);   SetIndexBuffer(1, SmoothedValues);   SetIndexBuffer(2, Crosses);   // besides, it is important that additional buffers are located after displayed ones   // (i.e. they must have higher index) otherwise problems may occur displaying buffers,   // and sometimes the error can be hardly found   // This function sets an empty value for the buffer with the preset index   // I do not recommend to use this function in order to avoid possible difficulties   // Default empty value for buffers -- EMPTY_VALUE.   // Empty buffer values are not drawn in a chart (except for DRAW_ZIGZAG)   // SetIndexEmptyValue(0, EMPTY_VALUE);     // Set parameters for buffers   SetIndexStyle(0, DRAW_LINE);     // The main signal is a solid line   SetIndexStyle(1, DRAW_LINE, STYLE_DASH); // Smoothed -- dotted line   SetIndexStyle(2, DRAW_ARROW, STYLE_SOLID, 2); // Intersections -- crosses of the size 2     SetIndexArrow(2, 251); // cross code in Wingdings     IndicatorDigits(DigitsUsed); // set number of significant digits after point     // Setting the starting plotting point for each indicator. If in terms of the current index   // the history depth   // is lower than the value written here, the buffer value with this index will not be drawn.   SetIndexDrawBegin(0, RSIPeriod);   SetIndexDrawBegin(1, RSIPeriod + MAPeriod);   SetIndexDrawBegin(2, RSIPeriod + MAPeriod + 1);   return(0); } int start() {   // counting number of bars for re-calculation   int toCount = Bars - IndicatorCounted();       // Calculating values   // counting from history start till the current moment   for (int i = toCount - 1; i >=0; i--)   {      // I understood its convenience only when I started to use it      // I recommend to conduct the normalization of data at once,      // so that later comparison could be easily made      Values[i] = NormalizeDouble(iRSI(Symbol(), 0, RSIPeriod, AppliedPrice, i), DigitsUsed);   }         // Counting smoothed values   for (i = toCount - 1; i >=0; i--)   {      SmoothedValues[i] = NormalizeDouble(iMAOnArray(Values, 0, MAPeriod, 0, MODE_EMA, i), DigitsUsed);   }         // ...     return(0); }


期货量化交易软件:交易者的工具箱设计指标的评论 (共 条)

分享到微博请遵守国家法律