IINWMARROWS_003

Download script
Author: Copyright � 2006, MetaQuotes Software Corp.
IINWMARROWS_003

This tool is designed as a visual trend-following indicator for the MetaTrader trading platform. Its primary purpose is to identify specific moments when momentum shifts in the market by detecting "crosses" between two different moving average lines.

Core Logic and Methodology

The script functions by calculating two distinct types of moving averages: a Faster moving average and a Slower moving average. By comparing these two lines, the tool attempts to spot transitions from one market state to another.

To ensure accuracy, the logic focuses on three specific criteria for every candle on the chart:

  1. The Current Position: It checks if the Faster moving average is currently above or below the Slower moving average.
  2. The Previous Position: It looks back at the preceding candle to see where the lines were located before the current movement.
  3. The Subsequent Movement: It analyzes the price action to confirm that a definitive "crossing" has occurred, rather than the lines simply moving closer together.

Dynamic Positioning

One of the unique features of this script is how it places its visual signals on your chart. Instead of placing icons at a fixed distance from the candles, the tool calculates the Average Range of the last 10 candles (measuring the volatility between the highs and lows).

It then uses this calculation to place the signal markers:

  • Bullish Signals: When the Faster average crosses above the Slower average, a signal is placed slightly below the candle's low.
  • Bearish Signals: When the Faster average crosses below the Slower average, a signal is placed slightly above the candle's high.

By basing the marker distance on the actual volatility of the market, the tool ensures that the signals remain clearly visible and do not overlap with price action during periods of high volatility.

Summary of User Experience

For the trader, this script automates the tedious task of watching two moving average lines constantly. It filters out the noise and places clear visual markers (arrows) on the chart only when a confirmed trend shift is detected, providing a simplified way to identify potential entry or exit points based on momentum changes.

Indicators Used
Moving average indicator
Miscellaneous
Implements a curve of type %1
13 Views
0 Downloads
0 Favorites
IINWMARROWS_003
//+------------------------------------------------------------------+
//|                                                  IINWMARROWS.mq4 |
//|                                           Based on EMA_CROSS.mq4 |
//|                      Copyright © 2006, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//|                           Last little modified by Iin Zulkarnain |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2006, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"
//----
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 White
#property indicator_color2 Red
#property indicator_width1 2
#property indicator_width2 2
//----
double CrossUp[];
double CrossDown[];
extern int FasterMode=3; //0=sma, 1=ema, 2=smma, 3=lwma
extern int FasterMA=  3;
extern int SlowerMode=3; //0=sma, 1=ema, 2=smma, 3=lwma
extern int SlowerMA=  3;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexStyle(0, DRAW_ARROW, EMPTY);
   SetIndexArrow(0, 233);
   SetIndexBuffer(0, CrossUp);
   SetIndexStyle(1, DRAW_ARROW, EMPTY);
   SetIndexArrow(1, 234);
   SetIndexBuffer(1, CrossDown);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//---- 
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
  int start() 
  {
   int limit, i, counter;
   double fasterMAnow, slowerMAnow, fasterMAprevious, slowerMAprevious, fasterMAafter, slowerMAafter;
   double Range, AvgRange;
   int counted_bars=IndicatorCounted();
//---- check for possible errors
   if(counted_bars<0) return(-1);
//---- last counted bar will be recounted
   if(counted_bars>0) counted_bars--;
//----
   limit=Bars-counted_bars;
     for(i=0; i<=limit; i++) 
     {
      counter=i;
      Range=0;
      AvgRange=0;
      for(counter=i ;counter<=i+9;counter++)
        {
         AvgRange=AvgRange+MathAbs(High[counter]-Low[counter]);
        }
      Range=AvgRange/10;
      fasterMAnow=iMA(NULL, 0, FasterMA, 0, FasterMode, PRICE_CLOSE, i);
      fasterMAprevious=iMA(NULL, 0, FasterMA, 0, FasterMode, PRICE_CLOSE, i+1);
      fasterMAafter=iMA(NULL, 0, FasterMA, 0, FasterMode, PRICE_CLOSE, i-1);
//----
      slowerMAnow=iMA(NULL, 0, SlowerMA, 0, SlowerMode, PRICE_OPEN, i);
      slowerMAprevious=iMA(NULL, 0, SlowerMA, 0, SlowerMode, PRICE_OPEN, i+1);
      slowerMAafter=iMA(NULL, 0, SlowerMA, 0, SlowerMode, PRICE_OPEN, i-1);
        if ((fasterMAnow > slowerMAnow) && (fasterMAprevious < slowerMAprevious) && (fasterMAafter > slowerMAafter)) 
        {
         CrossUp[i]=Low[i] - Range*0.5;
        }
        else if ((fasterMAnow < slowerMAnow) && (fasterMAprevious > slowerMAprevious) && (fasterMAafter < slowerMAafter)) 
        {
            CrossDown[i]=High[i] + Range*0.5;
        }
     }
   return(0);
  }
//+------------------------------------------------------------------+

Comments