// 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
}
};