TradeXray TrendAutoLines
- Indicadores
- Versão: 2.22
- Ativações: 10
TradeXray TrendAutoLines
What it does. It draws trend lines from one fixed geometric rule, and it never moves a line after that line has been drawn.
What it does not do. It does not tell you when to buy or when to sell, and it does not claim that these lines have any statistical edge. We have not measured one, so we do not say that one exists.
What has been checked. The no-repaint behaviour is not just a sentence in this description. It is checked by an automated verification harness, and the harness reports zero mismatches. The central check is that placing the as-of axis at a past time T produces exactly the same picture as physically cutting the data at T.
Why this description has no numbers in it
This description contains no win rate, no profit figures and no backtest results. That is not a formality. We have not tested whether these lines have any predictive value, so there is nothing to report. What is offered here is a drawing rule that is written down in full, and a machine check that the tool follows that rule.
The drawing rule
Pivots are 5-bar fractals: the middle bar is higher than the two bars on each side, or lower than the two bars on each side. The half-width is an input, so 5 bars is the default and not a fixed constant.
Inside a scan window the indicator takes the high of the interval and the low of the interval. If the high comes first, the leg is a down leg from that high A to that low B. If the low comes first, the leg is an up leg.
For a down leg, the three lines are the first three edges of the upper convex hull walked from A. In plain words: start horizontal at A, rotate downward, and draw to the first high you hit. From that point, rotate again. Then once more. That is the outer, middle and inner line. For an up leg the same procedure runs on the lower hull, mirrored.
Three lines per set, and no more. If you want finer structure, move to a lower timeframe. The outer line always has a smaller slope than the middle line, and the middle line a smaller slope than the inner line. That ordering is a property of the hull, not a setting.
Anchors can be taken from wicks or from bodies. The default is wicks, that is highs and lows. Setting the anchor price to bodies uses opens and closes instead, for pivots, for the hull and for the state tests alike. Which of the two is the correct reading of the method is not something we have settled, so both are offered and neither is presented as the right one.
What no repaint means here, and how it is checked
A line is anchored to two bars at the moment the set is created, and those two anchors are frozen. The indicator never rewrites them. New market highs and lows add new sets; they do not edit old ones.
Three things make this possible. The forming bar is never used. A pivot does not exist until the bars to the right of it have closed. And by default the indicator waits for an opposite confirmed pivot after B before it draws anything at all.
The verification harness runs the same drawing logic outside the terminal over synthetic series and random walks, and checks, at every bar of every series:
- Truncation invariance: the result from an array physically cut to t bars equals the result from the full array reproduced at t. Zero mismatches.
- Monotone addition: sets already recorded are never rewritten, only appended to. Zero violations.
- Edge invariance: the three edges of a recorded set never change afterwards. Zero mismatches.
- As-of invariance: placing the axis at a past time T equals cutting the data at T. Zero mismatches, across both hull modes, both anchor modes, both anchor prices, and with the freeze option on and off.
Please read that claim narrowly, because we state it narrowly. The harness is a port of the same drawing logic into another language. It is not a second, independently designed implementation, and we do not present it as one. What makes the check worth running is the kind of thing it tests: these are mathematical properties of the output, such as invariance under truncation, that logic which looks ahead cannot satisfy. A port of a rule that peeked at future bars would fail these checks, not pass them by family resemblance.
It is a check of the drawing logic, run outside MetaTrader. It is not a statement about market behaviour, and it is not a statement that the lines are useful.
One honest consequence. Lines do not move, but that is not the same as the screen never changing. When price makes a new high or low, a new set is added, and old sets drop off the chart once the display limits are reached. The old lines were not moved; they were retired.
The as-of axis, and the two handles
A vertical line on the chart is the as-of axis. Drag it to the left and the whole chart is redrawn as it stood at that time: the same sets, the same states, the same labels, using nothing that happened afterwards. A second vertical line sets the left edge of the scan range.
Each of the two lines carries a handle, and the handle reads out the value that line controls:
LINES :: AXIS 08.11 21:45 LINES :: RANGE 214
The word in front is a short tag for the indicator the tab belongs to. If a second indicator on the same chart also draws an as-of tab, the tag is how you tell the two apart at a glance.
The handle is one small tab, not a cluster of parts. It is laid out in screen pixels rather than on the price grid, so it keeps the same size and the same shape at every zoom level. It is filled with the same colour as the panel, and the readout is drawn on that fill. A two pixel strip down its left edge carries the colour of the line the tab belongs to, and that strip is how the two tabs are told apart at a glance.
Press the left mouse button anywhere on the tab and drag. The line follows at once. There is no step before that one: you do not select the tab first, you do not double click it, and you do not have to find a smaller target inside it. The indicator does its own hit testing against the rectangle it drew, so the area that responds is the tab you can see, plus a three pixel margin around it.
Three things follow from doing it that way, and they are the reason it is done that way.
- The tab is not a selectable chart object, so MetaTrader never puts selection marks on it.
- The tab has no drag points. It cannot be stretched, tilted or resized by catching it near an edge, so there is no misshapen state to recover from.
- While you hold the tab, horizontal chart scrolling is suspended, so the chart does not slide out from under the cursor while you drag. The indicator reads your existing setting before it changes it and writes that same value back when you let go. It is also written back if the release is missed, on the next click anywhere, on the next object drag, and when the indicator is removed.
Picking the tab up requires the button to go down while the pointer is already on it. Coming onto the tab with the button already held, part way through some other drag, does not hand that drag over.
If a tab would come to rest on top of the panel, it steps below the panel, and only then. When the two are clear of each other the tab does not move at all.
Tabs are placed in lanes. A lane is a row of screen height, and the lane number is an input. Two indicators that both draw an as-of tab are put in different lanes, so the tabs sit one above the other instead of covering each other. With one indicator on the chart the default lane leaves the tab exactly where it would otherwise be.
A tab can also be dragged up and down. Where you drop it is where it stays: the lane offset and the panel dodge are both skipped from then on, because both of those are guesses made before you had looked at the chart. A tab cannot be dropped off the edge, so it can always be picked up again. Moving a tab up or down changes nothing except where the tab is drawn. The height is not kept when the timeframe changes or the indicator is reloaded; it starts again from InpHandleYPct.
By default the vertical lines cannot be picked with the mouse. Clicking one does nothing, so a line cannot be caught by accident while you are drawing on the chart, and moving the axis by accident changes every line the tool draws. The tab and the panel are how the axis is moved. Setting InpAsOfLineSelectable to true restores the ordinary way of moving a chart object: select the line, then drag it. MetaTrader draws small selection marks on a selected object, and InpAsOfKeepSelected keeps the lines selected so that first click is not needed. That input only has an effect while the lines can be selected at all. Marks never appear on the tabs.
The two vertical lines can be drawn in four ways, and the setting exists because we do not know which one you will prefer on your own chart. THIN is the default: each line is drawn as a one pixel line mixed into the chart background, so they are still there but stop competing with the candles. FULL is the lines as described above, the way this indicator drew them before the modes were added. BOTH keeps those faint lines and adds three short tick marks to each one, at the top edge, the middle and the bottom edge of the window. TICKS mixes the lines all the way into the background and leaves only the marks. MetaTrader has no transparency for a vertical line, so faint is made by mixing the line colour into the chart background colour; how far it is mixed is an input. The marks are not faded, so each one keeps the colour of its own line and the axis is still told apart from the range. There are always exactly three marks per line, whatever the chart holds: the count is fixed in the code and does not grow with the number of bars. In every mode, TICKS included, both line objects are still there carrying their times, so a mode is a change in what you see and not in how the axis is dragged or what is drawn from it.
Moving the axis carries the range line with it, so the number of bars between the two lines does not change. The axis answers when you are looking from; the range answers how far back you are looking, and it is moved on its own when you want to change that. Where the range line reaches the oldest bar on the chart it stops there, the axis keeps moving, and the count on the panel follows the distance that is actually left, so the change is visible rather than silent. Moving the axis back to the right opens the range out again to the number you asked for.
This is the same mechanism as the truncation check described above, exposed as a control. It exists to make the tool inspectable, not to prove anything about the market.
The panel
A small flat panel sits in one corner of the chart. It is built from plain rectangles and labels rather than from platform buttons, so it has no bevels and no 3D styling.
It has three rows:
- The as-of time and a marker reading LIVE or PAST.
- The axis row: a button back to live.
- The range row: the range currently in effect, and a button that resets the range to the value in the inputs.
The steps of minus fifty, minus ten, plus ten and plus fifty bars are off by default. With them off the two rows fold into one and the panel is two rows tall rather than three. Switching InpShowAsOfSteps on brings the eight keys back and the panel returns to its earlier shape. The key that resets the range stays either way: with the steps off, the range is changed by dragging the range line, which lands on values such as 214, and that key is the way back to a round number. Its caption is the value in the inputs, so it doubles as a readout of the configured range.
The time on the panel and the time on the axis handle are always the same bar, and it is the bar the tool actually computed from. While the axis is live that is the last closed bar, not the bar still forming, even though the vertical line itself is parked on the forming bar. Anything that speaks in numbers names the bar the numbers came from.
The panel measures its own text before it lays itself out, and widens if a value does not fit, so nothing overlaps at any display scaling. It can sit in any of the four corners, and it keeps the margin you set from whichever corner you choose. The corner, the margins and its two fonts are inputs. It can be switched off entirely, in which case the indicator is always live and draws no control objects at all.
What it writes to the log
Two lines when it starts. The first says that the statistical edge of these lines has not been verified. The second is a one-line summary of the settings actually in force: symbol, timeframes, fractal width, window, anchor mode, hull end, line count, set quotas, anchor price, freeze, whether the controls are on, and which of the four line modes is in use, followed by a one-clause hint that THIN and BOTH make the two vertical lines less intrusive.
That is all, by default. The long-form explanation of each setting, several paragraphs of it, is still there but is printed only when InpDebugEvents is turned on. Nothing was deleted; it was moved behind a switch, because a log that fills up with an indicator explaining itself is a log you stop reading. The first line is not behind the switch and never will be.
Line states, and how to read the colours
Each line carries a short label, for example D OUT T2 (down leg, outer line, touched twice) or D MID BRK T0 (down leg, middle line, broken).
Touches and breaks are judged on closes against an ATR-scaled tolerance, so a wick that pierces a line without a close beyond it is not counted. Both thresholds are inputs. They are working defaults, not calibrated values.
Four things are encoded, and each one has its own channel, so no channel carries two meanings:
- Which of the three lines it is: colour. Outer is a muted yellow, middle a muted red, inner a muted blue.
- Whether the line has been broken: line style. Solid means intact, dashed means broken. Broken lines get no colour of their own.
- Whether the set is the newest one: brightness. Older sets are drawn in a darker version of the same three colours.
- Which timeframe it came from: thickness. Higher timeframes are drawn thicker.
All six colours are inputs, and the fading of older sets can be switched off.
Timeframes
Up to three timeframes can be drawn on one chart. By default only the chart timeframe is used. Higher timeframe bars are used only after they have closed, and closure is judged against the chart's own last closed bar rather than against the terminal clock, so the behaviour is the same in the strategy tester as it is live. Higher timeframe lines are drawn thicker and their labels carry the timeframe.
The scan window is counted in bars of the timeframe being processed, not converted. On H4, 120 bars is 20 days. Confirmation lag is likewise counted in bars of that timeframe.
Inputs
There are 62 inputs, in seven groups in the properties dialog. They are listed below in eight short lists rather than seven, because the panel settings are easier to read on their own; in the dialog they sit inside the as-of group. Every default listed here is the shipping default.
Drawing rule:
- InpDirMode: draw down legs, up legs, or decide automatically from which extreme comes first.
- InpFractalN: half-width of the pivot in bars. 2 means a 5-bar fractal.
- InpScanBars: length of the scan window, in bars of the timeframe being processed. Default 120.
- InpAnchorMode: where the interval starts. Fixed window edge, or the end point of the previous leg.
- InpMaxSpanBars: upper limit on interval length in previous-leg mode, before falling back to a fixed window.
- InpLineCount: how many of the three lines to draw, from 1 to 3.
- InpRequireTurnPivot: wait for an opposite confirmed pivot after B before drawing.
- InpHullEnd: right edge of the interval used to build the hull. Up to the current closed bar, or up to B.
- InpFreezeOnBreak: once a leg's outer line is broken by a close, stop redrawing that leg.
- InpAnchorPrice: wicks (highs and lows) or bodies (opens and closes).
As-of axis and range:
- InpShowAsOfControls: show the two vertical lines, their handles and the panel. Off means always live.
- InpAsOfLineColor, InpFromLineColor: colours of the axis line and of the range line.
- InpAsOfLineWidth: width of the two vertical lines in pixels. Thicker is easier to grab.
- InpAsOfLineFront: draw the vertical lines in front of the candles rather than behind them.
- InpAsOfLineMode: how the two vertical lines are drawn. THIN is the default: one thin line each, mixed into the chart background. FULL is the lines as they were drawn before the modes were added. BOTH is that faint line plus three tick marks. TICKS is the marks only. The axis and the range work the same way in all four.
- InpAsOfLineFadePct: how far THIN and BOTH mix a line into the chart background, from 0 to 100. 65 by default. Values outside that range are brought back inside it and the log says so.
- InpAsOfTickPx: the length of one tick mark in pixels, used by BOTH and TICKS. 18 by default, and brought inside 2 to 400. There are always three marks per line, whatever this is set to.
- InpAsOfLineSelectable: allow the vertical lines themselves to be picked and dragged. Off by default, so a line cannot be caught by accident. The tabs and the panel still move the axis.
- InpAsOfKeepSelected: keep the two vertical lines selected. Off by default, and it only has an effect while InpAsOfLineSelectable is on, because marks are only drawn on selectable objects.
- InpHandleLane: which lane the tabs are placed in, counting from the top. Give a second indicator that draws its own as-of tab a different lane and the tabs stop covering each other. Dragging a tab up or down overrides both the lane and the panel dodge until the chart is reloaded.
- InpShowAsOfSteps: show the minus fifty, minus ten, plus ten and plus fifty keys on the panel. Off by default, which folds the panel into two rows. NOW and the range reset key are always shown.
- InpShowAsOfHandles, InpHandleFontSize, InpHandleYPct: show the handles, their text size, and how high up the chart they sit. The font size also sets the smallest width a tab may have, so it is the setting to raise if you want a larger area to grab.
- InpAsOfHandleFill: draw the filled tab. Off leaves the readout as plain text, and the text is then not a grab target, so the axis is moved by the lines and the panel keys instead.
- InpDebugEvents: print the long-form setting description and every chart event to the log. Off by default. This is a diagnostic switch, for sending us something to read when a chart looks wrong.
Panel:
- InpUiCorner: which corner the panel sits in.
- InpUiX, InpUiY: panel margins from that corner, in pixels.
- InpUiSafeBottom: space always kept free at the bottom edge, for the time scale.
- InpHudFontStamp, InpHudFontNum: the label font and the number font of the panel.
- InpKeyAffordance: tell the parts of the panel you can press apart from the parts you only read. RAISED is the default: only the keys keep a face and a border, and the top of a key is lifted one step lighter, so a reading such as LIVE or PAST is plain text. MARK marks the keys with the border alone. OFF is the older panel, where a key and a reading looked the same.
Timeframes:
- InpTF1, InpTFEnable2, InpTF2, InpTFEnable3, InpTF3: up to three timeframes on one chart.
- InpTFWidthStep: extra line width in pixels per step up in timeframe. Zero keeps widths equal.
- InpMaxSetsHTF: sets kept per higher timeframe in the current direction.
- InpMaxSetsOppHTF: sets kept per higher timeframe in the opposite direction. Zero keeps none.
How much stays on screen:
- InpReplayBars: how many bars back the sequential replay runs, so that older sets are shown too.
- InpMaxSets: sets kept on the chart timeframe in the current direction.
- InpMaxSetsOpp: sets kept on the chart timeframe in the opposite direction. Zero keeps none.
- InpMaxHistoryBars: upper limit on bars scanned. Zero means all of them.
State thresholds:
- InpTouchTolATR: distance in ATR within which a close counts as touching the line.
- InpBreakTolATR: distance in ATR beyond the line at which a close counts as a break.
- InpATRPeriod: ATR period used by the touch and break tests.
Line appearance:
- InpOuterColor, InpMiddleColor, InpInnerColor: the three lines of the newest set.
- InpOuterColorOld, InpMiddleColorOld, InpInnerColorOld: the same three lines for older sets.
- InpLineWidth: line width in pixels, before the timeframe step is added.
- InpLineStyle: style for lines that have not been broken.
- InpBrokenStyle: style for broken lines. Must differ from InpLineStyle.
- InpFadeOldSets: draw older sets in the darker colours.
Labels:
- InpShowLabels: show the state label at the right end of each line.
- InpShowAB: mark the start A and the end B of the interval.
- InpLabelFontSize: font size of the state labels.
Every numeric input that has a range is examined at start-up, and the indicator refuses to run rather than draw something misleading. A single value outside its range is enough: start-up stops and the log names the input, its range and the value you gave. A contradictory pair does the same, for example a break tolerance smaller than the touch tolerance, or a broken line style identical to the normal line style. InpAsOfLineFadePct and InpAsOfTickPx are the only two inputs that behave differently, and they are the two described above: a value outside their range is brought inside it and the log says so, rather than stopping start-up.
What you install
One compiled indicator file. There is nothing else to copy, no include files to place by hand, no library to install, no DLL call, and no external connection of any kind. Drop it on a chart and it runs.
Limitations
- No entry or exit signals, no arrows, no alerts, no trading. It draws lines and labels them.
- No claim of statistical edge. Whether these lines have predictive value has not been tested by us.
- Lines appear late, by design. A pivot needs its right-hand bars to close, and by default the tool waits for an opposite pivot after B. Until then nothing is drawn. This lateness is the price of not repainting, and it cannot be removed without looking ahead.
- Closes only. A wick touch or a wick break is not counted.
- Ties are not handled. If the interval high or low is equal across bars, the pivot requirement is not met and no lines are drawn at that moment. This is the safe direction, not a workaround.
- Higher timeframes need history. If your broker does not supply enough history for a selected timeframe, nothing is drawn for that timeframe and a message is written to the log.
- The first draw grows with the length of the chart, and it has not been timed on a real terminal. On that first pass the indicator reads every bar the chart holds. InpMaxHistoryBars and InpReplayBars cap the detection and the replay; they do not cap that first read.
- Work done after the first draw. A tick that does not open a new bar draws nothing at all. When a bar does open, the work is bounded by InpMaxHistoryBars rather than by the length of the chart, and the same bound applies while you drag the axis across bars. None of this has been timed on a real terminal; it is a count of the work asked for, not a measurement of how long it takes, and it says nothing about the first draw above. The higher timeframe paths are not bounded this way and still read their whole series.
- The four ways of drawing the vertical lines are offered because we do not know which one will suit your chart, and we have not decided one for you. Faint is made by mixing the line colour into the chart background colour, so how faint a given setting looks depends on your background.
- Memory grows with the number of bars on the chart, and it is not capped by any setting. The indicator keeps its own copy of the chart series so that dragging the axis never has to re-read it: eight arrays of eight bytes per bar plus two of one byte, which is 66 bytes for every bar the terminal hands it. That is arithmetic from the source, not a measurement: on a chart with three million bars it works out at roughly a quarter of a gigabyte, and we have not observed the figure on a running terminal. If that matters to you, lower "Max bars in chart" in the terminal settings; the indicator's own history settings do not change it.
- Defaults were chosen for XAUUSD. The indicator runs on other symbols, but the defaults were not adjusted for them and a note is written to the log at start-up.
- The thresholds and the window length are working defaults. They are not calibrated values, and this description does not pretend otherwise.
- The panel uses Bahnschrift and Consolas by default. MetaTrader substitutes a different font silently when one is not installed and gives no way to ask which font it actually used, so on a machine without those fonts the panel will still work but will not look as intended. Both fonts are inputs.
- The panel needs room. On a chart window narrower than about 250 pixels, or shorter than about 100 pixels, it cannot fit and will be clipped rather than hidden, because a hidden panel cannot be clicked.
- The axis line, the range line and the handles are chart objects owned by the indicator. Deleting them by hand does not disable the feature; they are recreated. Use the input to switch the controls off instead.
- The two vertical lines are ordinary chart objects. By default they cannot be picked at all, and with InpAsOfLineSelectable on they are left unselected, so MetaTrader draws no selection marks on them, and they are moved the ordinary way: select, then drag. Whether selecting takes one click or two is a terminal setting, not something an indicator can read or change. InpAsOfKeepSelected keeps them selected instead, which saves that click and puts the marks on screen. Either way the marks never appear on the handles.
- Dragging a handle depends on the terminal delivering mouse move events to the indicator. The indicator asks the chart for them at start-up and stops asking when it is removed. If another indicator on the same chart turns that chart setting off, the handles stop responding, and the lines and the panel keys remain as ways to move the axis.
- Suspending chart scrolling while a handle is held is a chart-wide setting, so loading two indicators that both do it means whichever one restores last decides the value that is left.
- The handle is drawn as a filled screen-space panel, in the same way the indicator's own panel is drawn. How much of a candle a handle covers when it happens to sit over price is not something we have measured on a live chart, and we make no claim about it.
- With InpAsOfHandleFill off there is no tab, and the readout becomes plain text that is not a grab target. The axis is then moved with the panel keys, or with the vertical lines after switching InpAsOfLineSelectable on.
- The verification harness reimplements the drawing logic outside the terminal, and is a port of that logic rather than an independent design. It checks the logic, not the compiled file.
Who this is probably not for
- Anyone looking for entry signals, arrows, alerts or an automated system.
- Anyone who wants a chart where the set of lines never changes at all, rather than a chart where individual lines never move.
- Anyone who needs evidence that the lines have an edge before buying. We do not have that evidence and we will not invent it.
Support
Please use the product comments section or the mql5.com message system. Questions about what a specific input does, or about a chart where the output looks wrong, are welcome. Please include the symbol, the timeframe, and your input settings.
What it does. It draws trend lines from one fixed geometric rule, and it never moves a line after that line has been drawn.
What it does not do. It does not tell you when to buy or when to sell, and it does not claim that these lines have any statistical edge. We have not measured one, so we do not say that one exists.
What has been checked. The no-repaint behaviour is not just a sentence in this description. It is checked by an automated verification harness, and the harness reports zero mismatches. The central check is that placing the as-of axis at a past time T produces exactly the same picture as physically cutting the data at T.
Why this description has no numbers in it
This description contains no win rate, no profit figures and no backtest results. That is not a formality. We have not tested whether these lines have any predictive value, so there is nothing to report. What is offered here is a drawing rule that is written down in full, and a machine check that the tool follows that rule.
The drawing rule
Pivots are 5-bar fractals: the middle bar is higher than the two bars on each side, or lower than the two bars on each side. The half-width is an input, so 5 bars is the default and not a fixed constant.
Inside a scan window the indicator takes the high of the interval and the low of the interval. If the high comes first, the leg is a down leg from that high A to that low B. If the low comes first, the leg is an up leg.
For a down leg, the three lines are the first three edges of the upper convex hull walked from A. In plain words: start horizontal at A, rotate downward, and draw to the first high you hit. From that point, rotate again. Then once more. That is the outer, middle and inner line. For an up leg the same procedure runs on the lower hull, mirrored.
Three lines per set, and no more. If you want finer structure, move to a lower timeframe. The outer line always has a smaller slope than the middle line, and the middle line a smaller slope than the inner line. That ordering is a property of the hull, not a setting.
Anchors can be taken from wicks or from bodies. The default is wicks, that is highs and lows. Setting the anchor price to bodies uses opens and closes instead, for pivots, for the hull and for the state tests alike. Which of the two is the correct reading of the method is not something we have settled, so both are offered and neither is presented as the right one.
What no repaint means here, and how it is checked
A line is anchored to two bars at the moment the set is created, and those two anchors are frozen. The indicator never rewrites them. New market highs and lows add new sets; they do not edit old ones.
Three things make this possible. The forming bar is never used. A pivot does not exist until the bars to the right of it have closed. And by default the indicator waits for an opposite confirmed pivot after B before it draws anything at all.
The verification harness runs the same drawing logic outside the terminal over synthetic series and random walks, and checks, at every bar of every series:
- Truncation invariance: the result from an array physically cut to t bars equals the result from the full array reproduced at t. Zero mismatches.
- Monotone addition: sets already recorded are never rewritten, only appended to. Zero violations.
- Edge invariance: the three edges of a recorded set never change afterwards. Zero mismatches.
- As-of invariance: placing the axis at a past time T equals cutting the data at T. Zero mismatches, across both hull modes, both anchor modes, both anchor prices, and with the freeze option on and off.
Please read that claim narrowly, because we state it narrowly. The harness is a port of the same drawing logic into another language. It is not a second, independently designed implementation, and we do not present it as one. What makes the check worth running is the kind of thing it tests: these are mathematical properties of the output, such as invariance under truncation, that logic which looks ahead cannot satisfy. A port of a rule that peeked at future bars would fail these checks, not pass them by family resemblance.
It is a check of the drawing logic, run outside MetaTrader. It is not a statement about market behaviour, and it is not a statement that the lines are useful.
One honest consequence. Lines do not move, but that is not the same as the screen never changing. When price makes a new high or low, a new set is added, and old sets drop off the chart once the display limits are reached. The old lines were not moved; they were retired.
The as-of axis, and the two handles
A vertical line on the chart is the as-of axis. Drag it to the left and the whole chart is redrawn as it stood at that time: the same sets, the same states, the same labels, using nothing that happened afterwards. A second vertical line sets the left edge of the scan range.
Each of the two lines carries a handle, and the handle reads out the value that line controls:
LINES :: AXIS 08.11 21:45 LINES :: RANGE 214
The word in front is a short tag for the indicator the tab belongs to. If a second indicator on the same chart also draws an as-of tab, the tag is how you tell the two apart at a glance.
The handle is one small tab, not a cluster of parts. It is laid out in screen pixels rather than on the price grid, so it keeps the same size and the same shape at every zoom level. It is filled with the same colour as the panel, and the readout is drawn on that fill. A two pixel strip down its left edge carries the colour of the line the tab belongs to, and that strip is how the two tabs are told apart at a glance.
Press the left mouse button anywhere on the tab and drag. The line follows at once. There is no step before that one: you do not select the tab first, you do not double click it, and you do not have to find a smaller target inside it. The indicator does its own hit testing against the rectangle it drew, so the area that responds is the tab you can see, plus a three pixel margin around it.
Three things follow from doing it that way, and they are the reason it is done that way.
- The tab is not a selectable chart object, so MetaTrader never puts selection marks on it.
- The tab has no drag points. It cannot be stretched, tilted or resized by catching it near an edge, so there is no misshapen state to recover from.
- While you hold the tab, horizontal chart scrolling is suspended, so the chart does not slide out from under the cursor while you drag. The indicator reads your existing setting before it changes it and writes that same value back when you let go. It is also written back if the release is missed, on the next click anywhere, on the next object drag, and when the indicator is removed.
Picking the tab up requires the button to go down while the pointer is already on it. Coming onto the tab with the button already held, part way through some other drag, does not hand that drag over.
If a tab would come to rest on top of the panel, it steps below the panel, and only then. When the two are clear of each other the tab does not move at all.
Tabs are placed in lanes. A lane is a row of screen height, and the lane number is an input. Two indicators that both draw an as-of tab are put in different lanes, so the tabs sit one above the other instead of covering each other. With one indicator on the chart the default lane leaves the tab exactly where it would otherwise be.
A tab can also be dragged up and down. Where you drop it is where it stays: the lane offset and the panel dodge are both skipped from then on, because both of those are guesses made before you had looked at the chart. A tab cannot be dropped off the edge, so it can always be picked up again. Moving a tab up or down changes nothing except where the tab is drawn. The height is not kept when the timeframe changes or the indicator is reloaded; it starts again from InpHandleYPct.
By default the vertical lines cannot be picked with the mouse. Clicking one does nothing, so a line cannot be caught by accident while you are drawing on the chart, and moving the axis by accident changes every line the tool draws. The tab and the panel are how the axis is moved. Setting InpAsOfLineSelectable to true restores the ordinary way of moving a chart object: select the line, then drag it. MetaTrader draws small selection marks on a selected object, and InpAsOfKeepSelected keeps the lines selected so that first click is not needed. That input only has an effect while the lines can be selected at all. Marks never appear on the tabs.
The two vertical lines can be drawn in four ways, and the setting exists because we do not know which one you will prefer on your own chart. THIN is the default: each line is drawn as a one pixel line mixed into the chart background, so they are still there but stop competing with the candles. FULL is the lines as described above, the way this indicator drew them before the modes were added. BOTH keeps those faint lines and adds three short tick marks to each one, at the top edge, the middle and the bottom edge of the window. TICKS mixes the lines all the way into the background and leaves only the marks. MetaTrader has no transparency for a vertical line, so faint is made by mixing the line colour into the chart background colour; how far it is mixed is an input. The marks are not faded, so each one keeps the colour of its own line and the axis is still told apart from the range. There are always exactly three marks per line, whatever the chart holds: the count is fixed in the code and does not grow with the number of bars. In every mode, TICKS included, both line objects are still there carrying their times, so a mode is a change in what you see and not in how the axis is dragged or what is drawn from it.
Moving the axis carries the range line with it, so the number of bars between the two lines does not change. The axis answers when you are looking from; the range answers how far back you are looking, and it is moved on its own when you want to change that. Where the range line reaches the oldest bar on the chart it stops there, the axis keeps moving, and the count on the panel follows the distance that is actually left, so the change is visible rather than silent. Moving the axis back to the right opens the range out again to the number you asked for.
This is the same mechanism as the truncation check described above, exposed as a control. It exists to make the tool inspectable, not to prove anything about the market.
The panel
A small flat panel sits in one corner of the chart. It is built from plain rectangles and labels rather than from platform buttons, so it has no bevels and no 3D styling.
It has three rows:
- The as-of time and a marker reading LIVE or PAST.
- The axis row: a button back to live.
- The range row: the range currently in effect, and a button that resets the range to the value in the inputs.
The steps of minus fifty, minus ten, plus ten and plus fifty bars are off by default. With them off the two rows fold into one and the panel is two rows tall rather than three. Switching InpShowAsOfSteps on brings the eight keys back and the panel returns to its earlier shape. The key that resets the range stays either way: with the steps off, the range is changed by dragging the range line, which lands on values such as 214, and that key is the way back to a round number. Its caption is the value in the inputs, so it doubles as a readout of the configured range.
The time on the panel and the time on the axis handle are always the same bar, and it is the bar the tool actually computed from. While the axis is live that is the last closed bar, not the bar still forming, even though the vertical line itself is parked on the forming bar. Anything that speaks in numbers names the bar the numbers came from.
The panel measures its own text before it lays itself out, and widens if a value does not fit, so nothing overlaps at any display scaling. It can sit in any of the four corners, and it keeps the margin you set from whichever corner you choose. The corner, the margins and its two fonts are inputs. It can be switched off entirely, in which case the indicator is always live and draws no control objects at all.
What it writes to the log
Two lines when it starts. The first says that the statistical edge of these lines has not been verified. The second is a one-line summary of the settings actually in force: symbol, timeframes, fractal width, window, anchor mode, hull end, line count, set quotas, anchor price, freeze, whether the controls are on, and which of the four line modes is in use, followed by a one-clause hint that THIN and BOTH make the two vertical lines less intrusive.
That is all, by default. The long-form explanation of each setting, several paragraphs of it, is still there but is printed only when InpDebugEvents is turned on. Nothing was deleted; it was moved behind a switch, because a log that fills up with an indicator explaining itself is a log you stop reading. The first line is not behind the switch and never will be.
Line states, and how to read the colours
Each line carries a short label, for example D OUT T2 (down leg, outer line, touched twice) or D MID BRK T0 (down leg, middle line, broken).
Touches and breaks are judged on closes against an ATR-scaled tolerance, so a wick that pierces a line without a close beyond it is not counted. Both thresholds are inputs. They are working defaults, not calibrated values.
Four things are encoded, and each one has its own channel, so no channel carries two meanings:
- Which of the three lines it is: colour. Outer is a muted yellow, middle a muted red, inner a muted blue.
- Whether the line has been broken: line style. Solid means intact, dashed means broken. Broken lines get no colour of their own.
- Whether the set is the newest one: brightness. Older sets are drawn in a darker version of the same three colours.
- Which timeframe it came from: thickness. Higher timeframes are drawn thicker.
All six colours are inputs, and the fading of older sets can be switched off.
Timeframes
Up to three timeframes can be drawn on one chart. By default only the chart timeframe is used. Higher timeframe bars are used only after they have closed, and closure is judged against the chart's own last closed bar rather than against the terminal clock, so the behaviour is the same in the strategy tester as it is live. Higher timeframe lines are drawn thicker and their labels carry the timeframe.
The scan window is counted in bars of the timeframe being processed, not converted. On H4, 120 bars is 20 days. Confirmation lag is likewise counted in bars of that timeframe.
Inputs
There are 62 inputs, in seven groups in the properties dialog. They are listed below in eight short lists rather than seven, because the panel settings are easier to read on their own; in the dialog they sit inside the as-of group. Every default listed here is the shipping default.
Drawing rule:
- InpDirMode: draw down legs, up legs, or decide automatically from which extreme comes first.
- InpFractalN: half-width of the pivot in bars. 2 means a 5-bar fractal.
- InpScanBars: length of the scan window, in bars of the timeframe being processed. Default 120.
- InpAnchorMode: where the interval starts. Fixed window edge, or the end point of the previous leg.
- InpMaxSpanBars: upper limit on interval length in previous-leg mode, before falling back to a fixed window.
- InpLineCount: how many of the three lines to draw, from 1 to 3.
- InpRequireTurnPivot: wait for an opposite confirmed pivot after B before drawing.
- InpHullEnd: right edge of the interval used to build the hull. Up to the current closed bar, or up to B.
- InpFreezeOnBreak: once a leg's outer line is broken by a close, stop redrawing that leg.
- InpAnchorPrice: wicks (highs and lows) or bodies (opens and closes).
As-of axis and range:
- InpShowAsOfControls: show the two vertical lines, their handles and the panel. Off means always live.
- InpAsOfLineColor, InpFromLineColor: colours of the axis line and of the range line.
- InpAsOfLineWidth: width of the two vertical lines in pixels. Thicker is easier to grab.
- InpAsOfLineFront: draw the vertical lines in front of the candles rather than behind them.
- InpAsOfLineMode: how the two vertical lines are drawn. THIN is the default: one thin line each, mixed into the chart background. FULL is the lines as they were drawn before the modes were added. BOTH is that faint line plus three tick marks. TICKS is the marks only. The axis and the range work the same way in all four.
- InpAsOfLineFadePct: how far THIN and BOTH mix a line into the chart background, from 0 to 100. 65 by default. Values outside that range are brought back inside it and the log says so.
- InpAsOfTickPx: the length of one tick mark in pixels, used by BOTH and TICKS. 18 by default, and brought inside 2 to 400. There are always three marks per line, whatever this is set to.
- InpAsOfLineSelectable: allow the vertical lines themselves to be picked and dragged. Off by default, so a line cannot be caught by accident. The tabs and the panel still move the axis.
- InpAsOfKeepSelected: keep the two vertical lines selected. Off by default, and it only has an effect while InpAsOfLineSelectable is on, because marks are only drawn on selectable objects.
- InpHandleLane: which lane the tabs are placed in, counting from the top. Give a second indicator that draws its own as-of tab a different lane and the tabs stop covering each other. Dragging a tab up or down overrides both the lane and the panel dodge until the chart is reloaded.
- InpShowAsOfSteps: show the minus fifty, minus ten, plus ten and plus fifty keys on the panel. Off by default, which folds the panel into two rows. NOW and the range reset key are always shown.
- InpShowAsOfHandles, InpHandleFontSize, InpHandleYPct: show the handles, their text size, and how high up the chart they sit. The font size also sets the smallest width a tab may have, so it is the setting to raise if you want a larger area to grab.
- InpAsOfHandleFill: draw the filled tab. Off leaves the readout as plain text, and the text is then not a grab target, so the axis is moved by the lines and the panel keys instead.
- InpDebugEvents: print the long-form setting description and every chart event to the log. Off by default. This is a diagnostic switch, for sending us something to read when a chart looks wrong.
Panel:
- InpUiCorner: which corner the panel sits in.
- InpUiX, InpUiY: panel margins from that corner, in pixels.
- InpUiSafeBottom: space always kept free at the bottom edge, for the time scale.
- InpHudFontStamp, InpHudFontNum: the label font and the number font of the panel.
- InpKeyAffordance: tell the parts of the panel you can press apart from the parts you only read. RAISED is the default: only the keys keep a face and a border, and the top of a key is lifted one step lighter, so a reading such as LIVE or PAST is plain text. MARK marks the keys with the border alone. OFF is the older panel, where a key and a reading looked the same.
Timeframes:
- InpTF1, InpTFEnable2, InpTF2, InpTFEnable3, InpTF3: up to three timeframes on one chart.
- InpTFWidthStep: extra line width in pixels per step up in timeframe. Zero keeps widths equal.
- InpMaxSetsHTF: sets kept per higher timeframe in the current direction.
- InpMaxSetsOppHTF: sets kept per higher timeframe in the opposite direction. Zero keeps none.
How much stays on screen:
- InpReplayBars: how many bars back the sequential replay runs, so that older sets are shown too.
- InpMaxSets: sets kept on the chart timeframe in the current direction.
- InpMaxSetsOpp: sets kept on the chart timeframe in the opposite direction. Zero keeps none.
- InpMaxHistoryBars: upper limit on bars scanned. Zero means all of them.
State thresholds:
- InpTouchTolATR: distance in ATR within which a close counts as touching the line.
- InpBreakTolATR: distance in ATR beyond the line at which a close counts as a break.
- InpATRPeriod: ATR period used by the touch and break tests.
Line appearance:
- InpOuterColor, InpMiddleColor, InpInnerColor: the three lines of the newest set.
- InpOuterColorOld, InpMiddleColorOld, InpInnerColorOld: the same three lines for older sets.
- InpLineWidth: line width in pixels, before the timeframe step is added.
- InpLineStyle: style for lines that have not been broken.
- InpBrokenStyle: style for broken lines. Must differ from InpLineStyle.
- InpFadeOldSets: draw older sets in the darker colours.
Labels:
- InpShowLabels: show the state label at the right end of each line.
- InpShowAB: mark the start A and the end B of the interval.
- InpLabelFontSize: font size of the state labels.
Every numeric input that has a range is examined at start-up, and the indicator refuses to run rather than draw something misleading. A single value outside its range is enough: start-up stops and the log names the input, its range and the value you gave. A contradictory pair does the same, for example a break tolerance smaller than the touch tolerance, or a broken line style identical to the normal line style. InpAsOfLineFadePct and InpAsOfTickPx are the only two inputs that behave differently, and they are the two described above: a value outside their range is brought inside it and the log says so, rather than stopping start-up.
What you install
One compiled indicator file. There is nothing else to copy, no include files to place by hand, no library to install, no DLL call, and no external connection of any kind. Drop it on a chart and it runs.
Limitations
- No entry or exit signals, no arrows, no alerts, no trading. It draws lines and labels them.
- No claim of statistical edge. Whether these lines have predictive value has not been tested by us.
- Lines appear late, by design. A pivot needs its right-hand bars to close, and by default the tool waits for an opposite pivot after B. Until then nothing is drawn. This lateness is the price of not repainting, and it cannot be removed without looking ahead.
- Closes only. A wick touch or a wick break is not counted.
- Ties are not handled. If the interval high or low is equal across bars, the pivot requirement is not met and no lines are drawn at that moment. This is the safe direction, not a workaround.
- Higher timeframes need history. If your broker does not supply enough history for a selected timeframe, nothing is drawn for that timeframe and a message is written to the log.
- The first draw grows with the length of the chart, and it has not been timed on a real terminal. On that first pass the indicator reads every bar the chart holds. InpMaxHistoryBars and InpReplayBars cap the detection and the replay; they do not cap that first read.
- Work done after the first draw. A tick that does not open a new bar draws nothing at all. When a bar does open, the work is bounded by InpMaxHistoryBars rather than by the length of the chart, and the same bound applies while you drag the axis across bars. None of this has been timed on a real terminal; it is a count of the work asked for, not a measurement of how long it takes, and it says nothing about the first draw above. The higher timeframe paths are not bounded this way and still read their whole series.
- The four ways of drawing the vertical lines are offered because we do not know which one will suit your chart, and we have not decided one for you. Faint is made by mixing the line colour into the chart background colour, so how faint a given setting looks depends on your background.
- Memory grows with the number of bars on the chart, and it is not capped by any setting. The indicator keeps its own copy of the chart series so that dragging the axis never has to re-read it: eight arrays of eight bytes per bar plus two of one byte, which is 66 bytes for every bar the terminal hands it. That is arithmetic from the source, not a measurement: on a chart with three million bars it works out at roughly a quarter of a gigabyte, and we have not observed the figure on a running terminal. If that matters to you, lower "Max bars in chart" in the terminal settings; the indicator's own history settings do not change it.
- Defaults were chosen for XAUUSD. The indicator runs on other symbols, but the defaults were not adjusted for them and a note is written to the log at start-up.
- The thresholds and the window length are working defaults. They are not calibrated values, and this description does not pretend otherwise.
- The panel uses Bahnschrift and Consolas by default. MetaTrader substitutes a different font silently when one is not installed and gives no way to ask which font it actually used, so on a machine without those fonts the panel will still work but will not look as intended. Both fonts are inputs.
- The panel needs room. On a chart window narrower than about 250 pixels, or shorter than about 100 pixels, it cannot fit and will be clipped rather than hidden, because a hidden panel cannot be clicked.
- The axis line, the range line and the handles are chart objects owned by the indicator. Deleting them by hand does not disable the feature; they are recreated. Use the input to switch the controls off instead.
- The two vertical lines are ordinary chart objects. By default they cannot be picked at all, and with InpAsOfLineSelectable on they are left unselected, so MetaTrader draws no selection marks on them, and they are moved the ordinary way: select, then drag. Whether selecting takes one click or two is a terminal setting, not something an indicator can read or change. InpAsOfKeepSelected keeps them selected instead, which saves that click and puts the marks on screen. Either way the marks never appear on the handles.
- Dragging a handle depends on the terminal delivering mouse move events to the indicator. The indicator asks the chart for them at start-up and stops asking when it is removed. If another indicator on the same chart turns that chart setting off, the handles stop responding, and the lines and the panel keys remain as ways to move the axis.
- Suspending chart scrolling while a handle is held is a chart-wide setting, so loading two indicators that both do it means whichever one restores last decides the value that is left.
- The handle is drawn as a filled screen-space panel, in the same way the indicator's own panel is drawn. How much of a candle a handle covers when it happens to sit over price is not something we have measured on a live chart, and we make no claim about it.
- With InpAsOfHandleFill off there is no tab, and the readout becomes plain text that is not a grab target. The axis is then moved with the panel keys, or with the vertical lines after switching InpAsOfLineSelectable on.
- The verification harness reimplements the drawing logic outside the terminal, and is a port of that logic rather than an independent design. It checks the logic, not the compiled file.
Who this is probably not for
- Anyone looking for entry signals, arrows, alerts or an automated system.
- Anyone who wants a chart where the set of lines never changes at all, rather than a chart where individual lines never move.
- Anyone who needs evidence that the lines have an edge before buying. We do not have that evidence and we will not invent it.
Support
Please use the product comments section or the mql5.com message system. Questions about what a specific input does, or about a chart where the output looks wrong, are welcome. Please include the symbol, the timeframe, and your input settings.
