PredictPrice
Download scriptThe PredictPrice tool is designed to analyze historical price movements to help traders identify potential future trends. Rather than reacting to what has already happened, this script uses a specific mathematical formula—derived from the work of Bud Foxx—to estimate where the price might head next based on recent market behavior.
How the Logic Works
The script operates by examining the most recent closing prices of the market over a short period. It specifically looks at the last five data points to perform three primary calculations:
- Short-Term Average: It calculates the average price of the two most recent bars.
- Longer-Term Average: It calculates the average price across the last five bars.
- The Prediction Formula: By measuring the difference between these two averages and applying a specific multiplier and constant, the tool generates a "prediction" value. This value represents the momentum and potential trajectory of the price.
Visual Signals and Trading Logic
The indicator provides visual feedback on your chart by displaying different colors based on the relationship between the prediction value and the price averages:
- Buy Signals: When the prediction value exceeds a specific high threshold (default set at 80) and the short-term average is higher than the longer-term average, the tool identifies an upward momentum.
- Sell Signals: When the prediction value exceeds a specific threshold (default set at 60) but the short-term average is lower than the longer-term average, it identifies downward momentum.
- Neutral Zone: If neither of these specific conditions are met, the tool remains "flat," indicating that there is no clear high-probability signal and that market conditions may be balanced orsideways.
In essence, this script acts as a filter, attempting to strip away market noise to highlight specific moments where price momentum aligns with predictive mathematical modeling.
/*-----------------------------+
| |
| 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 ExtMapBuffer1[];
double ExtMapBuffer2[];
double ExtMapBuffer3[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
SetIndexBuffer(2,ExtMapBuffer1);
SetIndexBuffer(1,ExtMapBuffer2);
SetIndexBuffer(0,ExtMapBuffer3);
SetIndexStyle(2,DRAW_LINE,STYLE_SOLID,2);
SetIndexStyle(1,DRAW_LINE,STYLE_SOLID,2);
SetIndexStyle(0,DRAW_LINE,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
*/
ExtMapBuffer3[shift] = predict; //red
ExtMapBuffer2[shift] = predict; //green
ExtMapBuffer1[shift] = predict; //yellow
if (predict > BuyLevel && DATA2 > DATA5)
{
ExtMapBuffer2[shift] = EMPTY_VALUE;
}
else if (predict > SellLevel && DATA2 < DATA5)
{
ExtMapBuffer1[shift] = EMPTY_VALUE; //-1 red/greem tight
}
else
{
ExtMapBuffer1[shift]=EMPTY_VALUE;//EMPTY_VALUE;
ExtMapBuffer2[shift]=EMPTY_VALUE;//EMPTY_VALUE;
}
}
return(0);
}
//+------------------------------------------------------------------+
Comments