거래 로봇을 무료로 다운로드 하는 법을 시청해보세요
당사를 Facebook에서 찾아주십시오!
당사 팬 페이지에 가입하십시오
스크립트가 흥미로우신가요?
그렇다면 링크 to it -
하셔서 다른 이들이 평가할 수 있도록 해보세요
스크립트가 마음에 드시나요? MetaTrader 5 터미널에서 시도해보십시오
지표

NonLagMA with ATR Bands and Control Panel - MetaTrader 5용 지표

Difficult to tell, but may have started with igorad2003.
게시자:
LukeB
조회수:
8716
평가:
(9)
게시됨:
2018.12.06 03:15
업데이트됨:
2018.12.11 03:50
nonLagMA_LB.mq5 (90.63 KB) 조회
MQL5 프리랜스 이 코드를 기반으로 한 로봇이나 지표가 필요하신가요? 프리랜스로 주문하세요 프리랜스로 이동

The control dashboard has features as shown:

  • Click "Trend Bar" to turn the indicator on or off.
  • Drag and Drop "Non-Lag-MA" to reposition the information display.
  • Clicking "Top Band" will display the 'alfa' array and weight variable of the nonLagMA.  This nothing but a curiosity display.
  • Clicking anyplace on the chart selects the bar at that chart time to have its indicator values displayed.

Control Panel

An option for defining the indicator buffers (and plots) is to separate the data from the code and feed the data for each buffer to a single code block.  Along with the data arrays, an enum is defined to access the arrays with a human readable index to the proper array entry.

Buffer Definitions Data

This data is then provided by a for  loop that accesses the arrays and provides the data to the Index setting functions - each of which only have to be entered once:

  • for(IndicatorBufferIdx idx=0; idx<k_end_indi_idx; idx++){  // process each buffer using the buffer index enumeration

Likewise, a structure is used to define an array of buffers that can be accessed using the same "IndicatorBufferIdx" enum values throughout the program:

struct IndiStruct
 {
   double m_indi_buff[];
 } indi_array[k_end_indi_idx];  // create an indicator buffer for the number of defined indicator buffers

like this: indi_array[k_ATR_up_idx].m_indi_buff[shift];

Two classes are defined and used:

  1. class AlfaClass performs all the calculations for the nonLagMA values, with the alfa array values and weight value calculated only when the constructor is run.  Making multiple AlfaClass instances with differend period's passed to the constructor would readily support an indicator with multiple moving averages displayed.
  2. class InformationDisplayPanel implements all of the functions needed to display the information panel as well as the information panel's interactions with OnChartEvent processing.  It also uses an enumeration to access the data for the panel objects with human readable text in the code.Information Panel Label Object Data
The OnChartEvent function processes three different events,
  • CHARTEVENT_CLICK to select a time (chart bar) for indicator data display.
  • CHARTEVENT_OBJECT_CLICK to detect object clicks and enable turning the indicator on and off.
  • CHARTEVENT_OBJECT_DRAG to enable moving the information panel.

OnCalculate includes 6 function calls, each of which returns false if there is a failure in its processing and terminates the OnCalcualte function by returning the number of bars that have been previously successfully processed (the value in the static integer last_prev_calculated):

  • SetCalcuateLimits sets the oldest bar that the indicator should process (starting_bar), as well as setting the number of bars to get data from the terminal from (in to_copy).  I moved the call for setting the terminal data handles function (HandlesSet) from the usual OnInit location, to be called from inside of SetCalculateLimits on it's first run to implement automatic re-tries if there were to be an error getting the handles.
  • TerminalCalculationsAreComplete checks if the terminal has finished calcualting iMA and iATR data.  On startup, this function almost always returns an error, and the terminal automatically re-runs OnCalculate with a success on the 2nd try.  Check the Experts tab on the terminal for indicator error logs like this:
    • "TerminalCalculationsAreComplete: Not all data of teh MA_handle is calculated (-1 bars calculated out of 66109). Error: 4806, Requested data not found, 1 times."
  • PerformBufferCopies retrieves terminal data ( moving average and atr) for the indicator to use.
    • the moving average from the terminal is a single bar moving average - its only purpose is to get the ENUM_APPLIED_PRICE value for each bar, PRICE_CLOSE by default.  The actual moving average is calculated by the indicator (default is 30 bars).
  • RunTheIndicator performs the indicator calculations and subsequent display.  RunTheIndicator is also called from the OnChartEvent function when the indicator is turned off and back on to re-display the indicator.
  • ShowBarStatistics - finally, the indicator's information panel is displayed.
I have an MQL4 'twin' to this program that can be used to do a side-by-side comparison of the code blocks and functions that I'd be happy to provide to any one curious to see it.


Filtered frama Filtered frama

Fractal Adaptive Moving Average with value filter

Frama - floating levels Frama - floating levels

Fractal Adaptive Moving Average with floating levels

Hull quad Hull quad

Hull quad

Schaff trend cycle - Hull Schaff trend cycle - Hull

Schaff trend cycle - Hull