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

Indicator Doctor: Find Out Why Your MT5 Indicator Shows Nothing on the Chart - MetaTrader 5용 지표

조회수:
128
평가:
(1)
게시됨:
MQL5 프리랜스 이 코드를 기반으로 한 로봇이나 지표가 필요하신가요? 프리랜스로 주문하세요 프리랜스로 이동
Indicator Doctor: Find Out Why Your MT5 Indicator Shows Nothing on the Chart

The idea behind it

"I attached the indicator and the chart is empty" is one of the most common questions about custom indicators. The cause is rarely mysterious, but it is hard to see: the indicator is running, it has a handle, it may even show up in the list of indicators, and nothing is drawn. Most of the time the data is the problem, not the drawing, and the data can be read from outside through the same functions that other programs use: ChartIndicatorGet() , BarsCalculated() and CopyBuffer() .

The Doctor does exactly that. Every few seconds it takes each indicator on the chart, one after another, reads the newest bars of every buffer and applies six tests in a fixed order. The first test that fits gives the verdict:

  • R1, not ready. The indicator has calculated no bars, or none of its buffers can be read. The history may still be loading, the initialization may have failed (look at the Experts log), or the indicator depends on another one that is missing.
  • R2, empty. Every value in the newest InpDepth bars is empty ( EMPTY_VALUE or not a number). Typical causes: a period longer than the loaded history, a calculation loop that never writes the plotted buffer, a wrong buffer index, or a condition that is never true.
  • R4, all zero. Values exist, but every one of them is exactly 0. The buffer is declared but never filled, or an input of zero makes the result zero.
  • R3, newest bars only. The oldest value is among the newest InpRecentBars bars, although more bars are loaded. This is the classic loop that handles only the last bar and never fills the history.
  • R5, not in view. Values exist in the bars that were read, but none of them is in a bar that is visible now. The chart may be scrolled into the past, or the plot is shifted away from the visible bars.
  • R6, off scale. There are values in the visible bars, but none of them is inside the vertical scale of the window the indicator sits in. The standard example is an RSI that was written for a separate window but is drawn in the main window, where the scale is 1.0850 and the values are 30 to 70.

An indicator that passes all six tests is called healthy. Because the first match wins, an indicator gets one verdict at a time: the most basic problem is reported first, and the next one appears after it is fixed.

A verdict is not shown at once. It has to be the same in InpConfirmScans scans in a row (two by default), because an indicator that was just attached or a chart that is still loading history looks broken for a moment. Until then the row shows CHECKING. A scan also runs when the chart is scrolled or zoomed, because R5 and R6 depend on what is visible.

The Doctor never changes the other indicators and does not draw anything of its own in the chart area except the panel. Every handle that it gets is released in the same scan. The calculation in OnCalculate() is trivial (it clears new bars and writes the number of problems to the newest bar). The scan itself runs from a timer, so it also works when the market is quiet and no ticks arrive.

How to interpret it

  • Panel (top left of the chart).
    • Line 1: symbol, timeframe, how many of the newest bars were read from each buffer, and the visible bars (0 is the newest).
    • Line 2: number of indicators examined, how many have a confirmed problem and how many are still being checked.
    • Rows (up to InpMaxRows ): verdict code and label, the window number (0 is the main chart), the name of the indicator and the facts behind the verdict. Rows with a problem come first, in the order of the chart, then rows that are still being checked, then healthy ones. A name that appears twice in one window is marked with * .
    • Advice line: one sentence about the first problem on the list.
    • Report line: Still stuck? Post in the comments: R6 | EURUSD | H1 | RSI(14) . The code, the symbol, the timeframe and the name of the first problem, ready to be copied.
  • Row colors. White: a problem. Gray: healthy. Silver: still being checked.
  • Facts in the rows. For R6 they are the range of the values in the visible bars and the scale of the window, for R5 the visible bars and the oldest bar that holds a value, for R3 the oldest bar that holds a value. A healthy row shows the number of buffers and the range of the values in view.
  • Data Window. "Problems found" is the number of confirmed problems, written to the newest bar only. It shows empty until the first scan is done.
  • Experts log. When the verdict of an indicator changes, one line is written: IndicatorDoctor: RSI(14) (window 0): R6 OFF SCALE - values 16.0204..81.0088, scale of the window 1.08712..1.09646 . A new indicator that is healthy is not logged. Switch it off with InpLogChanges .
  • Nothing is drawn by the Doctor itself. The indicator has one buffer with the plot style DRAW_NONE. The chart objects are the panel lines only.


Fig. 1. Six indicators on one chart. MA(50) and Stoch(5,3,3) are healthy. RSI(14) in the main window is off the price scale (R6), Daily Levels has no value in the visible bars (R5), My Arrows holds values only in the newest bars (R3, two arrows are visible on the last two bars) and Spread Meter has no values at all (R2). The panel lists the problems first and prints the advice and the report line for the first one. Black and white screenshot, per the Code Base image guidelines.

External variables (inputs)

Input Default Purpose
InpScanSeconds 3 Seconds between two scans (1-60). The first scan runs on the first timer tick, and a scan is also started when the chart is scrolled or zoomed.
InpDepth 500 Newest bars read from every buffer (50-5000). If the first visible bar is older than this, more bars are read so that the visible bars are always covered. Raise it for indicators that give rare signals.
InpRecentBars 3 Reason R3: values only in this many newest bars (1-50).
InpConfirmScans 2 Scans in a row that must give the same result before a verdict is shown (1-10). 1 shows every result at once.
InpLogChanges true Write a line to the Experts log when the verdict of an indicator changes.
InpShowPanel true Show the panel. The scan, the log and the Data Window value work without it.
InpMaxRows 6 Indicator rows in the panel (1-8). The summary line always counts all indicators.
InpProblemColor clrWhite Color of rows with a problem and of the advice line.
InpOkColor clrGray Color of healthy rows.
InpTextColor clrSilver Color of the other panel text.
InpFontSize 8 Panel font size (Consolas). The line height follows the size.
InpPanelX , InpPanelY 8, 14 Panel offset from the upper left corner of the chart, in pixels.

Recommended use

  • Where to run it. Attach it to a live or demo chart that has the indicators in question, on any symbol and timeframe. It looks at the indicators of the chart it is attached to. It does not work in the Strategy Tester, where there is no chart with indicators to read.
  • Order of work. Read the code of the first problem in the list, fix it, and wait for the next scan. Because the first matching test wins, a second problem can appear after the first one is gone. R6 on an oscillator is normally solved by #property indicator_separate_window , not by changing the values.
  • What it cannot see. The Doctor reads the numbers in the buffers. It does not know the plot style, the color, the width, the visibility on a timeframe or the code. A plot that is set to DRAW_NONE, drawn in the color of the background or hidden on the current timeframe is reported as healthy, because its data is fine. If the panel says that everything is healthy and the plot is still invisible, the cause is in the properties of the plot, not in the data.
  • One healthy buffer is enough. A buffer used for calculation cannot be told apart from a buffer that is plotted. An indicator whose plotted buffer is empty but whose calculation buffer holds values is reported as healthy.
  • Empty values. The tests use EMPTY_VALUE and not-a-number as "empty". The empty value that an indicator sets for its own plot ( PLOT_EMPTY_VALUE ) cannot be read from outside. An indicator that marks empty bars with 0 is reported as R4 when every value is zero. An indicator that marks them with another number (for example -1) is seen as having values there.
  • Rare signals. An indicator that gives few signals, such as arrows, can be reported as R2 when there was no signal in the newest InpDepth bars. Raise InpDepth before you decide that it is broken. R2 also appears when the period of an indicator is longer than the loaded history.
  • R6 in separate windows. A separate window normally scales itself to the data, so R6 appears mostly in the main window, or in a separate window with a fixed scale ( indicator_minimum and indicator_maximum ).
  • Same name twice. ChartIndicatorGet() finds an indicator by its short name, so two indicators with the same name in one window cannot be told apart. Both rows show the verdict of the first one, and the second is marked with * . Give the copies different names.
  • Short loading phases. An indicator that has just been attached, or a chart that is loading history, can show R1 or R2 for a few seconds. This is why a verdict has to be seen in InpConfirmScans scans in a row.
  • Limits. At most 64 indicators of a chart are examined, and at most 32 buffers of each. The Doctor skips itself by its short name IndicatorDoctor .
  • Performance and memory. One scan reads the newest InpDepth bars (more when the chart is scrolled far into the past) of every buffer of every other indicator. With the defaults this is a few thousand values per indicator every three seconds. Between scans nothing is calculated, and OnCalculate() touches the new bars only.
  • Chart objects. The only objects are the panel lines in the main chart window, named with the prefix ID_ . They are removed in OnDeinit() , where the timer is stopped as well.
  • Account types. The indicator does not trade and does not depend on netting or hedging accounts.
  • Your turn: post your reason code. Attach the Doctor to the chart where your indicator is invisible, copy the report line from the panel and post it in the comments, for example R3 | GBPUSD | M15 | my indicator . Say whether the verdict was right and what the fix was. If the Doctor said that everything is healthy and the plot was still missing, post what you found: that is how the list of limits above can be completed, and how the next version can get a seventh reason.
EzoO Trade Manager - break-even and trailing stop for open positions (manual or any EA) EzoO Trade Manager - break-even and trailing stop for open positions (manual or any EA)

Moves the stop loss of already open positions (manual or from any EA) to break-even and then trails it by points or ATR. Never opens or closes trades, only moves the SL in your favour.

EzoO Session Boxes - Asian, London and New York high-low boxes with auto GMT offset EzoO Session Boxes - Asian, London and New York high-low boxes with auto GMT offset

Draws Asian, London and New York session boxes (high/low and range in points) for the last N days. Session hours are set in GMT; the broker's GMT offset is detected automatically.

Why Your Indicator Gives Different Values on Another Broker Why Your Indicator Gives Different Values on Another Broker

Checks the bar history of the chart for six defects that make an indicator give different values on another broker: missing bars, impossible values, filler bars, repeated bars, bars without ticks and price spikes. Every defective bar is marked in the indicator window, and a panel gives a health score for the symbol and timeframe, the largest holes, the defect counts and one line that can be pasted into a comment to compare brokers.

Account Settings Sync - Bidirectional EA Settings Across Charts Account Settings Sync - Bidirectional EA Settings Across Charts

Small MQL5 library that shares an EA's own runtime settings between charts of the same account, with edits from either chart, a file lock and per-field merge.