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

Mayfair Code For MT5

The document is a MetaTrader 5 (MT5) script for a trading indicator called 'Mayfair Price Action'. It includes various components for market analysis such as market structure, order blocks, fair value gaps, accumulation zones, and support/resistance levels. The script initializes these components, calculates necessary values based on market data, and manages memory cleanup upon deinitialization.

Uploaded by

Asim
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)
310 views3 pages

Mayfair Code For MT5

The document is a MetaTrader 5 (MT5) script for a trading indicator called 'Mayfair Price Action'. It includes various components for market analysis such as market structure, order blocks, fair value gaps, accumulation zones, and support/resistance levels. The script initializes these components, calculates necessary values based on market data, and manages memory cleanup upon deinitialization.

Uploaded by

Asim
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

// MayfairPriceAction.

mq5
#property copyright "Mayfair + Price Action"
#property version "1.0"
#property indicator_chart_window
#property indicator_buffers 12
#property indicator_plots 12

// Include component files


#include "MarketStructure.mqh"
#include "OrderBlocks.mqh"
#include "FairValueGaps.mqh"
#include "AccumulationZones.mqh"
#include "SupportResistance.mqh"

// Input parameters
input int SwingLookback = 50;
input int InternalLookback = 4;
input bool ShowBOS = true;
input bool ShowCHoCH = true;
input bool ShowOrderBlocks = true;
// ... (other inputs)

// Global components
MarketStructure *marketStructure;
OrderBlocks *orderBlocks;
FairValueGaps *fairValueGaps;
AccumulationZones *accZones;
SupportResistance *supRes;

int OnInit()
{
// Initialize components
marketStructure = new MarketStructure(SwingLookback, InternalLookback, ShowBOS,
ShowCHoCH);
orderBlocks = new OrderBlocks(ShowOrderBlocks);
fairValueGaps = new FairValueGaps();
accZones = new AccumulationZones();
supRes = new SupportResistance();

// Set indicator properties


IndicatorSetInteger(INDICATOR_DIGITS, _Digits);
// ... (buffer initialization)
return(INIT_SUCCEEDED);
}

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[])
{
// Calculate components
marketStructure.Calculate(rates_total, prev_calculated, time, high, low,
close);
orderBlocks.Calculate(rates_total, prev_calculated, time, open, high, low,
close, volume);
fairValueGaps.Calculate(rates_total, prev_calculated, time, open, high, low,
close);
accZones.Calculate(rates_total, prev_calculated, high, low);
supRes.Calculate(rates_total, prev_calculated, high, low);

// Update buffers for plotting


// ...

return(rates_total);
}

void OnDeinit(const int reason)


{
// Clean up objects
delete marketStructure;
delete orderBlocks;
delete fairValueGaps;
delete accZones;
delete supRes;
ObjectsDeleteAll(0, -1, -1);
}

class MarketStructure
{
private:
int swingLookback, internalLookback;
bool showBOS, showCHoCH;
// ... (other variables)

public:
MarketStructure(int swingLB, int internalLB, bool showB, bool showC)
{
swingLookback = swingLB;
internalLookback = internalLB;
showBOS = showB;
showCHoCH = showC;
}

void Calculate(const int rates_total, const int prev_calc,


const datetime &time[], const double &high[],
const double &low[], const double &close[])
{
for(int i = Bars-1; i >= 0; i--)
{
// Detect swing highs/lows
if(IsSwingHigh(i, high, swingLookback))
{
// Store swing high
}

if(IsSwingLow(i, low, swingLookback))


{
// Store swing low
}

// Detect BOS/CHoCH
if(close[i] > lastSwingHigh && showBOS)
{
DrawArrow(time[i], high[i], "BOS", clrGreen);
}

// ... (other conditions)


}
}

bool IsSwingHigh(int index, const double &high[], int lookback)


{
// Implementation
}
};

You might also like