241 lines
5.0 KiB
Plaintext
241 lines
5.0 KiB
Plaintext
///////////////////////////////////////////////////////
|
|
// SaherElm IT Center MQL5 Indicator
|
|
// -------------------------------------------
|
|
// Name: XDSR
|
|
// Description: Dynamic Support and Resistances ...
|
|
//
|
|
// 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 XDSR Indicator"
|
|
#property strict
|
|
|
|
//
|
|
#define ShortName "XDSR"
|
|
|
|
//
|
|
// Includes ...
|
|
#include "../Libraries/x-saherelm.log.lib.mq5"
|
|
#include "../Libraries/x-saherelm.draw.lib.mq5"
|
|
#include "../Libraries/x-saherelm.common.lib.mq5"
|
|
#include "../Classes/x-saherelm.xtrade.class.mq5"
|
|
|
|
//
|
|
// INPUT ...
|
|
|
|
//
|
|
// Short ...
|
|
input ENUM_TIMEFRAMES scPeriod = PERIOD_H4; // Short Period
|
|
input bool drawSCMidLine = true; // Draw MidLine
|
|
//
|
|
// Medium ...
|
|
input ENUM_TIMEFRAMES mcPeriod = PERIOD_H12; // Mid Period
|
|
input bool drawMCMidLine = true; // Draw MidLine
|
|
|
|
//
|
|
// Long ...
|
|
input ENUM_TIMEFRAMES lcPeriod = PERIOD_D1; // Long Period
|
|
input bool drawLCMidLine = true; // Draw MidLine
|
|
|
|
//
|
|
// Hind ...
|
|
input ENUM_TIMEFRAMES hcPeriod = PERIOD_W1; // Hind Period
|
|
input bool drawHCMidLine = true; // Draw MidLine
|
|
|
|
//
|
|
// BUFFERS ...
|
|
|
|
//
|
|
#property indicator_chart_window
|
|
|
|
//
|
|
#property indicator_buffers 5
|
|
#property indicator_plots 5
|
|
|
|
//
|
|
// Short ...
|
|
|
|
//
|
|
// Open ...
|
|
#define scOpenBufferIndex 0;
|
|
double scOpenBuffer[];
|
|
|
|
//
|
|
#property indicator_label1 "X121_XDSR SC O"
|
|
#property indicator_type1 DRAW_LINE
|
|
#property indicator_color1 clrCornflowerBlue
|
|
#property indicator_width1 1
|
|
|
|
//
|
|
// High ,,,
|
|
#define scHighBufferIndex 1;
|
|
double scHighBuffer[];
|
|
|
|
//
|
|
#property indicator_label2 "X121_XDSR SC H"
|
|
#property indicator_type2 DRAW_LINE
|
|
#property indicator_color2 clrCornflowerBlue
|
|
#property indicator_width2 1
|
|
|
|
//
|
|
// Close ,,,
|
|
#define scCloseBufferIndex 2;
|
|
double scCloseBuffer[];
|
|
|
|
//
|
|
#property indicator_label3 "X121_XDSR SC C"
|
|
#property indicator_type3 DRAW_LINE
|
|
#property indicator_color3 clrCornflowerBlue
|
|
#property indicator_width3 1
|
|
|
|
//
|
|
// Low ,,,
|
|
#define scLowBufferIndex 3;
|
|
double scLowBuffer[];
|
|
|
|
//
|
|
#property indicator_label4 "X121_XDSR SC L"
|
|
#property indicator_type4 DRAW_LINE
|
|
#property indicator_color4 clrCornflowerBlue
|
|
#property indicator_width4 1
|
|
|
|
//
|
|
// EVENT Handlers ...
|
|
|
|
//
|
|
// Initialization ...
|
|
int OnInit()
|
|
{
|
|
//
|
|
// Validate Inputs ...
|
|
if (!ValidateInputs())
|
|
{
|
|
return INIT_PARAMETERS_INCORRECT;
|
|
}
|
|
|
|
//
|
|
logTag = ShortName;
|
|
drawPrefix = ShortName;
|
|
|
|
//
|
|
// 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(
|
|
//
|
|
// total Candles on chart ...
|
|
const int rates_total,
|
|
//
|
|
// total calculated Candles on charts ...
|
|
const int prev_calculated,
|
|
//
|
|
// history of Candles Open Time ...
|
|
const datetime &time[],
|
|
//
|
|
// history of Candles Open Price ...
|
|
const double &open[],
|
|
//
|
|
// history of Candles High Price ...
|
|
const double &high[],
|
|
//
|
|
// history of Candles Low Price ...
|
|
const double &low[],
|
|
//
|
|
// history of Candles Close Price ...
|
|
const double &close[],
|
|
//
|
|
// history of Tick Volumes on Candle ...
|
|
const long &tick_volume[],
|
|
//
|
|
// history of Trade Volumes ...
|
|
const long &volume[],
|
|
//
|
|
// history of Candles Spread Price ...
|
|
const int &spread[])
|
|
{
|
|
//
|
|
if (rates_total < 50)
|
|
{
|
|
return prev_calculated;
|
|
}
|
|
|
|
//
|
|
int start = prev_calculated == 0
|
|
? 50
|
|
: prev_calculated - 1;
|
|
|
|
//
|
|
// Main Loop ...
|
|
for (int barIndex = start; barIndex < rates_total; barIndex++)
|
|
{
|
|
}
|
|
|
|
//
|
|
return rates_total;
|
|
}
|
|
|
|
//
|
|
// CUSTOM Functions ...
|
|
|
|
//
|
|
// Validate Input Args for Initialization ...
|
|
bool ValidateInputs()
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
result = true;
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Define Indexes and Styles ...
|
|
void DefineBuffers()
|
|
{
|
|
}
|
|
|
|
//
|
|
// Set Indicator Short Name and also we can define Buffers Labels ...
|
|
void SetIndicatorName()
|
|
{
|
|
IndicatorSetString(INDICATOR_SHORTNAME, ShortName);
|
|
}
|