Alım-satım robotlarını ücretsiz olarak nasıl indirebileceğinizi izleyin
Bizi Facebook üzerinde bulun!
Fan sayfamıza katılın
Kodu ilginç mi buldunuz?
Öyleyse bir link gönderin -
başkalarının da faydalanmasını sağlayın
Kodu beğendiniz mi? MetaTrader 5 terminalinde deneyin
Göstergeler

HTF EMA No Lookahead - MetaTrader 5 için gösterge

Görüntülemeler:
128
Yayınlandı:
MQL5 Freelance Bu koda dayalı bir robota veya göstergeye mi ihtiyacınız var? Freelance üzerinden sipariş edin Freelance'e git

A common way to show a higher-timeframe moving average on a lower-timeframe chart is to take the value of the higher-timeframe bar that contains the current bar. On history this looks fine, but it is a hidden lookahead: on an H1 chart at 10:00, the H4 bar that started at 08:00 is not closed yet, and its EMA value is only known at 12:00. An indicator or an Expert Advisor that uses it in the past sees information from the future, and the backtest looks better than live trading.

This indicator draws the higher-timeframe EMA using only data that was available at that moment. For every chart bar it takes the last higher-timeframe bar that closed strictly before the chart bar ends. The result is a step line that never repaints: what you see on history is exactly what you would have seen live.

H4 EMA 50 and 200 on an XAUUSD H1 chart

Input parameters

  • Higher timeframe (default H4). If it is not higher than the chart timeframe, a normal EMA of the chart is drawn.
  • Fast EMA period (default 50, 0 = off).
  • Slow EMA period (default 200, 0 = off).
  • Applied price (default Close).

Buffers for Expert Advisors

  • 0 = fast EMA
  • 1 = slow EMA
  • 2 = trend: +1 fast above slow, -1 fast below slow, 0 = no data
int h = iCustom(_Symbol, PERIOD_H1, "HTF_EMA_NoLookahead", PERIOD_H4, 50, 200, PRICE_CLOSE);
double trend[1];
//--- bar 1 = last closed bar
if(CopyBuffer(h, 2, 1, 1, trend) == 1 && trend[0] > 0)
  {
   //--- H4 trend is up
  }

How it was checked

On 2000 bars of XAUUSD H1 every value was compared with an independent calculation (iBarShift of the last second of the H1 bar, then the previous H4 bar). There were no differences. The indicator loads higher-timeframe history in the background and redraws itself when it arrives, also at the weekend when there are no ticks.

Round Number Levels Session Grid Round Number Levels Session Grid

Round number levels for Gold (XAUUSD) and any symbol on MT5. Draws major and minor round levels around price plus Asia, London and New York session open lines, with an optional alert when a candle closes across a major level. Open source code.

Multi Timeframe Trend Dashboard Multi Timeframe Trend Dashboard

Multi timeframe trend dashboard for Gold (XAUUSD) and any symbol on MT5. Shows up, down or flat for up to 6 timeframes from a fast and slow EMA on the last closed bar, with the distance in points and an alert when all line up. Open source code.

Risk Lot From Stop Line Risk Lot From Stop Line

Drag a stop line on the chart and see the volume for a given risk, the real risk after rounding, and a warning when even the minimum volume risks too much.

MACD Signals MACD Signals

Indicator edition for new platform.