PredictPriceHist

Download script
PredictPriceHist

The PredictPrice indicator is designed to analyze historical price movements and provide visual signals regarding potential future price trends. Rather than relying on standard volume or momentum indicators, it utilizes a specific mathematical formula to calculate a "prediction" value based on the relationship between recent price points.

How the Logic Works

The tool functions by examining the closing prices of the last five candles on your chart. It processes this data in two distinct steps:

  1. Data Aggregation: The script calculates two different averages. First, it finds the midpoint of the two most recent prices. Second, it calculates the average of all five most recent prices.
  2. Prediction Calculation: By comparing these two averages against each other and applying a specific mathematical constant, the script generates a numerical "prediction" value. This value represents the intensity or strength of the current price movement relative to the historical data provided.

Visual Signals and Interpretation

The indicator translates these complex calculations into three distinct visual categories on your chart, colored for easy identification:

  • Buy Signals (Green): When the calculated prediction value exceeds a high threshold (default 80) and the short-term average is trending higher than the long-term average, the indicator identifies a potential "Buy" opportunity.
  • Sell Signals (Red): When the prediction value exceeds a moderate threshold (default 60) but the short-term average is trending lower than the long-term average, the indicator identifies a potential "Sell" opportunity.
  • Neutral Market (Yellow/Flat): If the price action does not meet the specific criteria for a Buy or Sell signal, the prediction value is displayed as a neutral "Flat" state. This indicates that the current trend lacks sufficient strength or clarity to trigger a specific direction.

In summary, this tool acts as a filter, helping traders distinguish between significant market shifts and standard price noise by mathematically weighing recent trends against a broader five-period average.

Price Data Components
Series array that contains close prices for each bar
Miscellaneous
Implements a curve of type %1
10 Views
0 Downloads
0 Favorites
PredictPriceHist
/*-----------------------------+
|			       |
| Shared by www.Aptrafx.com    |
|			       |
+------------------------------*/

//+------------------------------------------------------------------+
//|                                                  PredictPrice    |
//|                                    Copyright © 2006, Robert Hill |
//|                                                                  |
//| Attempts to pridict next price.                                  |
//| Based on formula provided by Bud Foxx
//+------------------------------------------------------------------+
#property  copyright "Copyright © 2006, Robert Hill "

//---- indicator settings
#property  indicator_separate_window
#property  indicator_buffers 3
#property indicator_color1 Yellow      
#property indicator_color2 Red
#property indicator_color3 Green
#property indicator_width1 2
#property indicator_width2 2
#property indicator_width3 2

extern int BuyLevel = 80;
extern int SellLevel = 60;

//---- buffers
double UpBuffer[];
double DownBuffer[];
double FlatBuffer[];

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
  
   SetIndexBuffer(2,UpBuffer);
   SetIndexBuffer(1,DownBuffer);
   SetIndexBuffer(0,FlatBuffer);
   
   SetIndexStyle(2,DRAW_HISTOGRAM,STYLE_SOLID,2);
   SetIndexStyle(1,DRAW_HISTOGRAM,STYLE_SOLID,2);
   SetIndexStyle(0,DRAW_HISTOGRAM,STYLE_SOLID,2);

//---- initialization done
   return(0);
  }

int start()

  {
   double D1, D2, D3, D4, D5;
   double DATA2, DATA5;
   double predict;
   int shift;
   int    limit;
   int    counted_bars=IndicatorCounted();
   if(counted_bars>0) counted_bars--;
   limit=Bars-counted_bars - 5;
  
   for(shift = limit; shift >= 0; shift--)
   { 
         D1=iClose(NULL,0,shift+1);
         D2=iClose(NULL,0,shift+2);
         D3=iClose(NULL,0,shift+3);
         D4=iClose(NULL,0,shift+4);
         D5=iClose(NULL,0,shift+5);


         DATA2=(D1+D2) /2;
         DATA5=(D1+D2+ D3+D4+D5) /5;

         predict=((MathAbs( DATA2-DATA5) /D1*125.75 + 0.54528)*10000) /100;

         
//========== COLOR CODING ===========================================               
/*
   IF PREDICT > 50 AND PREDICT < 60 THEN FLAT

   IF PREDICT > 80 AND DATA2>DATA5 THEN BUY

   IF PREDICT > 60 AND DATA2<DATA5 THEN SELL
*/
        
        UpBuffer[shift] = 0;
        DownBuffer[shift] = 0;
        FlatBuffer[shift] = 0;

        if (predict > BuyLevel && DATA2 > DATA5)
        {
            UpBuffer[shift] = predict;
        }
        else if (predict > SellLevel && DATA2 < DATA5) 
        {
            DownBuffer[shift] = predict;
        }
        else 
        {
            FlatBuffer[shift]=predict;
        }
        
      }
       
      return(0);
  }
//+------------------------------------------------------------------+



Comments