0% found this document useful (0 votes)
145 views3 pages

Xauusd Advanced Predictor

Uploaded by

ali.52771372
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
145 views3 pages

Xauusd Advanced Predictor

Uploaded by

ali.52771372
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

#property copyright "Advanced Future Candle Predictor"

#property link "https://www.example.com"


#property version "1.00"
#property strict
#property indicator_chart_window
#property indicator_buffers 5
#property indicator_plots 5

// Input Parameters
input int LookbackPeriod = 15; // Lookback Period
input int VolatilityPeriod = 20; // Volatility Period
input double TrendSensitivity = 1.5; // Trend Sensitivity

// Buffers for visualization


double PredictionBuffer[];
double ConfidenceBuffer[];
double TrendBuffer[];
double PatternBuffer[];
double RiskBuffer[];

// Global variables
int shortEMA, mediumEMA, longEMA;

int OnInit()
{
SetIndexStyle(0, DRAW_LINE, STYLE_SOLID, 2, clrBlue);
SetIndexBuffer(0, PredictionBuffer);
SetIndexLabel(0, "Prediction Score");

SetIndexStyle(1, DRAW_LINE, STYLE_DOT, 1, clrGreen);


SetIndexBuffer(1, ConfidenceBuffer);
SetIndexLabel(1, "Confidence Score");

SetIndexStyle(2, DRAW_LINE, STYLE_DASH, 1, clrRed);


SetIndexBuffer(2, TrendBuffer);
SetIndexLabel(2, "Trend Score");

SetIndexStyle(3, DRAW_ARROW, STYLE_SOLID, 2, clrYellow);


SetIndexBuffer(3, PatternBuffer);
SetIndexLabel(3, "Candle Pattern");

SetIndexStyle(4, DRAW_LINE, STYLE_DOT, 1, clrOrange);


SetIndexBuffer(4, RiskBuffer);
SetIndexLabel(4, "Risk Level");

shortEMA = iMA(_Symbol, PERIOD_CURRENT, 10, 0, MODE_EMA, PRICE_CLOSE);


mediumEMA = iMA(_Symbol, PERIOD_CURRENT, 21, 0, MODE_EMA, PRICE_CLOSE);
longEMA = iMA(_Symbol, PERIOD_CURRENT, 50, 0, MODE_EMA, PRICE_CLOSE);

return(INIT_SUCCEEDED);
}

// Helper Functions
double GetCandleBody(int shift)
{
return MathAbs(Close[shift] - Open[shift]);
}

int GetCandleDirection(int shift)


{
return Close[shift] > Open[shift] ? 1 : -1;
}

bool IsBullishEngulfing(int shift)


{
return Close[shift] > Open[shift] &&
Close[shift] > Open[shift+1] &&
Open[shift] < Close[shift+1] &&
GetCandleBody(shift) > GetCandleBody(shift+1) &&
GetCandleDirection(shift) == 1;
}

bool IsBearishEngulfing(int shift)


{
return Close[shift] < Open[shift] &&
Close[shift] < Open[shift+1] &&
Open[shift] > Close[shift+1] &&
GetCandleBody(shift) > GetCandleBody(shift+1] &&
GetCandleDirection(shift) == -1;
}

int OnCalculate(const int rates_total,


const int prev_calculated,
const datetime &time[],
const double &open[],
const double &high[],
const double &low[],
const double &close[],
const long &tick_volume[],
const long &volume[],
const int &spread[])
{
for(int i = MathMax(1, prev_calculated-1); i < rates_total; i++)
{
// Volatility Analysis
double volatility = iStdDev(_Symbol, PERIOD_CURRENT, VolatilityPeriod, 0,
MODE_SMA, PRICE_CLOSE, i);
double volatilityMA = iMA(_Symbol, PERIOD_CURRENT, VolatilityPeriod, 0,
MODE_SMA, PRICE_DEVIATION, i);
bool isHighVolatility = volatility > volatilityMA * 1.5;

// Trend Detection
double shortMA = iMA(_Symbol, PERIOD_CURRENT, 10, 0, MODE_EMA, PRICE_CLOSE,
i);
double mediumMA = iMA(_Symbol, PERIOD_CURRENT, 21, 0, MODE_EMA,
PRICE_CLOSE, i);
double longMA = iMA(_Symbol, PERIOD_CURRENT, 50, 0, MODE_EMA, PRICE_CLOSE,
i);

bool bullishTrend = close[i] > shortMA && shortMA > mediumMA && mediumMA >
longMA;
bool bearishTrend = close[i] < shortMA && shortMA < mediumMA && mediumMA <
longMA;
bool sidewaysMarket = !bullishTrend && !bearishTrend;

// Pattern Recognition
bool bullishPattern = IsBullishEngulfing(i);
bool bearishPattern = IsBearishEngulfing(i);
// Volume Analysis
double volumeMA = iMA(_Symbol, PERIOD_CURRENT, LookbackPeriod, 0, MODE_SMA,
PRICE_VOLUME, i);
bool volumeBreakout = volume[i] > volumeMA * 2;

// Advanced Scoring System


double trendWeight = sidewaysMarket ? 0.2 : 0.4;
double patternWeight = isHighVolatility ? 0.3 : 0.2;
double volumeWeight = volumeBreakout ? 0.3 : 0.2;
double structureWeight = 1.0 - (trendWeight + patternWeight +
volumeWeight);

double trendScore = bullishTrend ? 1.0 : bearishTrend ? -1.0 : 0.0;


double patternScore = bullishPattern ? 1.0 : bearishPattern ? -1.0 : 0.0;
double volumeScore = volumeBreakout ? 1.0 : -1.0;

// Final Prediction Score


double predictionScore = (trendScore * trendWeight +
patternScore * patternWeight +
volumeScore * volumeWeight) * TrendSensitivity;

// Confidence Calculation
double confidenceScore = MathAbs(predictionScore);

// Store Results
PredictionBuffer[i] = predictionScore;
ConfidenceBuffer[i] = confidenceScore;
TrendBuffer[i] = trendScore;
PatternBuffer[i] = patternScore;
RiskBuffer[i] = isHighVolatility ? 1.0 : 0.0;
}

return rates_total;
}

You might also like