0% found this document useful (0 votes)
5 views2 pages

Engulfing Candle Donchian Signal Indicator

The document outlines the code for a trading indicator called 'ReversalWithDonchianHTF' which utilizes an engulfing candle pattern and the Donchian Channel for generating buy and sell signals. It includes properties for indicator buffers, styles, and settings for high time frame filtering. The OnCalculate function processes market data to determine buy and sell conditions based on the defined criteria.

Uploaded by

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

Engulfing Candle Donchian Signal Indicator

The document outlines the code for a trading indicator called 'ReversalWithDonchianHTF' which utilizes an engulfing candle pattern and the Donchian Channel for generating buy and sell signals. It includes properties for indicator buffers, styles, and settings for high time frame filtering. The OnCalculate function processes market data to determine buy and sell conditions based on the defined criteria.

Uploaded by

faucetc630
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

//+------------------------------------------------------------------+ //|

ReversalWithDonchianHTF.mq5 | //| Signal: Engulfing Candle +


Donchian Channel + HTF Color |
//+------------------------------------------------------------------+ #property
indicator_chart_window #property indicator_buffers 2 #property
indicator_color1 Lime #property indicator_color2 Red

input int Donchian_Period = 20; input ENUM_TIMEFRAMES HTF =


PERIOD_H1;

// Indicator buffers double BuySignal[]; double SellSignal[];

int OnInit() { SetIndexBuffer(0, BuySignal, INDICATOR_DATA);


SetIndexStyle(0, DRAW_ARROW); SetIndexArrow(0, 233);

SetIndexBuffer(1, SellSignal, INDICATOR_DATA); SetIndexStyle(1,


DRAW_ARROW); SetIndexArrow(1, 234);

ArraySetAsSeries(BuySignal, true); ArraySetAsSeries(SellSignal, true);

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[]) { if (rates_total < Donchian_Period + 2) return 0;

for (int i = rates_total - Donchian_Period - 2; i >= 0; i--) { double donHigh =


iHigh(NULL, 0, iHighest(NULL, 0, MODE_HIGH, Donchian_Period, i));
double donLow = iLow(NULL, 0, iLowest(NULL, 0, MODE_LOW,
Donchian_Period, i));

// HTF filter: Use bar index parity as placeholder for color


bool htfBull = iBarShift(NULL, HTF, Time[i]) % 2 == 0;
bool htfBear = !htfBull;

// BUY condition: Engulfing + price near Donchian Low + HTF

You might also like