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

WickRejection Code Complete

mql5 code for wick rejection

Uploaded by

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

WickRejection Code Complete

mql5 code for wick rejection

Uploaded by

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

//+------------------------------------------------------------------+

//| WickRejection.mq5|

//| Custom Indicator to highlight wick rejections on chart |

//+------------------------------------------------------------------+

#property indicator_separate_window

#property indicator_buffers 3

#property indicator_color1 Red // Worst areas

#property indicator_color2 Yellow // Better areas

#property indicator_color3 Green // Best areas

input int WickLengthFactor = 2; // Wick must be 'n' times the body size to qualify

input int MinRejections = 5; // Minimum number of rejections to categorize area

double WorstBuffer[];

double BetterBuffer[];

double BestBuffer[];

// Initialization of the indicator

int OnInit()

SetIndexBuffer(0, WorstBuffer);

SetIndexBuffer(1, BetterBuffer);

SetIndexBuffer(2, BestBuffer);

return(INIT_SUCCEEDED);

// Function to calculate wick rejection strength

bool IsWickRejection(int i)

{
double bodySize = MathAbs(Open[i] - Close[i]);

double upperWick = High[i] - MathMax(Open[i], Close[i]);

double lowerWick = MathMin(Open[i], Close[i]) - Low[i];

// Check if upper or lower wick is significantly larger than the body

if (upperWick > bodySize * WickLengthFactor || lowerWick > bodySize * WickLengthFactor)

return true;

return false;

// Indicator Calculation

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[])

int countWorst = 0, countBetter = 0, countBest = 0;

for (int i = 1; i < rates_total - 1; i++)

if (IsWickRejection(i))

// Count wick rejections at the current price level


int rejectionCount = 0;

double rejectionPrice = Close[i];

// Check past candles for similar wick rejections

for (int j = i; j < i + 20 && j < rates_total; j++)

if (MathAbs(Close[j] - rejectionPrice) < SymbolInfoDouble(SYMBOL_POINT) * 10)

rejectionCount++;

// Categorize areas based on rejection count

if (rejectionCount >= MinRejections * 2)

WorstBuffer[i] = rejectionPrice;

else if (rejectionCount >= MinRejections)

BetterBuffer[i] = rejectionPrice;

else

BestBuffer[i] = rejectionPrice;

return(rates_total);

You might also like