test_5typ_up_v1

Download script
Author: Ron T
test_5typ_up_v1

This script is designed as a custom technical indicator for the MetaTrader platform. Its primary purpose is to analyze price momentum and identify specific directional trends by tracking the relationship between consecutive price candles over a short period of time.

Core Logic and Data Analysis

The tool operates by calculating a "Typical Price" for each candle, which is the average of the high, low, and closing prices. It then looks back at the most recent six periods of data to identify specific mathematical patterns:

  • Trend Detection: The script monitors whether prices are moving consistently in one direction over a six-period sequence. It specifically looks for a "run-up" (where each consecutive price is higher than the last) or a "run-down" (where each consecutive price is lower than the last).
  • Volatility Filtering: In addition to the directional trend, the script calculates the total change in price over a three-period window. It compares this change against a user-defined threshold (the "Gap Size"). This ensures that the movement isn't just a minor fluctuation but represents a significant enough price jump to be considered noteworthy.

Visual Output on the Chart

The indicator provides real-time visual feedback by placing symbols on your trading chart:

  • Trend Lines: It plots a continuous line representing the Typical Price, allowing you to see the smoothed flow of the market.
  • Directional Signals:
    • When the script detects a significant six-period run-up combined with the required price gap, it triggers a specific visual marker (a white arrow) to indicate potential upward momentum.
    • When the script detects a significant six-period run-down combined with the required price gap, it triggers a different visual marker (a red arrow) to indicate potential downward momentum.
  • Gap Identification: The script also places small dots on the chart to highlight moments where the three-period price gap requirement has been met, regardless of the direction.

Summary for Traders

Essentially, this tool filters out "market noise" by requiring both a consistent directional move (over 6 bars) and a minimum amount of movement (the Gap Size) before displaying a signal. It helps traders visually identify sustained momentum shifts while ignoring insignificant price wiggles.

Miscellaneous
Implements a curve of type %1
9 Views
0 Downloads
0 Favorites
test_5typ_up_v1
//+------------------------------------------------------------------+
//| test.mq4                                                         |
//+------------------------------------------------------------------+
#property copyright "Ron T"
#property link      "http://www.lightpatch.com"

#property indicator_chart_window
#property indicator_buffers 4
#property indicator_color1 Red
#property indicator_color2 White
#property indicator_color3 DeepSkyBlue
#property indicator_color4 White

//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
double ExtMapBuffer3[];
double ExtMapBuffer4[];

// User Input
extern double Gap_Size=0.0030;


//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//|------------------------------------------------------------------|

int init()
  {

   SetIndexStyle(0,DRAW_ARROW);
   SetIndexBuffer(0, ExtMapBuffer1);
   SetIndexArrow(0,234); //down red
   
   SetIndexStyle(1,DRAW_ARROW);
   SetIndexBuffer(1, ExtMapBuffer2);
   SetIndexArrow(1,233); //up white

   SetIndexStyle(2,DRAW_LINE);
   SetIndexBuffer(2, ExtMapBuffer3);
   //SetIndexArrow(2,224);

   SetIndexStyle(3,DRAW_ARROW);
   SetIndexBuffer(3, ExtMapBuffer4);
   SetIndexArrow(3,168); //dot

   return(0);
  }


//+------------------------------------------------------------------+
//| Custor indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
   int i;
   
   for( i=0; i<Bars; i++ ) ExtMapBuffer1[i]=0;
   for( i=0; i<Bars; i++ ) ExtMapBuffer2[i]=0;
   for( i=0; i<Bars; i++ ) ExtMapBuffer3[i]=0;
   for( i=0; i<Bars; i++ ) ExtMapBuffer4[i]=0;

   return(0);
  }


//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   double oTYP0=0, oTYP1=0, oTYP2=0, oTYP3=0, oTYP4=0, oTYP5=0;

   int pos=Bars;
      
   while(pos>=0)
     {
      // six-period typical
      oTYP0=(High[pos+0]+Low[pos+0]+Close[pos+0])/3;
      oTYP1=(High[pos+1]+Low[pos+1]+Close[pos+1])/3;
      oTYP2=(High[pos+2]+Low[pos+2]+Close[pos+2])/3;
      oTYP3=(High[pos+3]+Low[pos+3]+Close[pos+3])/3;
      oTYP4=(High[pos+4]+Low[pos+4]+Close[pos+4])/3;
      oTYP5=(High[pos+5]+Low[pos+5]+Close[pos+5])/3;

      ExtMapBuffer3[pos]=oTYP0;

      // +++++++++++++++++++++ LONG

      //three-period ten-pip gap
      if ( (oTYP3-oTYP2)+(oTYP2-oTYP1)+(oTYP1-oTYP0) >= Gap_Size )
        {
         ExtMapBuffer4[pos]=oTYP0;
        }
           

      // six-period run-up
      if(oTYP5 > oTYP4 && oTYP4 > oTYP3 && oTYP3 > oTYP2 && oTYP2 > oTYP1 && oTYP1 > oTYP0)
        {
         ExtMapBuffer1[pos]=oTYP0+0.0015;  //up white
         ExtMapBuffer2[pos]=0;
         
         //ExtMapBuffer4[pos+5]=oTYP5;
         //ExtMapBuffer4[pos+4]=oTYP4;
         //ExtMapBuffer4[pos+3]=oTYP3;
         //ExtMapBuffer4[pos+2]=oTYP2;
         //ExtMapBuffer4[pos+1]=oTYP1;
         //ExtMapBuffer4[pos+0]=oTYP0;
        }

      // +++++++++++++++++++++ SHORT
      //three-period ten-pip gap
      if ( (oTYP3-oTYP2)+(oTYP2-oTYP1)+(oTYP1-oTYP0) <= Gap_Size*(-1) )
        {
         ExtMapBuffer4[pos]=oTYP0;
        }
           
      if(
         oTYP5 < oTYP4 &&
         oTYP4 < oTYP3 &&
         oTYP3 < oTYP2 &&
         oTYP2 < oTYP1 &&
         oTYP1 < oTYP0 
         )
        {
         // six-period run-down
         ExtMapBuffer1[pos]=0;
         ExtMapBuffer2[pos]=oTYP0-0.0015;  //down red

         // five-period run-down
         //ExtMapBuffer4[pos+5]=oTYP5;
         //ExtMapBuffer4[pos+4]=oTYP4;
         //ExtMapBuffer4[pos+3]=oTYP3;
         //ExtMapBuffer4[pos+2]=oTYP2;
         //ExtMapBuffer4[pos+1]=oTYP1;
         //ExtMapBuffer4[pos+0]=oTYP0;
        }
 	   pos--;
     }

   return(0);
  }
//+------------------------------------------------------------------+

Comments