backup v1 and compile ...
This commit is contained in:
@@ -0,0 +1,222 @@
|
||||
///////////////////////////////////////////////////////
|
||||
// SaherElm IT Center MQL5 Indicator
|
||||
// -------------------------------------------
|
||||
// Name: XDMNT
|
||||
// Description: Dominant ...
|
||||
//
|
||||
// Maintainer:
|
||||
// ------------
|
||||
// Hadi Khazaee Asl (hadi_khazaee_asl@yahoo.com)
|
||||
//
|
||||
//////////////////////////////////////////////////////
|
||||
//
|
||||
// Global Properties ...
|
||||
#property copyright "Copyright 2023, SaherElm IT Center"
|
||||
#property link "https://saherelm.ir"
|
||||
#property version "1.00"
|
||||
#property description "SaherElm XDMNT Indicator"
|
||||
#property strict
|
||||
|
||||
//
|
||||
#define ShortName "XDMNT"
|
||||
|
||||
//
|
||||
// Imports ...
|
||||
#include "../Libraries/x-saherelm.common.lib.mq5"
|
||||
|
||||
//
|
||||
// Inputs ...
|
||||
|
||||
//
|
||||
input group "Presentation";
|
||||
input bool showBull = true; // Show Bull
|
||||
input bool showBear = true; // Show Bear
|
||||
|
||||
//
|
||||
// Buffers ...
|
||||
|
||||
//
|
||||
#property indicator_chart_window
|
||||
|
||||
//
|
||||
#property indicator_buffers 2
|
||||
#property indicator_plots 2
|
||||
|
||||
//
|
||||
#define bullBufferIndex 0
|
||||
double bullBuffer[];
|
||||
|
||||
//
|
||||
#property indicator_label1 "XDMNT Bull"
|
||||
#property indicator_type1 DRAW_ARROW
|
||||
#property indicator_color1 clrAqua
|
||||
#property indicator_width1 2
|
||||
|
||||
//
|
||||
#define bearBufferIndex 1
|
||||
double bearBuffer[];
|
||||
|
||||
//
|
||||
#property indicator_label2 "XDMNT Bear"
|
||||
#property indicator_type2 DRAW_ARROW
|
||||
#property indicator_color2 clrMagenta
|
||||
#property indicator_width2 2
|
||||
|
||||
//
|
||||
// Event Handlers ...
|
||||
|
||||
//
|
||||
// Initialization ...
|
||||
int OnInit()
|
||||
{
|
||||
//
|
||||
// Validate Inputs ...
|
||||
if (!ValidateInputs())
|
||||
{
|
||||
return INIT_PARAMETERS_INCORRECT;
|
||||
}
|
||||
|
||||
//
|
||||
// Define Index Buffers ...
|
||||
DefineBuffers();
|
||||
|
||||
//
|
||||
// Set Indicator ShortName ...
|
||||
SetIndicatorName();
|
||||
|
||||
//
|
||||
// Init Succeed ...
|
||||
return INIT_SUCCEEDED;
|
||||
}
|
||||
|
||||
//
|
||||
// DeInitialization ...
|
||||
void OnDeinit(const int reason)
|
||||
{
|
||||
//
|
||||
// REASON_PROGRAM 0 The EA has stopped working calling the ExpertRemove() function
|
||||
// REASON_REMOVE 1 Program removed from a chart
|
||||
// REASON_RECOMPILE 2 Program recompiled
|
||||
// REASON_CHARTCHANGE 3 A symbol or a chart period is changed
|
||||
// REASON_CHARTCLOSE 4 Chart closed
|
||||
// REASON_PARAMETERS 5 Inputs changed by a user
|
||||
// REASON_ACCOUNT 6 Another account has been activated or reconnection to the trade server has occurred due to changes in the account settings
|
||||
// REASON_TEMPLATE 7 Another chart template applied
|
||||
// REASON_INITFAILED 8 The OnInit() handler returned a non-zero value
|
||||
// REASON_CLOSE 9 Terminal closed
|
||||
}
|
||||
|
||||
//
|
||||
// Calculating what we want ...
|
||||
int OnCalculate(
|
||||
const int rates_total, // Total Bars on Chart ...
|
||||
const int prev_calculated, // Total Calculated Bars on Charts ...
|
||||
const datetime &time[], // History of Open Time ...
|
||||
const double &open[], // History of Open Price ...
|
||||
const double &high[], // History of High Price ...
|
||||
const double &low[], // History of Low Price ...
|
||||
const double &close[], // History of Close Price ...
|
||||
const long &tick_volume[], // History of Tick Volumes on Bar ...
|
||||
const long &volume[], // History of Trade Volumes ...
|
||||
const int &spread[] // History of Spread Price ...
|
||||
)
|
||||
{
|
||||
//
|
||||
ArraySetAsSeries(open, true);
|
||||
ArraySetAsSeries(high, true);
|
||||
ArraySetAsSeries(low, true);
|
||||
ArraySetAsSeries(close, true);
|
||||
ArraySetAsSeries(time, true);
|
||||
|
||||
//
|
||||
for (int i = 1; i < rates_total - 2; i++)
|
||||
{
|
||||
//
|
||||
// Bullish ...
|
||||
if (open[i] < close[i] && open[i + 1] < close[i + 1] && open[i] >= close[i + 1] && low[i] < close[i + 1] && high[i + 1] > open[i])
|
||||
{
|
||||
//
|
||||
bullBuffer[i] = low[i + 1];
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
bullBuffer[i] = 0;
|
||||
}
|
||||
|
||||
//
|
||||
// Bearish ...
|
||||
if (open[i] > close[i] && open[i + 1] > close[i + 1] && open[i] <= close[i + 1] && high[i] > close[i + 1] && low[i + 1] < open[i])
|
||||
{
|
||||
//
|
||||
bearBuffer[i] = high[i + 1];
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
bearBuffer[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
return rates_total;
|
||||
}
|
||||
|
||||
//
|
||||
// Custom Functions ...
|
||||
|
||||
//
|
||||
// Validate Input Args for Initialization ...
|
||||
bool ValidateInputs()
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result = true;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Set Indicator Short Name and also we can define Buffers Labels ...
|
||||
void SetIndicatorName()
|
||||
{
|
||||
IndicatorSetString(INDICATOR_SHORTNAME, ShortName);
|
||||
}
|
||||
|
||||
//
|
||||
// Define Indexes and Styles ...
|
||||
void DefineBuffers()
|
||||
{
|
||||
//
|
||||
// Bull ...
|
||||
ENUM_DRAW_TYPE bullDrawType = showBull ? DRAW_ARROW : DRAW_NONE;
|
||||
|
||||
//
|
||||
ArraySetAsSeries(bullBuffer, true);
|
||||
PlotIndexSetInteger(bullBufferIndex, PLOT_ARROW, 225);
|
||||
PlotIndexSetDouble(bullBufferIndex, PLOT_EMPTY_VALUE, 0);
|
||||
SetIndexBuffer(bullBufferIndex, bullBuffer, INDICATOR_DATA);
|
||||
|
||||
//
|
||||
PlotIndexSetInteger(bullBufferIndex, PLOT_SHOW_DATA, showBull);
|
||||
PlotIndexSetInteger(bullBufferIndex, PLOT_DRAW_TYPE, bullDrawType);
|
||||
|
||||
//
|
||||
// Bear ...
|
||||
ENUM_DRAW_TYPE bearDrawType = showBear ? DRAW_ARROW : DRAW_NONE;
|
||||
|
||||
//
|
||||
ArraySetAsSeries(bearBuffer, true);
|
||||
PlotIndexSetInteger(bearBufferIndex, PLOT_ARROW, 225);
|
||||
PlotIndexSetDouble(bearBufferIndex, PLOT_EMPTY_VALUE, 0);
|
||||
SetIndexBuffer(bearBufferIndex, bearBuffer, INDICATOR_DATA);
|
||||
|
||||
//
|
||||
PlotIndexSetInteger(bearBufferIndex, PLOT_SHOW_DATA, showBull);
|
||||
PlotIndexSetInteger(bearBufferIndex, PLOT_DRAW_TYPE, bearDrawType);
|
||||
}
|
||||
|
||||
//
|
||||
Reference in New Issue
Block a user