Author: Copyright 2006 � Ronald Verwer / ROVERCOM
Predict_v1

The Predict.mq4 script is a specialized market analysis tool designed to identify potential trends and signal directions by analyzing price movements in real-time. Instead of looking at raw prices alone, it calculates specific mathematical relationships between recent historical data to determine whether the market is leaning toward an upward move, a downward move, or remaining neutral.

How the Logic Works

The core of this tool relies on three main pillars of analysis:

1. Dual-Average Comparisons The script continuously monitors two different types of "averages" based on the most recent price closes.

  • It looks at a very short-term average (the immediate previous two prices).
  • It compares this against a slightly broader, medium-term average (the last five prices). By comparing these two benchmarks, the script can sense the "momentum"—whether the price is accelerating faster than its recent history or slowing down.

2. Momentum Strength Calculation Beyond just identifying direction, the tool calculates a specific strength value (referred to as "Pr" in the system). This value measures the intensity of the price movement relative to the current market level.

  • The script uses this strength value to filter out "noise."
  • A signal is only generated if the momentum exceeds a pre-defined threshold (the "Buy" or "Sell" levels), ensuring that minor fluctuations don't trigger unnecessary alerts.

3. Signal Identification & Visuals Based on the interaction between the averages and the momentum strength, the script categorizes the market into three states:

  • Upward Trend (Long): Triggered when the short-term average is higher than the medium-term average and the momentum strength is sufficiently high. This is marked on your chart with specific visual icons.
  • Downward Trend (Short): Triggered when the short-term average falls below the medium-term average while maintaining high momentum strength.
  • Flat/Neutral: If the momentum is low or sits within a specific "gray zone," the script identifies the market as flat, indicating a lack of clear direction.

Summary for the User

In simple terms, this script acts as a sophisticated filter. It watches how fast the price is moving compared to its recent past. If it detects a strong, consistent push in one direction that exceeds a specific intensity level, it provides a visual cue on your chart to highlight that potential move. It also includes an on-screen comment that updates live, showing you the current momentum strength and the prevailing market prediction (Long, Short, or Flat).

Miscellaneous
Implements a curve of type %1
10 Views
0 Downloads
0 Favorites
Predict_v1
//+------------------------------------------------------------------+
//|                                        Created by Ronald Verwer. |
//|                                                      Predict.mq4 |
//|                      Copyright; 2006 © by Ronald Verwer/ROVERCOM |
//+------------------------------------------------------------------+

#property copyright "Copyright 2006 © Ronald Verwer / ROVERCOM"

#property indicator_chart_window
#property indicator_buffers 3

#property indicator_color1 Blue
#property indicator_color2 Magenta
#property indicator_color3 Orange
#property indicator_width1 2
#property indicator_width2 2
#property indicator_width3 2

extern int BuyLevel = 56;
extern int SellLevel = 56;

extern bool    Use_Single_Arrows            = false;//true;

double Up[];
double Dn[];
double Fl[];
double Drctn[];

//+------------------------------------------------------------------+
//| Indicator Initialization Function                                |
//+------------------------------------------------------------------+

int init()
   {
   IndicatorBuffers(4);
   SetIndexStyle(0,DRAW_ARROW,0,2);
   SetIndexArrow(0,233);
   SetIndexStyle(1,DRAW_ARROW,0,2);
   SetIndexArrow(1,234);
   SetIndexStyle(2,DRAW_ARROW,0,2);
   SetIndexArrow(2,159);

   SetIndexBuffer(0,Up);
   SetIndexBuffer(1,Dn);
   SetIndexBuffer(2,Fl);
   SetIndexBuffer(3,Drctn);

   IndicatorShortName("Prediction");
   SetIndexLabel(0,"Up");
   SetIndexLabel(1,"Dn");
   SetIndexLabel(2,"Flat");
//----
   SetIndexDrawBegin(0,10);
   SetIndexDrawBegin(1,10);
   SetIndexDrawBegin(2,10);
//----
   return(0);
   }

//+------------------------------------------------------------------+
//| Indicator De-Initialization Function                             |
//+------------------------------------------------------------------+

int deinit()
   {
   return(0);
   }

//+------------------------------------------------------------------+
//| EMA_Levels                                                       |
//+------------------------------------------------------------------+

int start()
  {
   int i,limit;
   double D1,D2,Pr;
   string Txt;
   int counted_bars=IndicatorCounted();
   if(counted_bars<0) return(-1);
   if(counted_bars>0) counted_bars--;
   limit=Bars-counted_bars;
   
	for(i=limit;i>=0;i--) 
      {	
      Up[i] = EMPTY_VALUE;
      Dn[i] = EMPTY_VALUE;
      Fl[i] = EMPTY_VALUE;
      
      D1=(Close[i+1]+Close[i+2])/2;
      D2=(Close[i+1]+Close[i+2]+Close[i+3]+Close[i+4]+Close[i+5])/5;
      if(Close[i+1]!=0)
         Pr=((MathAbs(D1-D2)/Close[i+1]*125.75 + 0.54528)*10000)/100;
         
      if(D1>D2 && Pr>BuyLevel)
         {
         Drctn[i] = 1;
         if(Drctn[i] != Drctn[i+1] || !Use_Single_Arrows)
            Up[i] = Low[i] - 4 * Point;
         }
      else if(D1<D2 && Pr>SellLevel)
         {
         Drctn[i] = -1;
         if(Drctn[i] != Drctn[i+1] || !Use_Single_Arrows)
            Dn[i] = High[i] + 4 * Point;
         }
      else if(Pr>50 && Pr<60)
            {
            Drctn[i] = 0;
            if(Drctn[i+1]==1)
               Fl[i] = Low[i] - 4 * Point;
            else if(Drctn[i+1]==-1)
               Fl[i] = High[i] + 4 * Point;
            }
      else
         Drctn[i] = 0;
      }
   if(Drctn[0]==-1) Txt="Short";
   else if(Drctn[0]==1) Txt="Long";
   else Txt="Flat";
   
   Comment("Predictions: Pr = "+DoubleToStr(Pr,3)+" ; Current Signal =  "+Txt);
	return(0);	
   }
  
//----

Comments