generated from LengKundee/UA6-9V_VL6-N9
122 lines
4.6 KiB
MQL5
122 lines
4.6 KiB
MQL5
|
|
//+------------------------------------------------------------------+
|
||
|
|
//| Wick Engulf.mq5 |
|
||
|
|
//| Rajesh Nait, Copyright 2023 |
|
||
|
|
//| https://www.mql5.com/en/users/rajeshnait/seller |
|
||
|
|
//+------------------------------------------------------------------+
|
||
|
|
#property copyright "Rajesh Nait, Copyright 2023"
|
||
|
|
#property link "https://www.mql5.com/en/users/rajeshnait/seller"
|
||
|
|
#property version "1.00"
|
||
|
|
#property indicator_chart_window
|
||
|
|
#property indicator_buffers 2
|
||
|
|
#property indicator_plots 2
|
||
|
|
|
||
|
|
//--- plot Bullish Marubozu
|
||
|
|
#property indicator_label1 "+WE"
|
||
|
|
#property indicator_type1 DRAW_ARROW
|
||
|
|
#property indicator_color1 clrSnow
|
||
|
|
#property indicator_style1 STYLE_SOLID
|
||
|
|
#property indicator_width1 1
|
||
|
|
//--- plot Bearish Marubozu
|
||
|
|
#property indicator_label2 "-WE"
|
||
|
|
#property indicator_type2 DRAW_ARROW
|
||
|
|
#property indicator_color2 clrSnow
|
||
|
|
#property indicator_style2 STYLE_SOLID
|
||
|
|
#property indicator_width2 1
|
||
|
|
|
||
|
|
|
||
|
|
//--- input parameters
|
||
|
|
input group "Bearish"
|
||
|
|
input uchar InpBullishWECode = 233; // BullishWE: code for style DRAW_ARROW (font Wingdings)
|
||
|
|
input int InpBullishWEShift = 10; // BullishWE: vertical shift of arrows in pixels
|
||
|
|
input group "Bullish"
|
||
|
|
input uchar InpBearishWECode = 234; // BearishWE: code for style DRAW_ARROW (font Wingdings)
|
||
|
|
input int InpBearishWEShift =10; // BearishWE: vertical shift of arrows in pixels
|
||
|
|
//--- indicator buffers
|
||
|
|
double BullishWEBuffer[];
|
||
|
|
double BearishWEBuffer[];
|
||
|
|
int min_rates_total;
|
||
|
|
//+------------------------------------------------------------------+
|
||
|
|
//| Custom indicator initialization function |
|
||
|
|
//+------------------------------------------------------------------+
|
||
|
|
int OnInit() {
|
||
|
|
min_rates_total=2;
|
||
|
|
//--- indicator buffers mapping
|
||
|
|
SetIndexBuffer(0,BullishWEBuffer,INDICATOR_DATA);
|
||
|
|
SetIndexBuffer(1,BearishWEBuffer,INDICATOR_DATA);
|
||
|
|
|
||
|
|
IndicatorSetInteger(INDICATOR_DIGITS,Digits());
|
||
|
|
//--- setting a code from the Wingdings charset as the property of PLOT_ARROW
|
||
|
|
PlotIndexSetInteger(0,PLOT_DRAW_BEGIN,min_rates_total);
|
||
|
|
PlotIndexSetInteger(1,PLOT_DRAW_BEGIN,min_rates_total);
|
||
|
|
|
||
|
|
PlotIndexSetInteger(0,PLOT_ARROW,InpBullishWECode);
|
||
|
|
PlotIndexSetInteger(1,PLOT_ARROW,InpBearishWECode);
|
||
|
|
|
||
|
|
ArraySetAsSeries(BullishWEBuffer,true);
|
||
|
|
ArraySetAsSeries(BearishWEBuffer,true);
|
||
|
|
|
||
|
|
//--- set the vertical shift of arrows in pixels
|
||
|
|
PlotIndexSetInteger(0,PLOT_ARROW_SHIFT,InpBullishWEShift);
|
||
|
|
PlotIndexSetInteger(1,PLOT_ARROW_SHIFT,-InpBearishWEShift);
|
||
|
|
//--- set as an empty value 0.0
|
||
|
|
PlotIndexSetDouble(0,PLOT_EMPTY_VALUE,0.0);
|
||
|
|
PlotIndexSetDouble(1,PLOT_EMPTY_VALUE,0.0);
|
||
|
|
//---
|
||
|
|
return(INIT_SUCCEEDED);
|
||
|
|
}
|
||
|
|
//+------------------------------------------------------------------+
|
||
|
|
//| Custom indicator iteration function |
|
||
|
|
//+------------------------------------------------------------------+
|
||
|
|
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<min_rates_total)
|
||
|
|
return(0);
|
||
|
|
|
||
|
|
int limit;
|
||
|
|
|
||
|
|
if(prev_calculated>rates_total || prev_calculated<=0) {
|
||
|
|
limit=rates_total-min_rates_total;
|
||
|
|
} else {
|
||
|
|
limit=rates_total-prev_calculated;
|
||
|
|
}
|
||
|
|
ArraySetAsSeries(open,true);
|
||
|
|
ArraySetAsSeries(high,true);
|
||
|
|
ArraySetAsSeries(low,true);
|
||
|
|
ArraySetAsSeries(close,true);
|
||
|
|
|
||
|
|
//---
|
||
|
|
|
||
|
|
for(int i=limit; i>=0 && !IsStopped(); i--) {
|
||
|
|
BullishWEBuffer[i]=0.0;
|
||
|
|
BearishWEBuffer[i]=0.0;
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
BearishWEBuffer[0]=0.0;
|
||
|
|
if(
|
||
|
|
(open[i]<close[i] && open[i+1]<close[i+1] && high[i+1]>high[i] && open[i]>=close[i+1]) ||
|
||
|
|
(open[i]<close[i] && open[i+1]>close[i+1] && high[i+1]>high[i] && open[i]>=open[i+1])
|
||
|
|
)
|
||
|
|
BearishWEBuffer[i]=high[i];
|
||
|
|
|
||
|
|
BullishWEBuffer[0]=0.0;
|
||
|
|
if(
|
||
|
|
(open[i]>close[i] && open[i+1]>close[i+1] && low[i+1]<low[i] && open[i]<=close[i+1]) ||
|
||
|
|
(open[i]>close[i] && open[i+1]<close[i+1] && low[i+1]<low[i] && open[i]<=open[i+1])
|
||
|
|
)
|
||
|
|
BullishWEBuffer[i]=low[i];
|
||
|
|
|
||
|
|
}
|
||
|
|
//--- return value of prev_calculated for next call
|
||
|
|
return(rates_total);
|
||
|
|
}
|
||
|
|
//+------------------------------------------------------------------+
|