당사 팬 페이지에 가입하십시오
- 조회수:
- 6200
- 평가:
- 게시됨:
- 2018.12.25 03:11
- 업데이트됨:
- 2019.01.19 18:06
-
이 코드를 기반으로 한 로봇이나 지표가 필요하신가요? 프리랜스로 주문하세요 프리랜스로 이동
This is a utility for beginning indicator programmers, or others, that
want to have a look at values provided by OnCalculate and a few other
functions.
The indicator shows:
1) The most recent value provided with the most recent OnCalculate call.
2) The previous value from the previous OnCalculate call.
3) The first value from the first time OnCalculate executed.
4) Each array's series value, as_series or not_series, with the ability to change the series value with a click on the display.
Version 1.10 adds the ability to dynamically change if the arrays are set as series or not - just click on the text. Also, the Window Bars and First visible Bar values are dynamically set with chart changes. The ON/OFF display indicates what will happen with its settings on the next OnCalculate execution, versus what happened on the most recent execution.
Version 1.20 adds the ability to choose to have the indicator set the arrays to as_series or not_series, also just by clicking on the text. The indicator now also displays both ends of the time array and both ends of the iMA buffer. These changes are intended to make obvious the difference between as_series and not_series arrays. Also, the display is now refreshed as needed using the OnTimeEvent handler instead of doing the display on every quote. This reduces the time for executing OnCalculate from around 300 ms to less than 1 ms - the code to check the execute time has been left in OnCalculate and only needs to be un-commented to display the execution milliseconds.
This picture shows the values the OnCalculate_Values utility displays. Note the three values, delimited by the '/', separating the "Most Recent Value", "Previous Value" and "First Value". The OnCalculate values are set to 'as_series' or 'not_series' with every OnCalculate event - when Set Arrays is 'ON', otherwise, they are left to the terminal default value. Note the value after the array names in brackets, that value indicates which bar the value comes from - the index '0' value, or the 'value at the maximum index'.
The code implements a single indicator line, a plot of the Open price of each bar as provided by iMA; the purpose is to provide a buffer to use the "BarsCalculated" function and to show the display of an Indicator when set to 'as_series' or 'not_series'. Clicking iMA_Val[0] sets the iMA buffer to as_series or not_series only once, when clicked; the iMA indicator array is not set with each call of OnCalculate.
A collection of arrays hold the properties of each of the display objects (OBJ_LABEL) in the display:
The "ArrayGetAsSeries" function is used to determine if the arrays in OnCalculate parameters are time series arrays or not, and the display shows the outcome (As_Series or Not_Series) - the display shows that these arrays are not series initially, or from one call to the next after being set as series (the SetAsSeries function sets them as series only when it is on, it lets them revert to their default when it is off - it does not set 'as series' to false).
The 3 member array, ary_OnCalcVals, holds the 1) Most Recent, 2) Previous, and 3) First values found in the OnCalculate parameters. The CopyNewToOld and MoveNewTo functions take the current value for each display parameter and places it in the historical storage provided by ary_OnCalcVals.
![EMA to SMA MACD - on chart](https://c.mql5.com/i/code/indicator.png)
EMA to SMA MACD - on chart
![EMA to SMA MACD - extended](https://c.mql5.com/i/code/indicator.png)
EMA to SMA MACD - extended