last ...
This commit is contained in:
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,573 @@
|
|||||||
|
///////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// SaherElm IT Center MQL5 Indicator
|
||||||
|
// -------------------------------------------------
|
||||||
|
// Name: X121 XSWLH
|
||||||
|
// Description: XSWLH ...
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// 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 X121 XSWLH Indicator"
|
||||||
|
#property strict
|
||||||
|
|
||||||
|
//
|
||||||
|
// Definitions ...
|
||||||
|
|
||||||
|
//
|
||||||
|
#define ShortName "X121 XSWLH"
|
||||||
|
|
||||||
|
//
|
||||||
|
// Includes Common Library ...
|
||||||
|
#include "../Libraries/x-saherelm.common.lib.mq5"
|
||||||
|
|
||||||
|
//
|
||||||
|
// Inputs ...
|
||||||
|
|
||||||
|
//
|
||||||
|
input int swingLength; // Swing Length
|
||||||
|
|
||||||
|
//
|
||||||
|
input int startCalculationForLastBars = 1000; // Calculate Last n Bars
|
||||||
|
|
||||||
|
//
|
||||||
|
input bool showSwingLow; // Show Swing Low
|
||||||
|
input bool showSwingHigh; // Show Swing High
|
||||||
|
|
||||||
|
//
|
||||||
|
input int swingLowArrowCode = 225; // Swing Low Arrow Code
|
||||||
|
input int swingHighArrowCode = 226; // Swing High Arrow Code
|
||||||
|
|
||||||
|
//
|
||||||
|
#define emptyValue 0.0
|
||||||
|
|
||||||
|
//
|
||||||
|
// Buffers ...
|
||||||
|
|
||||||
|
//
|
||||||
|
#property indicator_chart_window
|
||||||
|
|
||||||
|
//
|
||||||
|
#property indicator_buffers 2
|
||||||
|
#property indicator_plots 2
|
||||||
|
|
||||||
|
//
|
||||||
|
// SWING LOW ...
|
||||||
|
|
||||||
|
//
|
||||||
|
#define swingLowBufferIndex 0
|
||||||
|
double swingLowBuffer[];
|
||||||
|
|
||||||
|
//
|
||||||
|
#property indicator_label1 "SWL"
|
||||||
|
#property indicator_type1 DRAW_ARROW
|
||||||
|
#property indicator_color1 clrGreen
|
||||||
|
#property indicator_width1 1
|
||||||
|
|
||||||
|
//
|
||||||
|
// SWING HIGH ...
|
||||||
|
|
||||||
|
//
|
||||||
|
#define swingHighBufferIndex 1
|
||||||
|
double swingHighBuffer[];
|
||||||
|
|
||||||
|
//
|
||||||
|
#property indicator_label2 "SWH"
|
||||||
|
#property indicator_type2 DRAW_ARROW
|
||||||
|
#property indicator_color2 clrRed
|
||||||
|
#property indicator_width2 1
|
||||||
|
|
||||||
|
//
|
||||||
|
// Data Buffers ...
|
||||||
|
|
||||||
|
//
|
||||||
|
#define lastBufferIndex 1
|
||||||
|
|
||||||
|
//
|
||||||
|
// Variables, Properties and etc ...
|
||||||
|
|
||||||
|
//
|
||||||
|
// this counts Available Bars ...
|
||||||
|
int limit;
|
||||||
|
|
||||||
|
//
|
||||||
|
int firstBarIndex;
|
||||||
|
|
||||||
|
//
|
||||||
|
int maxLength;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Event Handlers ...
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialize Indicator ...
|
||||||
|
*
|
||||||
|
* @return ( int )
|
||||||
|
*/
|
||||||
|
int OnInit()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Validate Inputs ...
|
||||||
|
if (!ValidateInputs())
|
||||||
|
{
|
||||||
|
return INIT_PARAMETERS_INCORRECT;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Initialize Indicator Handlers ...
|
||||||
|
|
||||||
|
//
|
||||||
|
// because in some cases we may have more than one input for
|
||||||
|
// calculation and we must prevent any calculation
|
||||||
|
// untill we pass the biggest input length, here we get max Input length
|
||||||
|
// and then wait until pass it ...
|
||||||
|
maxLength = ExtractMaxLengthOfInputs();
|
||||||
|
|
||||||
|
//
|
||||||
|
// Define Index Buffers ...
|
||||||
|
DefineBuffers();
|
||||||
|
|
||||||
|
//
|
||||||
|
// Set Indicator ShortName ...
|
||||||
|
SetIndicatorName();
|
||||||
|
|
||||||
|
//
|
||||||
|
// Init Succeed ...
|
||||||
|
return INIT_SUCCEEDED;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* De Initialize Indicator ...
|
||||||
|
*
|
||||||
|
* @param reason: Integer, De Initialization Reason ...
|
||||||
|
*/
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calculate Bars ...
|
||||||
|
*
|
||||||
|
* @param rates_total: Integer, Total Bars on Chart ...
|
||||||
|
* @param prev_calculated: Integer, Total Calculated Bars on Charts ...
|
||||||
|
* @param time: DateTime Array, History of Open Time ...
|
||||||
|
* @param open: Double Array, History of Open Prices ...
|
||||||
|
* @param high: Double Array, History of High Prices ...
|
||||||
|
* @param low: Double Array, History of Low Prices ...
|
||||||
|
* @param close: Double Array, History of Close Prices ...
|
||||||
|
* @param tick_volume: Long, History of Tick Volumes on Bar ...
|
||||||
|
* @param volume: Long, History of Trade Volumes ...
|
||||||
|
* @param spread: Double, History of Spread Price ...
|
||||||
|
*
|
||||||
|
* @return ( int )
|
||||||
|
*/
|
||||||
|
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[] //
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Prepare Buffers ...
|
||||||
|
ArraySetAsSeries(time, true);
|
||||||
|
ArraySetAsSeries(open, true);
|
||||||
|
ArraySetAsSeries(high, true);
|
||||||
|
ArraySetAsSeries(low, true);
|
||||||
|
ArraySetAsSeries(close, true);
|
||||||
|
ArraySetAsSeries(tick_volume, true);
|
||||||
|
ArraySetAsSeries(volume, true);
|
||||||
|
ArraySetAsSeries(spread, true);
|
||||||
|
|
||||||
|
//
|
||||||
|
limit = (prev_calculated > rates_total || prev_calculated <= 0)
|
||||||
|
? rates_total
|
||||||
|
: (rates_total - prev_calculated) + 1;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Main Loop ...
|
||||||
|
for (int i = limit - 1; i >= 0 && !IsStopped(); i--)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
CalculateBuffers(
|
||||||
|
i,
|
||||||
|
prev_calculated,
|
||||||
|
rates_total,
|
||||||
|
//
|
||||||
|
open,
|
||||||
|
high,
|
||||||
|
close,
|
||||||
|
low,
|
||||||
|
tick_volume //
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
return rates_total;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Functions ...
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Validate Input Args for Initialization ...
|
||||||
|
*
|
||||||
|
* @return ( bool )
|
||||||
|
*/
|
||||||
|
bool ValidateInputs()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
bool result = false;
|
||||||
|
|
||||||
|
//
|
||||||
|
result =
|
||||||
|
//
|
||||||
|
swingLength > 0
|
||||||
|
//
|
||||||
|
;
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extract Max Length of Inputs ...
|
||||||
|
*
|
||||||
|
* @return ( int )
|
||||||
|
*/
|
||||||
|
int ExtractMaxLengthOfInputs()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
int result = 0;
|
||||||
|
|
||||||
|
//
|
||||||
|
result = MathMax(result, swingLength);
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Define Required Buffers ...
|
||||||
|
*/
|
||||||
|
void DefineBuffers()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Plot Buffers ...
|
||||||
|
|
||||||
|
//
|
||||||
|
// SWING Low ...
|
||||||
|
|
||||||
|
//
|
||||||
|
ENUM_DRAW_TYPE swingLowDrawType = showSwingLow ? DRAW_ARROW : DRAW_NONE;
|
||||||
|
|
||||||
|
//
|
||||||
|
ArraySetAsSeries(swingLowBuffer, true);
|
||||||
|
SetIndexBuffer(swingLowBufferIndex, swingLowBuffer, INDICATOR_DATA);
|
||||||
|
|
||||||
|
//
|
||||||
|
PlotIndexSetInteger(swingLowBufferIndex, PLOT_SHOW_DATA, showSwingLow);
|
||||||
|
PlotIndexSetInteger(swingLowBufferIndex, PLOT_DRAW_TYPE, swingLowDrawType);
|
||||||
|
|
||||||
|
//
|
||||||
|
PlotIndexSetDouble(swingLowBufferIndex, PLOT_EMPTY_VALUE, emptyValue);
|
||||||
|
PlotIndexSetInteger(swingLowBufferIndex, PLOT_ARROW, swingLowArrowCode);
|
||||||
|
|
||||||
|
//
|
||||||
|
// SWING High ...
|
||||||
|
|
||||||
|
//
|
||||||
|
ENUM_DRAW_TYPE swingHighDrawType = showSwingHigh ? DRAW_ARROW : DRAW_NONE;
|
||||||
|
|
||||||
|
//
|
||||||
|
ArraySetAsSeries(swingHighBuffer, true);
|
||||||
|
SetIndexBuffer(swingHighBufferIndex, swingHighBuffer, INDICATOR_DATA);
|
||||||
|
|
||||||
|
//
|
||||||
|
PlotIndexSetInteger(swingHighBufferIndex, PLOT_SHOW_DATA, showSwingHigh);
|
||||||
|
PlotIndexSetInteger(swingHighBufferIndex, PLOT_DRAW_TYPE, swingHighDrawType);
|
||||||
|
|
||||||
|
//
|
||||||
|
PlotIndexSetDouble(swingHighBufferIndex, PLOT_EMPTY_VALUE, emptyValue);
|
||||||
|
PlotIndexSetInteger(swingHighBufferIndex, PLOT_ARROW, swingHighArrowCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set Indicator Short Name and also we can define Buffers Labels ...
|
||||||
|
*/
|
||||||
|
void SetIndicatorName()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
IndicatorSetInteger(INDICATOR_DIGITS, _Digits);
|
||||||
|
IndicatorSetString(INDICATOR_SHORTNAME, ShortName);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fill All Bufers to Zero Vlue for Specified Bar Index ...
|
||||||
|
*
|
||||||
|
* @param barIndex: Integer ...
|
||||||
|
*/
|
||||||
|
void FillBuffersZero(int barIndex)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
swingLowBuffer[barIndex] = emptyValue;
|
||||||
|
swingHighBuffer[barIndex] = emptyValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calculate Custom Buffers ...
|
||||||
|
*
|
||||||
|
* @param bar_index: Integer, Represent Current Bar ...
|
||||||
|
* @param prevCalculated: Integer, Represent Previous Calculated Bars ...
|
||||||
|
* @param ratesTotal: Integer, Represents All Available Bars ...
|
||||||
|
* @param open: Double Array, History of Open Prices ...
|
||||||
|
* @param high: Double Array, History of High Prices ...
|
||||||
|
* @param close: Double Array, History of Close Prices ...
|
||||||
|
* @param low: Double Array, History of Low Prices ...
|
||||||
|
* @param tickVolume: Long, History of Tick Volumes on Bar ...
|
||||||
|
*/
|
||||||
|
void CalculateBuffers(
|
||||||
|
int bar_index, // Selected Bar Index
|
||||||
|
const int prevCalculated,
|
||||||
|
const int ratesTotal,
|
||||||
|
const double &open[],
|
||||||
|
const double &high[],
|
||||||
|
const double &close[],
|
||||||
|
const double &low[],
|
||||||
|
const long &tickVolume[] //
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
int barsLimit = startCalculationForLastBars > 0
|
||||||
|
? startCalculationForLastBars
|
||||||
|
: 0;
|
||||||
|
if (barsLimit == 0)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
barsLimit = ratesTotal;
|
||||||
|
firstBarIndex = barsLimit - 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//
|
||||||
|
firstBarIndex = startCalculationForLastBars;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// bool canCalculate = true;
|
||||||
|
bool canCalculate =
|
||||||
|
bar_index <= barsLimit;
|
||||||
|
if (canCalculate)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Calculate Support nad Resistance ...
|
||||||
|
CalculateValues(
|
||||||
|
bar_index,
|
||||||
|
prevCalculated,
|
||||||
|
ratesTotal,
|
||||||
|
open,
|
||||||
|
high,
|
||||||
|
close,
|
||||||
|
low,
|
||||||
|
tickVolume //
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
FillBuffersZero(bar_index);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calculate Values ...
|
||||||
|
*
|
||||||
|
* @param bar_index: int, Specified Bar Index ...
|
||||||
|
* @param prevCalculated: int, Provides Previous Calculated Bars ...
|
||||||
|
* @param ratesTotal: int, Provides All Availabled Bars ...
|
||||||
|
* @param open: double Collection, Provides Open Prices Time Series ...
|
||||||
|
* @param high: double Collection, Provides High Prices Time Series ...
|
||||||
|
* @param close: double Collection, Provides Close Prices Time Series ...
|
||||||
|
* @param low: double Collection, Provides Low Prices Time Series ...
|
||||||
|
* @param tickVolume: long Collection, Provides Ticks Volume Prices Time Series ...
|
||||||
|
*/
|
||||||
|
void CalculateValues(
|
||||||
|
int bar_index, // Selected Bar Index
|
||||||
|
const int prevCalculated,
|
||||||
|
const int ratesTotal,
|
||||||
|
const double &open[],
|
||||||
|
const double &high[],
|
||||||
|
const double &close[],
|
||||||
|
const double &low[],
|
||||||
|
const long &tickVolume[] //
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Check Prev Bar ...
|
||||||
|
//
|
||||||
|
int lastBarIndex = bar_index + 1;
|
||||||
|
bool isFirstBar =
|
||||||
|
startCalculationForLastBars > 0
|
||||||
|
? bar_index == startCalculationForLastBars
|
||||||
|
: bar_index == firstBarIndex;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Reading Last Values ...
|
||||||
|
|
||||||
|
//
|
||||||
|
double iSWLPrev =
|
||||||
|
isFirstBar
|
||||||
|
? emptyValue
|
||||||
|
: swingLowBuffer[lastBarIndex];
|
||||||
|
|
||||||
|
//
|
||||||
|
double iSWHPrev =
|
||||||
|
isFirstBar
|
||||||
|
? emptyValue
|
||||||
|
: swingHighBuffer[lastBarIndex];
|
||||||
|
|
||||||
|
//
|
||||||
|
// Checking Swings ...
|
||||||
|
bool isSwingLow = IsSwingLow(high, low, bar_index, swingLength);
|
||||||
|
bool isSwingHigh = IsSwingHigh(high, low, bar_index, swingLength);
|
||||||
|
bool hasSwing = isSwingLow ||
|
||||||
|
isSwingHigh;
|
||||||
|
if (!hasSwing)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// FillBuffersZero(bar_index);
|
||||||
|
|
||||||
|
//
|
||||||
|
swingLowBuffer[bar_index] = iSWLPrev;
|
||||||
|
swingHighBuffer[bar_index] = iSWHPrev;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
double iSWL = low[bar_index];
|
||||||
|
double iSWH = high[bar_index];
|
||||||
|
|
||||||
|
//
|
||||||
|
// Act Based on Swing High or Swing Low Detection ...
|
||||||
|
if (isSwingLow && !isSwingHigh)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Detect Swing High based On swing Low ...
|
||||||
|
iSWH = iSWHPrev;
|
||||||
|
}
|
||||||
|
else if (isSwingHigh && !isSwingLow)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Detect Swing Low Based On Swing High ...
|
||||||
|
iSWL = iSWLPrev;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
if (iSWL > iSWLPrev && iSWH == iSWHPrev)
|
||||||
|
{
|
||||||
|
iSWL = iSWLPrev;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
if (iSWH < iSWHPrev && iSWL == iSWLPrev)
|
||||||
|
{
|
||||||
|
iSWH = iSWHPrev;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
swingLowBuffer[bar_index] = iSWL;
|
||||||
|
swingHighBuffer[bar_index] = iSWH;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Helpers ...
|
||||||
|
|
||||||
|
//
|
||||||
|
bool IsSwingLow(
|
||||||
|
const double &high[],
|
||||||
|
const double &low[],
|
||||||
|
int index,
|
||||||
|
int length //
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
bool result = false;
|
||||||
|
|
||||||
|
//
|
||||||
|
result = index + 1 + length <= firstBarIndex;
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
for (int i = index + 1; i <= index + length; i++)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
result = low[index] < low[i];
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
bool IsSwingHigh(
|
||||||
|
const double &high[],
|
||||||
|
const double &low[],
|
||||||
|
int index,
|
||||||
|
int length //
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
bool result = false;
|
||||||
|
|
||||||
|
//
|
||||||
|
result = index + 1 + length <= firstBarIndex;
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
for (int i = index + 1; i <= index + length; i++)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
result = high[index] > high[i];
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
@@ -49,20 +49,22 @@ enum ENUM_X121_XCA_BUFFERS
|
|||||||
X121_XCA_FIBO_L1_LINE = 14,
|
X121_XCA_FIBO_L1_LINE = 14,
|
||||||
X121_XCA_FIBO_L2_LINE = 15,
|
X121_XCA_FIBO_L2_LINE = 15,
|
||||||
X121_XCA_FIBO_L3_LINE = 16,
|
X121_XCA_FIBO_L3_LINE = 16,
|
||||||
X121_XCA_SAR_LINE = 17,
|
X121_XCA_FIBO_L4_LINE = 17,
|
||||||
X121_XCA_TREND_LINE = 18,
|
X121_XCA_FIBO_L5_LINE = 18,
|
||||||
X121_XCA_KI_LINE = 20,
|
X121_XCA_SAR_LINE = 19,
|
||||||
X121_XCA_SWING_LOW_LINE = 22,
|
X121_XCA_TREND_LINE = 20,
|
||||||
X121_XCA_SWING_HIGH_LINE = 23,
|
X121_XCA_KI_LINE = 22,
|
||||||
X121_XCA_TKI_LINE = 24,
|
X121_XCA_SWING_LOW_LINE = 24,
|
||||||
X121_XCA_VIDYA_LINE = 26,
|
X121_XCA_SWING_HIGH_LINE = 25,
|
||||||
X121_XCA_MAH_LINE = 28,
|
X121_XCA_TKI_LINE = 26,
|
||||||
X121_XCA_MAL_LINE = 29,
|
X121_XCA_VIDYA_LINE = 28,
|
||||||
X121_XCA_MAC_LINE = 30,
|
X121_XCA_MAH_LINE = 30,
|
||||||
X121_XCA_TREND_STATE_LINE = 31,
|
X121_XCA_MAL_LINE = 31,
|
||||||
X121_XCA_KI_STATE_LINE = 32,
|
X121_XCA_MAC_LINE = 32,
|
||||||
X121_XCA_TKI_STATE_LINE = 33,
|
X121_XCA_TREND_STATE_LINE = 33,
|
||||||
X121_XCA_VIDYA_STATE_LINE = 34,
|
X121_XCA_KI_STATE_LINE = 34,
|
||||||
|
X121_XCA_TKI_STATE_LINE = 35,
|
||||||
|
X121_XCA_VIDYA_STATE_LINE = 36,
|
||||||
};
|
};
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -106,6 +108,8 @@ struct X121XCAInputs
|
|||||||
ENUM_X_FIBO_LEVELS fiboLevel1; // Fibo Level 1
|
ENUM_X_FIBO_LEVELS fiboLevel1; // Fibo Level 1
|
||||||
ENUM_X_FIBO_LEVELS fiboLevel2; // Fibo Level 2
|
ENUM_X_FIBO_LEVELS fiboLevel2; // Fibo Level 2
|
||||||
ENUM_X_FIBO_LEVELS fiboLevel3; // Fibo Level 3
|
ENUM_X_FIBO_LEVELS fiboLevel3; // Fibo Level 3
|
||||||
|
ENUM_X_FIBO_LEVELS fiboLevel4; // Fibo Level 4
|
||||||
|
ENUM_X_FIBO_LEVELS fiboLevel5; // Fibo Level 5
|
||||||
|
|
||||||
//
|
//
|
||||||
// Sar Detection ...
|
// Sar Detection ...
|
||||||
@@ -155,13 +159,17 @@ struct X121XCAInputs
|
|||||||
bool showFiboLevel1; // Show Fibo Level 1
|
bool showFiboLevel1; // Show Fibo Level 1
|
||||||
bool showFiboLevel2; // Show Fibo Level 2
|
bool showFiboLevel2; // Show Fibo Level 2
|
||||||
bool showFiboLevel3; // Show Fibo Level 3
|
bool showFiboLevel3; // Show Fibo Level 3
|
||||||
|
bool showFiboLevel4; // Show Fibo Level 4
|
||||||
|
bool showFiboLevel5; // Show Fibo Level 5
|
||||||
bool showPeaksAndVales; // Show Peaks And Vales
|
bool showPeaksAndVales; // Show Peaks And Vales
|
||||||
bool showPeakAndValeGolden; // Show Peak and Vale Golden
|
bool showPeakAndValeGolden; // Show Peak and Vale Golden
|
||||||
bool showSupportAndResistance; // Show Support and Resistance
|
bool showSupportAndResistance; // Show Support and Resistance
|
||||||
bool showShortCycle; // Show Short Cycle
|
|
||||||
bool showMediumCycle; // Show Medium Cycle
|
//
|
||||||
bool showLongCycle; // Show Long Cycle
|
bool showShortCycle; // Show Short Cycle
|
||||||
bool showHindCycle; // Show Hind Cycle
|
bool showMediumCycle; // Show Medium Cycle
|
||||||
|
bool showLongCycle; // Show Long Cycle
|
||||||
|
bool showHindCycle; // Show Hind Cycle
|
||||||
|
|
||||||
//
|
//
|
||||||
int sarArrowCode; // Parabolic Sar Arrow Code
|
int sarArrowCode; // Parabolic Sar Arrow Code
|
||||||
@@ -216,8 +224,10 @@ struct X121XCAInputs
|
|||||||
//
|
//
|
||||||
// Fibo Levels ...
|
// Fibo Levels ...
|
||||||
fiboLevel1 = X_FIBO_LEVEL_236; // Fibo Level 1
|
fiboLevel1 = X_FIBO_LEVEL_236; // Fibo Level 1
|
||||||
fiboLevel2 = X_FIBO_LEVEL_500; // Fibo Level 2
|
fiboLevel2 = X_FIBO_LEVEL_382; // Fibo Level 2
|
||||||
fiboLevel3 = X_FIBO_LEVEL_764; // Fibo Level 3
|
fiboLevel3 = X_FIBO_LEVEL_500; // Fibo Level 3
|
||||||
|
fiboLevel4 = X_FIBO_LEVEL_618; // Fibo Level 4
|
||||||
|
fiboLevel5 = X_FIBO_LEVEL_764; // Fibo Level 5
|
||||||
|
|
||||||
//
|
//
|
||||||
// Sar Detection ...
|
// Sar Detection ...
|
||||||
@@ -267,13 +277,17 @@ struct X121XCAInputs
|
|||||||
showFiboLevel1 = false; // Show Fibo Level 1
|
showFiboLevel1 = false; // Show Fibo Level 1
|
||||||
showFiboLevel2 = false; // Show Fibo Level 2
|
showFiboLevel2 = false; // Show Fibo Level 2
|
||||||
showFiboLevel3 = false; // Show Fibo Level 3
|
showFiboLevel3 = false; // Show Fibo Level 3
|
||||||
|
showFiboLevel4 = false; // Show Fibo Level 4
|
||||||
|
showFiboLevel5 = false; // Show Fibo Level 5
|
||||||
showPeaksAndVales = false; // Show Peaks And Vales
|
showPeaksAndVales = false; // Show Peaks And Vales
|
||||||
showPeakAndValeGolden = false; // Show Peak and Vale Golden
|
showPeakAndValeGolden = false; // Show Peak and Vale Golden
|
||||||
showSupportAndResistance = false; // Show Support and Resistance
|
showSupportAndResistance = false; // Show Support and Resistance
|
||||||
showShortCycle = false; // Show Short Cycle
|
|
||||||
showMediumCycle = false; // Show Medium Cycle
|
//
|
||||||
showLongCycle = false; // Show Long Cycle
|
showShortCycle = false; // Show Short Cycle
|
||||||
showHindCycle = false; // Show Hind Cycle
|
showMediumCycle = false; // Show Medium Cycle
|
||||||
|
showLongCycle = false; // Show Long Cycle
|
||||||
|
showHindCycle = false; // Show Hind Cycle
|
||||||
|
|
||||||
//
|
//
|
||||||
sarArrowCode = 0; // Parabolic Sar Arrow Code
|
sarArrowCode = 0; // Parabolic Sar Arrow Code
|
||||||
@@ -321,8 +335,10 @@ struct X121XCAInputs
|
|||||||
//
|
//
|
||||||
// Fibo Levels ...
|
// Fibo Levels ...
|
||||||
fiboLevel1 = X_FIBO_LEVEL_236; // Fibo Level 1
|
fiboLevel1 = X_FIBO_LEVEL_236; // Fibo Level 1
|
||||||
fiboLevel2 = X_FIBO_LEVEL_500; // Fibo Level 2
|
fiboLevel2 = X_FIBO_LEVEL_382; // Fibo Level 2
|
||||||
fiboLevel3 = X_FIBO_LEVEL_764; // Fibo Level 3
|
fiboLevel3 = X_FIBO_LEVEL_500; // Fibo Level 3
|
||||||
|
fiboLevel4 = X_FIBO_LEVEL_618; // Fibo Level 4
|
||||||
|
fiboLevel5 = X_FIBO_LEVEL_764; // Fibo Level 5
|
||||||
|
|
||||||
//
|
//
|
||||||
// Sar Detection ...
|
// Sar Detection ...
|
||||||
@@ -367,13 +383,17 @@ struct X121XCAInputs
|
|||||||
showFiboLevel1 = true; // Show Fibo Level 1
|
showFiboLevel1 = true; // Show Fibo Level 1
|
||||||
showFiboLevel2 = true; // Show Fibo Level 2
|
showFiboLevel2 = true; // Show Fibo Level 2
|
||||||
showFiboLevel3 = true; // Show Fibo Level 3
|
showFiboLevel3 = true; // Show Fibo Level 3
|
||||||
|
showFiboLevel4 = true; // Show Fibo Level 4
|
||||||
|
showFiboLevel5 = true; // Show Fibo Level 5
|
||||||
showPeaksAndVales = true; // Show Peaks And Vales
|
showPeaksAndVales = true; // Show Peaks And Vales
|
||||||
showPeakAndValeGolden = true; // Show Peak and Vale Golden
|
showPeakAndValeGolden = true; // Show Peak and Vale Golden
|
||||||
showSupportAndResistance = true; // Show Support and Resistance
|
showSupportAndResistance = true; // Show Support and Resistance
|
||||||
showShortCycle = true; // Show Short Cycle
|
|
||||||
showMediumCycle = true; // Show Medium Cycle
|
//
|
||||||
showLongCycle = true; // Show Long Cycle
|
showShortCycle = true; // Show Short Cycle
|
||||||
showHindCycle = true; // Show Hind Cycle
|
showMediumCycle = true; // Show Medium Cycle
|
||||||
|
showLongCycle = true; // Show Long Cycle
|
||||||
|
showHindCycle = true; // Show Hind Cycle
|
||||||
|
|
||||||
//
|
//
|
||||||
sarArrowCode = 159; // Parabolic Sar Arrow Code
|
sarArrowCode = 159; // Parabolic Sar Arrow Code
|
||||||
@@ -475,6 +495,8 @@ struct X121XCAConditions
|
|||||||
double fiboLevel1Buffer[];
|
double fiboLevel1Buffer[];
|
||||||
double fiboLevel2Buffer[];
|
double fiboLevel2Buffer[];
|
||||||
double fiboLevel3Buffer[];
|
double fiboLevel3Buffer[];
|
||||||
|
double fiboLevel4Buffer[];
|
||||||
|
double fiboLevel5Buffer[];
|
||||||
double trendStateBuffer[];
|
double trendStateBuffer[];
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -776,6 +798,8 @@ struct X121XCAConditions
|
|||||||
Clean(fiboLevel1Buffer);
|
Clean(fiboLevel1Buffer);
|
||||||
Clean(fiboLevel2Buffer);
|
Clean(fiboLevel2Buffer);
|
||||||
Clean(fiboLevel3Buffer);
|
Clean(fiboLevel3Buffer);
|
||||||
|
Clean(fiboLevel4Buffer);
|
||||||
|
Clean(fiboLevel5Buffer);
|
||||||
Clean(vidyaStateBuffer);
|
Clean(vidyaStateBuffer);
|
||||||
Clean(trendStateBuffer);
|
Clean(trendStateBuffer);
|
||||||
|
|
||||||
@@ -809,6 +833,8 @@ struct X121XCAConditions
|
|||||||
ArraySetAsSeries(fiboLevel1Buffer, true);
|
ArraySetAsSeries(fiboLevel1Buffer, true);
|
||||||
ArraySetAsSeries(fiboLevel2Buffer, true);
|
ArraySetAsSeries(fiboLevel2Buffer, true);
|
||||||
ArraySetAsSeries(fiboLevel3Buffer, true);
|
ArraySetAsSeries(fiboLevel3Buffer, true);
|
||||||
|
ArraySetAsSeries(fiboLevel4Buffer, true);
|
||||||
|
ArraySetAsSeries(fiboLevel5Buffer, true);
|
||||||
ArraySetAsSeries(vidyaStateBuffer, true);
|
ArraySetAsSeries(vidyaStateBuffer, true);
|
||||||
ArraySetAsSeries(trendStateBuffer, true);
|
ArraySetAsSeries(trendStateBuffer, true);
|
||||||
|
|
||||||
@@ -1778,6 +1804,8 @@ class XCX121XCAHelper : public XCBaseHelper
|
|||||||
Clean(fiboLevel1Buffer);
|
Clean(fiboLevel1Buffer);
|
||||||
Clean(fiboLevel2Buffer);
|
Clean(fiboLevel2Buffer);
|
||||||
Clean(fiboLevel3Buffer);
|
Clean(fiboLevel3Buffer);
|
||||||
|
Clean(fiboLevel4Buffer);
|
||||||
|
Clean(fiboLevel5Buffer);
|
||||||
Clean(trendStateBuffer);
|
Clean(trendStateBuffer);
|
||||||
Clean(vidyaStateBuffer);
|
Clean(vidyaStateBuffer);
|
||||||
}
|
}
|
||||||
@@ -1834,6 +1862,8 @@ class XCX121XCAHelper : public XCBaseHelper
|
|||||||
ArraySetAsSeries(fiboLevel1Buffer, true);
|
ArraySetAsSeries(fiboLevel1Buffer, true);
|
||||||
ArraySetAsSeries(fiboLevel2Buffer, true);
|
ArraySetAsSeries(fiboLevel2Buffer, true);
|
||||||
ArraySetAsSeries(fiboLevel3Buffer, true);
|
ArraySetAsSeries(fiboLevel3Buffer, true);
|
||||||
|
ArraySetAsSeries(fiboLevel4Buffer, true);
|
||||||
|
ArraySetAsSeries(fiboLevel5Buffer, true);
|
||||||
ArraySetAsSeries(vidyaStateBuffer, true);
|
ArraySetAsSeries(vidyaStateBuffer, true);
|
||||||
ArraySetAsSeries(trendStateBuffer, true);
|
ArraySetAsSeries(trendStateBuffer, true);
|
||||||
|
|
||||||
@@ -1865,6 +1895,8 @@ class XCX121XCAHelper : public XCBaseHelper
|
|||||||
mInputs.fiboLevel1,
|
mInputs.fiboLevel1,
|
||||||
mInputs.fiboLevel2,
|
mInputs.fiboLevel2,
|
||||||
mInputs.fiboLevel3,
|
mInputs.fiboLevel3,
|
||||||
|
mInputs.fiboLevel4,
|
||||||
|
mInputs.fiboLevel5,
|
||||||
"", // Sar Detection ...
|
"", // Sar Detection ...
|
||||||
mInputs.sarStep,
|
mInputs.sarStep,
|
||||||
mInputs.sarMax,
|
mInputs.sarMax,
|
||||||
@@ -1896,13 +1928,15 @@ class XCX121XCAHelper : public XCBaseHelper
|
|||||||
mInputs.showFiboLevel1,
|
mInputs.showFiboLevel1,
|
||||||
mInputs.showFiboLevel2,
|
mInputs.showFiboLevel2,
|
||||||
mInputs.showFiboLevel3,
|
mInputs.showFiboLevel3,
|
||||||
|
mInputs.showFiboLevel4,
|
||||||
|
mInputs.showFiboLevel5,
|
||||||
mInputs.showPeaksAndVales,
|
mInputs.showPeaksAndVales,
|
||||||
mInputs.showPeakAndValeGolden,
|
mInputs.showPeakAndValeGolden,
|
||||||
mInputs.showSupportAndResistance,
|
mInputs.showSupportAndResistance //
|
||||||
mInputs.showShortCycle,
|
// mInputs.showShortCycle,
|
||||||
mInputs.showMediumCycle,
|
// mInputs.showMediumCycle,
|
||||||
mInputs.showLongCycle,
|
// mInputs.showLongCycle,
|
||||||
mInputs.showHindCycle // ,
|
// mInputs.showHindCycle // ,
|
||||||
//
|
//
|
||||||
// mInputs.sarArrowCode,
|
// mInputs.sarArrowCode,
|
||||||
// mInputs.peakArrowCode,
|
// mInputs.peakArrowCode,
|
||||||
@@ -3574,6 +3608,110 @@ class XCX121XCAHelper : public XCBaseHelper
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// FIBO Level 4 ...
|
||||||
|
|
||||||
|
//
|
||||||
|
double GetFiboLevel4(
|
||||||
|
int barIndex // Bar Index
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
if (barIndex < 0)
|
||||||
|
{
|
||||||
|
barIndex = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
Calculate(barIndex);
|
||||||
|
|
||||||
|
//
|
||||||
|
int count = ArraySize(fiboLevel4Buffer);
|
||||||
|
if (barIndex >= count)
|
||||||
|
{
|
||||||
|
barIndex = count - 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
return fiboLevel4Buffer[barIndex];
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
int CopyFiboLevel4(
|
||||||
|
int start, // Start
|
||||||
|
int count, // Number of Items for read
|
||||||
|
double &buffer[], // Dest Buffer
|
||||||
|
bool forceClean = true // Force To Clean buffer
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Update Calculations ...
|
||||||
|
Calculate(start);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Copy Items ...
|
||||||
|
return Copy(
|
||||||
|
0,
|
||||||
|
count,
|
||||||
|
fiboLevel4Buffer,
|
||||||
|
buffer,
|
||||||
|
forceClean
|
||||||
|
//
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// FIBO Level 5 ...
|
||||||
|
|
||||||
|
//
|
||||||
|
double GetFiboLevel5(
|
||||||
|
int barIndex // Bar Index
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
if (barIndex < 0)
|
||||||
|
{
|
||||||
|
barIndex = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
Calculate(barIndex);
|
||||||
|
|
||||||
|
//
|
||||||
|
int count = ArraySize(fiboLevel5Buffer);
|
||||||
|
if (barIndex >= count)
|
||||||
|
{
|
||||||
|
barIndex = count - 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
return fiboLevel5Buffer[barIndex];
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
int CopyFiboLevel5(
|
||||||
|
int start, // Start
|
||||||
|
int count, // Number of Items for read
|
||||||
|
double &buffer[], // Dest Buffer
|
||||||
|
bool forceClean = true // Force To Clean buffer
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Update Calculations ...
|
||||||
|
Calculate(start);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Copy Items ...
|
||||||
|
return Copy(
|
||||||
|
0,
|
||||||
|
count,
|
||||||
|
fiboLevel5Buffer,
|
||||||
|
buffer,
|
||||||
|
forceClean
|
||||||
|
//
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
void Free() override
|
void Free() override
|
||||||
{
|
{
|
||||||
@@ -3866,6 +4004,20 @@ class XCX121XCAHelper : public XCBaseHelper
|
|||||||
conditions.fiboLevel3Buffer //
|
conditions.fiboLevel3Buffer //
|
||||||
);
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
CopyFiboLevel4(
|
||||||
|
zIndex,
|
||||||
|
loopback,
|
||||||
|
conditions.fiboLevel4Buffer //
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
CopyFiboLevel5(
|
||||||
|
zIndex,
|
||||||
|
loopback,
|
||||||
|
conditions.fiboLevel5Buffer //
|
||||||
|
);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Conditions ...
|
// Conditions ...
|
||||||
|
|
||||||
@@ -4566,6 +4718,8 @@ class XCX121XCAHelper : public XCBaseHelper
|
|||||||
double fiboLevel1Buffer[];
|
double fiboLevel1Buffer[];
|
||||||
double fiboLevel2Buffer[];
|
double fiboLevel2Buffer[];
|
||||||
double fiboLevel3Buffer[];
|
double fiboLevel3Buffer[];
|
||||||
|
double fiboLevel4Buffer[];
|
||||||
|
double fiboLevel5Buffer[];
|
||||||
double vidyaStateBuffer[];
|
double vidyaStateBuffer[];
|
||||||
double trendStateBuffer[];
|
double trendStateBuffer[];
|
||||||
|
|
||||||
@@ -4852,6 +5006,24 @@ class XCX121XCAHelper : public XCBaseHelper
|
|||||||
fiboLevel3Buffer //
|
fiboLevel3Buffer //
|
||||||
);
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
CopyBuffer(
|
||||||
|
mHandler,
|
||||||
|
X121_XCA_FIBO_L4_LINE,
|
||||||
|
barIndex,
|
||||||
|
maxRequiredBars,
|
||||||
|
fiboLevel4Buffer //
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
CopyBuffer(
|
||||||
|
mHandler,
|
||||||
|
X121_XCA_FIBO_L5_LINE,
|
||||||
|
barIndex,
|
||||||
|
maxRequiredBars,
|
||||||
|
fiboLevel5Buffer //
|
||||||
|
);
|
||||||
|
|
||||||
//
|
//
|
||||||
CopyBuffer(
|
CopyBuffer(
|
||||||
mHandler,
|
mHandler,
|
||||||
@@ -5047,6 +5219,18 @@ class XCX121XCAHelper : public XCBaseHelper
|
|||||||
maxAllowed //
|
maxAllowed //
|
||||||
);
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
CleanupArray(
|
||||||
|
fiboLevel4Buffer,
|
||||||
|
maxAllowed //
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
CleanupArray(
|
||||||
|
fiboLevel5Buffer,
|
||||||
|
maxAllowed //
|
||||||
|
);
|
||||||
|
|
||||||
//
|
//
|
||||||
CleanupArray(
|
CleanupArray(
|
||||||
trendStateBuffer,
|
trendStateBuffer,
|
||||||
|
|||||||
@@ -0,0 +1,286 @@
|
|||||||
|
//+------------------------------------------------------------------+
|
||||||
|
//| ForexSessionDetector.mq5 |
|
||||||
|
//| Copyright 2023, MetaQuotes Software Corp. |
|
||||||
|
//| https://www.metaquotes.net/ |
|
||||||
|
//+------------------------------------------------------------------+
|
||||||
|
#property copyright "Copyright 2023, MetaQuotes Software Corp."
|
||||||
|
#property link "https://www.metaquotes.net/"
|
||||||
|
#property version "1.00"
|
||||||
|
#property indicator_chart_window
|
||||||
|
#property indicator_buffers 0
|
||||||
|
#property indicator_plots 0
|
||||||
|
|
||||||
|
//+------------------------------------------------------------------+
|
||||||
|
//| Session Times |
|
||||||
|
//+------------------------------------------------------------------+
|
||||||
|
input color SydneyColor = clrRoyalBlue; // Sydney session color
|
||||||
|
input color TokyoColor = clrGreen; // Tokyo session color
|
||||||
|
input color LondonColor = clrRed; // London session color
|
||||||
|
input color NewYorkColor = clrDodgerBlue; // New York session color
|
||||||
|
input int TextSize = 8; // Font size
|
||||||
|
input bool ShowHighLow = true; // Show High/Low prices
|
||||||
|
input bool ShowSessionTimes = true; // Show Session Times
|
||||||
|
|
||||||
|
//+------------------------------------------------------------------+
|
||||||
|
//| Global Variables |
|
||||||
|
//+------------------------------------------------------------------+
|
||||||
|
struct SessionInfo
|
||||||
|
{
|
||||||
|
string name;
|
||||||
|
int startHour;
|
||||||
|
int startMinute;
|
||||||
|
int endHour;
|
||||||
|
int endMinute;
|
||||||
|
color clr;
|
||||||
|
datetime sessionStart;
|
||||||
|
datetime sessionEnd;
|
||||||
|
double high;
|
||||||
|
double low;
|
||||||
|
bool active;
|
||||||
|
};
|
||||||
|
|
||||||
|
SessionInfo sessions[4];
|
||||||
|
string fontFace = "Arial";
|
||||||
|
|
||||||
|
//+------------------------------------------------------------------+
|
||||||
|
//| Custom indicator initialization function |
|
||||||
|
//+------------------------------------------------------------------+
|
||||||
|
int OnInit()
|
||||||
|
{
|
||||||
|
// Initialize session information
|
||||||
|
sessions[0].name = "Sydney";
|
||||||
|
sessions[0].startHour = 22;
|
||||||
|
sessions[0].startMinute = 0;
|
||||||
|
sessions[0].endHour = 6;
|
||||||
|
sessions[0].endMinute = 0;
|
||||||
|
sessions[0].clr = SydneyColor;
|
||||||
|
|
||||||
|
sessions[1].name = "Tokyo";
|
||||||
|
sessions[1].startHour = 0;
|
||||||
|
sessions[1].startMinute = 0;
|
||||||
|
sessions[1].endHour = 9;
|
||||||
|
sessions[1].endMinute = 0;
|
||||||
|
sessions[1].clr = TokyoColor;
|
||||||
|
|
||||||
|
sessions[2].name = "London";
|
||||||
|
sessions[2].startHour = 8;
|
||||||
|
sessions[2].startMinute = 0;
|
||||||
|
sessions[2].endHour = 17;
|
||||||
|
sessions[2].endMinute = 0;
|
||||||
|
sessions[2].clr = LondonColor;
|
||||||
|
|
||||||
|
sessions[3].name = "New York";
|
||||||
|
sessions[3].startHour = 13;
|
||||||
|
sessions[3].startMinute = 0;
|
||||||
|
sessions[3].endHour = 22;
|
||||||
|
sessions[3].endMinute = 0;
|
||||||
|
sessions[3].clr = NewYorkColor;
|
||||||
|
|
||||||
|
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[])
|
||||||
|
{
|
||||||
|
// Clear previous objects
|
||||||
|
ObjectsDeleteAll(0, "Session_");
|
||||||
|
|
||||||
|
// Process each session
|
||||||
|
for (int i = 0; i < 4; i++)
|
||||||
|
{
|
||||||
|
ProcessSession(i, time, high, low, rates_total);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (rates_total);
|
||||||
|
}
|
||||||
|
|
||||||
|
//+------------------------------------------------------------------+
|
||||||
|
//| Process a single session |
|
||||||
|
//+------------------------------------------------------------------+
|
||||||
|
void ProcessSession(int sessionIndex, const datetime &time[], const double &high[], const double &low[], int rates_total)
|
||||||
|
{
|
||||||
|
SessionInfo session = sessions[sessionIndex];
|
||||||
|
|
||||||
|
// Find current session start and end times
|
||||||
|
datetime currentTime = TimeCurrent();
|
||||||
|
MqlDateTime currentTimeStruct;
|
||||||
|
TimeToStruct(currentTime, currentTimeStruct);
|
||||||
|
|
||||||
|
datetime sessionStart, sessionEnd;
|
||||||
|
|
||||||
|
// Handle sessions that span midnight
|
||||||
|
if (session.startHour > session.endHour)
|
||||||
|
{
|
||||||
|
// Session spans midnight (e.g., Sydney 22:00-6:00)
|
||||||
|
if (currentTimeStruct.hour >= session.startHour || currentTimeStruct.hour < session.endHour)
|
||||||
|
{
|
||||||
|
sessionStart = StructToTime(currentTimeStruct.year, currentTimeStruct.mon, currentTimeStruct.day, session.startHour, session.startMinute, 0);
|
||||||
|
if (currentTimeStruct.hour < session.startHour)
|
||||||
|
sessionStart -= 86400; // Previous day
|
||||||
|
sessionEnd = sessionStart + (session.endHour - session.startHour) * 3600 + (session.endMinute - session.startMinute) * 60;
|
||||||
|
if (sessionEnd <= sessionStart)
|
||||||
|
sessionEnd += 86400;
|
||||||
|
session.active = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sessionStart = StructToTime(currentTimeStruct.year, currentTimeStruct.mon, currentTimeStruct.day, session.startHour, session.startMinute, 0);
|
||||||
|
sessionEnd = sessionStart + (session.endHour - session.startHour) * 3600 + (session.endMinute - session.startMinute) * 60;
|
||||||
|
if (sessionEnd <= sessionStart)
|
||||||
|
sessionEnd += 86400;
|
||||||
|
session.active = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Normal session (doesn't span midnight)
|
||||||
|
if (currentTimeStruct.hour >= session.startHour && currentTimeStruct.hour < session.endHour)
|
||||||
|
{
|
||||||
|
sessionStart = StructToTime(currentTimeStruct.year, currentTimeStruct.mon, currentTimeStruct.day, session.startHour, session.startMinute, 0);
|
||||||
|
sessionEnd = StructToTime(currentTimeStruct.year, currentTimeStruct.mon, currentTimeStruct.day, session.endHour, session.endMinute, 0);
|
||||||
|
session.active = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sessionStart = StructToTime(currentTimeStruct.year, currentTimeStruct.mon, currentTimeStruct.day, session.startHour, session.startMinute, 0);
|
||||||
|
sessionEnd = StructToTime(currentTimeStruct.year, currentTimeStruct.mon, currentTimeStruct.day, session.endHour, session.endMinute, 0);
|
||||||
|
session.active = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
session.sessionStart = sessionStart;
|
||||||
|
session.sessionEnd = sessionEnd;
|
||||||
|
|
||||||
|
// Find high/low for the session
|
||||||
|
int startIndex = iBarShift(NULL, 0, sessionStart);
|
||||||
|
int endIndex = iBarShift(NULL, 0, sessionEnd);
|
||||||
|
|
||||||
|
if (startIndex == -1 || endIndex == -1)
|
||||||
|
return;
|
||||||
|
|
||||||
|
session.high = high[ArrayMaximum(high, endIndex, startIndex - endIndex + 1)];
|
||||||
|
session.low = low[ArrayMinimum(low, endIndex, startIndex - endIndex + 1)];
|
||||||
|
|
||||||
|
// Draw session information on chart
|
||||||
|
DrawSessionInfo(session, startIndex, endIndex, sessionIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
//+------------------------------------------------------------------+
|
||||||
|
//| Get chart window price max |
|
||||||
|
//+------------------------------------------------------------------+
|
||||||
|
double GetWindowPriceMax()
|
||||||
|
{
|
||||||
|
double maxPrice;
|
||||||
|
ChartGetDouble(0, CHART_PRICE_MAX, 0, maxPrice);
|
||||||
|
return maxPrice;
|
||||||
|
}
|
||||||
|
|
||||||
|
//+------------------------------------------------------------------+
|
||||||
|
//| Get chart window price min |
|
||||||
|
//+------------------------------------------------------------------+
|
||||||
|
double GetWindowPriceMin()
|
||||||
|
{
|
||||||
|
double minPrice;
|
||||||
|
ChartGetDouble(0, CHART_PRICE_MIN, 0, minPrice);
|
||||||
|
return minPrice;
|
||||||
|
}
|
||||||
|
|
||||||
|
//+------------------------------------------------------------------+
|
||||||
|
//| Draw session information on chart |
|
||||||
|
//+------------------------------------------------------------------+
|
||||||
|
void DrawSessionInfo(SessionInfo &session, int startIndex, int endIndex, int sessionIndex)
|
||||||
|
{
|
||||||
|
string objName;
|
||||||
|
color textColor = session.clr;
|
||||||
|
double priceMax = GetWindowPriceMax();
|
||||||
|
double priceMin = GetWindowPriceMin();
|
||||||
|
|
||||||
|
// Draw vertical lines for session start/end
|
||||||
|
objName = "Session_" + session.name + "_Start";
|
||||||
|
ObjectCreate(0, objName, OBJ_VLINE, 0, session.sessionStart, 0);
|
||||||
|
ObjectSetInteger(0, objName, OBJPROP_COLOR, session.clr);
|
||||||
|
ObjectSetInteger(0, objName, OBJPROP_STYLE, STYLE_DOT);
|
||||||
|
ObjectSetInteger(0, objName, OBJPROP_WIDTH, 1);
|
||||||
|
ObjectSetInteger(0, objName, OBJPROP_BACK, true);
|
||||||
|
|
||||||
|
objName = "Session_" + session.name + "_End";
|
||||||
|
ObjectCreate(0, objName, OBJ_VLINE, 0, session.sessionEnd, 0);
|
||||||
|
ObjectSetInteger(0, objName, OBJPROP_COLOR, session.clr);
|
||||||
|
ObjectSetInteger(0, objName, OBJPROP_STYLE, STYLE_DOT);
|
||||||
|
ObjectSetInteger(0, objName, OBJPROP_WIDTH, 1);
|
||||||
|
ObjectSetInteger(0, objName, OBJPROP_BACK, true);
|
||||||
|
|
||||||
|
// Draw session name label
|
||||||
|
if (ShowSessionTimes)
|
||||||
|
{
|
||||||
|
objName = "Session_" + session.name + "_Label";
|
||||||
|
ObjectCreate(0, objName, OBJ_TEXT, 0, session.sessionStart, priceMax - (priceMax - priceMin) * 0.1 * (sessionIndex + 1));
|
||||||
|
ObjectSetString(0, objName, OBJPROP_TEXT, session.name + " " + TimeToString(session.sessionStart, TIME_MINUTES) + " - " + TimeToString(session.sessionEnd, TIME_MINUTES));
|
||||||
|
ObjectSetInteger(0, objName, OBJPROP_COLOR, textColor);
|
||||||
|
ObjectSetInteger(0, objName, OBJPROP_FONTSIZE, TextSize);
|
||||||
|
ObjectSetString(0, objName, OBJPROP_FONT, fontFace);
|
||||||
|
ObjectSetInteger(0, objName, OBJPROP_ANCHOR, ANCHOR_LEFT_UPPER);
|
||||||
|
ObjectSetInteger(0, objName, OBJPROP_BACK, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Draw high/low prices if enabled
|
||||||
|
if (ShowHighLow)
|
||||||
|
{
|
||||||
|
objName = "Session_" + session.name + "_High";
|
||||||
|
ObjectCreate(0, objName, OBJ_TEXT, 0, session.sessionStart + (session.sessionEnd - session.sessionStart) / 2, session.high);
|
||||||
|
ObjectSetString(0, objName, OBJPROP_TEXT, "H: " + DoubleToString(session.high, _Digits));
|
||||||
|
ObjectSetInteger(0, objName, OBJPROP_COLOR, textColor);
|
||||||
|
ObjectSetInteger(0, objName, OBJPROP_FONTSIZE, TextSize);
|
||||||
|
ObjectSetString(0, objName, OBJPROP_FONT, fontFace);
|
||||||
|
ObjectSetInteger(0, objName, OBJPROP_ANCHOR, ANCHOR_LOWER);
|
||||||
|
ObjectSetInteger(0, objName, OBJPROP_BACK, false);
|
||||||
|
|
||||||
|
objName = "Session_" + session.name + "_Low";
|
||||||
|
ObjectCreate(0, objName, OBJ_TEXT, 0, session.sessionStart + (session.sessionEnd - session.sessionStart) / 2, session.low);
|
||||||
|
ObjectSetString(0, objName, OBJPROP_TEXT, "L: " + DoubleToString(session.low, _Digits));
|
||||||
|
ObjectSetInteger(0, objName, OBJPROP_COLOR, textColor);
|
||||||
|
ObjectSetInteger(0, objName, OBJPROP_FONTSIZE, TextSize);
|
||||||
|
ObjectSetString(0, objName, OBJPROP_FONT, fontFace);
|
||||||
|
ObjectSetInteger(0, objName, OBJPROP_ANCHOR, ANCHOR_UPPER);
|
||||||
|
ObjectSetInteger(0, objName, OBJPROP_BACK, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Highlight active session
|
||||||
|
if (session.active)
|
||||||
|
{
|
||||||
|
objName = "Session_" + session.name + "_Background";
|
||||||
|
ObjectCreate(0, objName, OBJ_RECTANGLE, 0, session.sessionStart, priceMax, session.sessionEnd, priceMin);
|
||||||
|
ObjectSetInteger(0, objName, OBJPROP_COLOR, session.clr);
|
||||||
|
ObjectSetInteger(0, objName, OBJPROP_BGCOLOR, session.clr);
|
||||||
|
ObjectSetInteger(0, objName, OBJPROP_BACK, true);
|
||||||
|
ObjectSetInteger(0, objName, OBJPROP_FILL, true);
|
||||||
|
ObjectSetInteger(0, objName, OBJPROP_WIDTH, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//+------------------------------------------------------------------+
|
||||||
|
//| Create datetime from components |
|
||||||
|
//+------------------------------------------------------------------+
|
||||||
|
datetime StructToTime(int year, int month, int day, int hour, int minute, int second)
|
||||||
|
{
|
||||||
|
MqlDateTime mdt;
|
||||||
|
mdt.year = year;
|
||||||
|
mdt.mon = month;
|
||||||
|
mdt.day = day;
|
||||||
|
mdt.hour = hour;
|
||||||
|
mdt.min = minute;
|
||||||
|
mdt.sec = second;
|
||||||
|
return StructToTime(mdt);
|
||||||
|
}
|
||||||
|
//+------------------------------------------------------------------+
|
||||||
+282
-133
@@ -63,8 +63,10 @@ input ENUM_SERIESMODE llMode = MODE_LOW; // Lowest Low Calculation Method
|
|||||||
//
|
//
|
||||||
input group "Fibo Levels";
|
input group "Fibo Levels";
|
||||||
input ENUM_X_FIBO_LEVELS fiboLevel1 = X_FIBO_LEVEL_236; // Fibo Level 1
|
input ENUM_X_FIBO_LEVELS fiboLevel1 = X_FIBO_LEVEL_236; // Fibo Level 1
|
||||||
input ENUM_X_FIBO_LEVELS fiboLevel2 = X_FIBO_LEVEL_500; // Fibo Level 2
|
input ENUM_X_FIBO_LEVELS fiboLevel2 = X_FIBO_LEVEL_382; // Fibo Level 2
|
||||||
input ENUM_X_FIBO_LEVELS fiboLevel3 = X_FIBO_LEVEL_764; // Fibo Level 3
|
input ENUM_X_FIBO_LEVELS fiboLevel3 = X_FIBO_LEVEL_500; // Fibo Level 3
|
||||||
|
input ENUM_X_FIBO_LEVELS fiboLevel4 = X_FIBO_LEVEL_618; // Fibo Level 4
|
||||||
|
input ENUM_X_FIBO_LEVELS fiboLevel5 = X_FIBO_LEVEL_764; // Fibo Level 5
|
||||||
|
|
||||||
//
|
//
|
||||||
input group "Sar Detection";
|
input group "Sar Detection";
|
||||||
@@ -96,8 +98,8 @@ input int swingLength = 5; // Length
|
|||||||
|
|
||||||
//
|
//
|
||||||
input group "Support and Resistance";
|
input group "Support and Resistance";
|
||||||
input int supResSmoothingLength = 7; // Smoothing Length
|
input int supResSmoothingLength = 7; // Smoothing Length
|
||||||
input ENUM_X_MA_METHOD supResSmoothingMode = X_MA_MODE_SMA; // Smoothing Method
|
input ENUM_X_MA_METHOD supResSmoothingMode = X_MA_MODE_NONE; // Smoothing Method
|
||||||
|
|
||||||
//
|
//
|
||||||
// Presentation ...
|
// Presentation ...
|
||||||
@@ -119,13 +121,17 @@ input bool showSwings = true; // Show Swings
|
|||||||
input bool showFiboLevel1 = true; // Show Fibo Level 1
|
input bool showFiboLevel1 = true; // Show Fibo Level 1
|
||||||
input bool showFiboLevel2 = true; // Show Fibo Level 2
|
input bool showFiboLevel2 = true; // Show Fibo Level 2
|
||||||
input bool showFiboLevel3 = true; // Show Fibo Level 3
|
input bool showFiboLevel3 = true; // Show Fibo Level 3
|
||||||
|
input bool showFiboLevel4 = true; // Show Fibo Level 4
|
||||||
|
input bool showFiboLevel5 = true; // Show Fibo Level 5
|
||||||
input bool showPeaksAndVales = true; // Show Peaks And Vales
|
input bool showPeaksAndVales = true; // Show Peaks And Vales
|
||||||
input bool showPeakAndValeGolden = true; // Show Peak and Vale Golden
|
input bool showPeakAndValeGolden = true; // Show Peak and Vale Golden
|
||||||
input bool showSupportAndResistance = true; // Show Support and Resistance
|
input bool showSupportAndResistance = true; // Show Support and Resistance
|
||||||
input bool showShortCycle = true; // Show Short Cycle
|
|
||||||
input bool showMediumCycle = true; // Show Medium Cycle
|
//
|
||||||
input bool showLongCycle = true; // Show Long Cycle
|
bool showShortCycle = false; // Show Short Cycle
|
||||||
input bool showHindCycle = true; // Show Hind Cycle
|
bool showMediumCycle = false; // Show Medium Cycle
|
||||||
|
bool showLongCycle = false; // Show Long Cycle
|
||||||
|
bool showHindCycle = false; // Show Hind Cycle
|
||||||
|
|
||||||
//
|
//
|
||||||
int sarArrowCode = 159; // Parabolic Sar Arrow Code
|
int sarArrowCode = 159; // Parabolic Sar Arrow Code
|
||||||
@@ -155,8 +161,8 @@ int swingHighArrowCode = 226; // Swing High Arrow Code
|
|||||||
#property indicator_chart_window
|
#property indicator_chart_window
|
||||||
|
|
||||||
//
|
//
|
||||||
#property indicator_buffers 37
|
#property indicator_buffers 39
|
||||||
#property indicator_plots 27
|
#property indicator_plots 29
|
||||||
|
|
||||||
//
|
//
|
||||||
// Plot Buffers ...
|
// Plot Buffers ...
|
||||||
@@ -367,8 +373,8 @@ double fiboLevel2Buffer[];
|
|||||||
//
|
//
|
||||||
#property indicator_label16 "Fibo L2"
|
#property indicator_label16 "Fibo L2"
|
||||||
#property indicator_type16 DRAW_LINE
|
#property indicator_type16 DRAW_LINE
|
||||||
#property indicator_color16 clrYellow
|
#property indicator_color16 clrGold
|
||||||
#property indicator_style16 STYLE_DASH
|
#property indicator_style16 STYLE_DOT
|
||||||
#property indicator_width16 1
|
#property indicator_width16 1
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -381,176 +387,204 @@ double fiboLevel3Buffer[];
|
|||||||
//
|
//
|
||||||
#property indicator_label17 "Fibo L3"
|
#property indicator_label17 "Fibo L3"
|
||||||
#property indicator_type17 DRAW_LINE
|
#property indicator_type17 DRAW_LINE
|
||||||
#property indicator_color17 clrGold
|
#property indicator_color17 clrYellow
|
||||||
#property indicator_style17 STYLE_DOT
|
#property indicator_style17 STYLE_DASH
|
||||||
#property indicator_width17 1
|
#property indicator_width17 1
|
||||||
|
|
||||||
|
//
|
||||||
|
// FIBO Level 4
|
||||||
|
|
||||||
|
//
|
||||||
|
#define fiboLevel4BufferIndex 17
|
||||||
|
double fiboLevel4Buffer[];
|
||||||
|
|
||||||
|
//
|
||||||
|
#property indicator_label18 "Fibo L4"
|
||||||
|
#property indicator_type18 DRAW_LINE
|
||||||
|
#property indicator_color18 clrGold
|
||||||
|
#property indicator_style18 STYLE_DOT
|
||||||
|
#property indicator_width18 1
|
||||||
|
|
||||||
|
//
|
||||||
|
// FIBO Level 5
|
||||||
|
|
||||||
|
//
|
||||||
|
#define fiboLevel5BufferIndex 18
|
||||||
|
double fiboLevel5Buffer[];
|
||||||
|
|
||||||
|
//
|
||||||
|
#property indicator_label19 "Fibo L5"
|
||||||
|
#property indicator_type19 DRAW_LINE
|
||||||
|
#property indicator_color19 clrGold
|
||||||
|
#property indicator_style19 STYLE_DOT
|
||||||
|
#property indicator_width19 1
|
||||||
|
|
||||||
//
|
//
|
||||||
// SAR ...
|
// SAR ...
|
||||||
|
|
||||||
//
|
//
|
||||||
#define sarBufferIndex 17
|
#define sarBufferIndex 19
|
||||||
double sarBuffer[];
|
double sarBuffer[];
|
||||||
|
|
||||||
//
|
//
|
||||||
#property indicator_label18 "SAR"
|
#property indicator_label20 "SAR"
|
||||||
#property indicator_type18 DRAW_ARROW
|
#property indicator_type20 DRAW_ARROW
|
||||||
#property indicator_color18 clrYellow
|
#property indicator_color20 clrYellow
|
||||||
#property indicator_width18 1
|
#property indicator_width20 1
|
||||||
|
|
||||||
//
|
//
|
||||||
// TREND ...
|
// TREND ...
|
||||||
|
|
||||||
//
|
//
|
||||||
#define trendBufferIndex 18
|
#define trendBufferIndex 20
|
||||||
#define trendBufferPlotIndex 18
|
#define trendBufferPlotIndex 20
|
||||||
double trendBuffer[];
|
double trendBuffer[];
|
||||||
|
|
||||||
//
|
//
|
||||||
#define trendColorBufferIndex 19
|
#define trendColorBufferIndex 21
|
||||||
double trendColorBuffer[];
|
double trendColorBuffer[];
|
||||||
|
|
||||||
//
|
//
|
||||||
#property indicator_label19 "TRND"
|
#property indicator_label21 "TRND"
|
||||||
#property indicator_type19 DRAW_COLOR_LINE
|
#property indicator_type21 DRAW_COLOR_LINE
|
||||||
#property indicator_color19 CLR_NONE, clrAqua, clrMagenta, clrGray
|
#property indicator_color21 CLR_NONE, clrAqua, clrMagenta, clrGray
|
||||||
#property indicator_style19 STYLE_DASH
|
#property indicator_style21 STYLE_DASH
|
||||||
#property indicator_width19 2
|
#property indicator_width21 2
|
||||||
|
|
||||||
//
|
//
|
||||||
// KI ...
|
// KI ...
|
||||||
|
|
||||||
//
|
//
|
||||||
#define kiBufferIndex 20
|
#define kiBufferIndex 22
|
||||||
#define kiBufferPlotIndex 19
|
#define kiBufferPlotIndex 21
|
||||||
double kiBuffer[];
|
double kiBuffer[];
|
||||||
|
|
||||||
//
|
//
|
||||||
#define kiColorBufferIndex 21
|
#define kiColorBufferIndex 23
|
||||||
double kiColorBuffer[];
|
double kiColorBuffer[];
|
||||||
|
|
||||||
//
|
//
|
||||||
#property indicator_label20 "KI"
|
#property indicator_label22 "KI"
|
||||||
#property indicator_type20 DRAW_COLOR_LINE
|
#property indicator_type22 DRAW_COLOR_LINE
|
||||||
#property indicator_color20 CLR_NONE, clrGreen, clrRed, clrGray
|
#property indicator_color22 CLR_NONE, clrGreen, clrRed, clrGray
|
||||||
#property indicator_style20 STYLE_DASHDOTDOT
|
#property indicator_style22 STYLE_DASHDOTDOT
|
||||||
#property indicator_width20 2
|
#property indicator_width22 2
|
||||||
|
|
||||||
//
|
//
|
||||||
// SWING Low ...
|
// SWING Low ...
|
||||||
|
|
||||||
//
|
//
|
||||||
#define swingLowBufferIndex 22
|
#define swingLowBufferIndex 24
|
||||||
#define swingLowBufferPlotIndex 20
|
#define swingLowBufferPlotIndex 22
|
||||||
double swingLowBuffer[];
|
double swingLowBuffer[];
|
||||||
|
|
||||||
//
|
//
|
||||||
#property indicator_label21 "SWL"
|
#property indicator_label23 "SWL"
|
||||||
#property indicator_type21 DRAW_ARROW
|
#property indicator_type23 DRAW_ARROW
|
||||||
#property indicator_color21 clrGreen
|
#property indicator_color23 clrGreen
|
||||||
#property indicator_width21 1
|
#property indicator_width23 1
|
||||||
|
|
||||||
//
|
//
|
||||||
// SWING High ...
|
// SWING High ...
|
||||||
|
|
||||||
//
|
//
|
||||||
#define swingHighBufferIndex 23
|
#define swingHighBufferIndex 25
|
||||||
#define swingHighBufferPlotIndex 21
|
#define swingHighBufferPlotIndex 23
|
||||||
double swingHighBuffer[];
|
double swingHighBuffer[];
|
||||||
|
|
||||||
//
|
//
|
||||||
#property indicator_label22 "SWH"
|
#property indicator_label24 "SWH"
|
||||||
#property indicator_type22 DRAW_ARROW
|
#property indicator_type24 DRAW_ARROW
|
||||||
#property indicator_color22 clrRed
|
#property indicator_color24 clrRed
|
||||||
#property indicator_width22 1
|
#property indicator_width24 1
|
||||||
|
|
||||||
//
|
//
|
||||||
// TKI ...
|
// TKI ...
|
||||||
|
|
||||||
//
|
//
|
||||||
#define tkiBufferIndex 24
|
#define tkiBufferIndex 26
|
||||||
#define tkiBufferPlotIndex 22
|
#define tkiBufferPlotIndex 24
|
||||||
double tkiBuffer[];
|
double tkiBuffer[];
|
||||||
|
|
||||||
//
|
//
|
||||||
#define tkiColorBufferIndex 25
|
#define tkiColorBufferIndex 27
|
||||||
double tkiColorBuffer[];
|
double tkiColorBuffer[];
|
||||||
|
|
||||||
//
|
//
|
||||||
#property indicator_label23 "TKI"
|
#property indicator_label25 "TKI"
|
||||||
#property indicator_type23 DRAW_COLOR_LINE
|
#property indicator_type25 DRAW_COLOR_LINE
|
||||||
#property indicator_color23 CLR_NONE, clrGreen, clrRed, clrGray
|
#property indicator_color25 CLR_NONE, clrGreen, clrRed, clrGray
|
||||||
#property indicator_style23 STYLE_DASHDOTDOT
|
#property indicator_style25 STYLE_DASHDOTDOT
|
||||||
#property indicator_width23 2
|
#property indicator_width25 2
|
||||||
|
|
||||||
//
|
//
|
||||||
// VIDYA ...
|
// VIDYA ...
|
||||||
|
|
||||||
//
|
//
|
||||||
#define vidyaBufferIndex 26
|
#define vidyaBufferIndex 28
|
||||||
#define vidyaBufferPlotIndex 23
|
#define vidyaBufferPlotIndex 25
|
||||||
double vidyaBuffer[];
|
double vidyaBuffer[];
|
||||||
|
|
||||||
//
|
//
|
||||||
#define vidyaColorBufferIndex 27
|
#define vidyaColorBufferIndex 29
|
||||||
double vidyaColorBuffer[];
|
double vidyaColorBuffer[];
|
||||||
|
|
||||||
//
|
//
|
||||||
#property indicator_label24 "VIDYA"
|
#property indicator_label26 "VIDYA"
|
||||||
#property indicator_type24 DRAW_COLOR_LINE
|
#property indicator_type26 DRAW_COLOR_LINE
|
||||||
#property indicator_color24 CLR_NONE, clrAqua, clrMagenta, clrGray
|
#property indicator_color26 CLR_NONE, clrAqua, clrMagenta, clrGray
|
||||||
#property indicator_style24 STYLE_SOLID
|
#property indicator_style26 STYLE_SOLID
|
||||||
#property indicator_width24 1
|
#property indicator_width26 1
|
||||||
|
|
||||||
//
|
//
|
||||||
// MAH ...
|
// MAH ...
|
||||||
|
|
||||||
//
|
//
|
||||||
#define mahBufferIndex 28
|
#define mahBufferIndex 30
|
||||||
#define mahBufferPlotIndex 24
|
#define mahBufferPlotIndex 26
|
||||||
double mahBuffer[];
|
double mahBuffer[];
|
||||||
|
|
||||||
//
|
//
|
||||||
#property indicator_label25 "MAH"
|
#property indicator_label27 "MAH"
|
||||||
#property indicator_type25 DRAW_LINE
|
#property indicator_type27 DRAW_LINE
|
||||||
#property indicator_color25 clrMagenta
|
#property indicator_color27 clrMagenta
|
||||||
#property indicator_style25 STYLE_SOLID
|
#property indicator_style27 STYLE_SOLID
|
||||||
#property indicator_width25 1
|
#property indicator_width27 1
|
||||||
|
|
||||||
//
|
//
|
||||||
// MAL ...
|
// MAL ...
|
||||||
|
|
||||||
//
|
//
|
||||||
#define malBufferIndex 29
|
#define malBufferIndex 31
|
||||||
#define malBufferPlotIndex 25
|
#define malBufferPlotIndex 27
|
||||||
double malBuffer[];
|
double malBuffer[];
|
||||||
|
|
||||||
//
|
//
|
||||||
#property indicator_label26 "MAL"
|
#property indicator_label28 "MAL"
|
||||||
#property indicator_type26 DRAW_LINE
|
#property indicator_type28 DRAW_LINE
|
||||||
#property indicator_color26 clrAqua
|
#property indicator_color28 clrAqua
|
||||||
#property indicator_style26 STYLE_SOLID
|
#property indicator_style28 STYLE_SOLID
|
||||||
#property indicator_width26 1
|
#property indicator_width28 1
|
||||||
|
|
||||||
//
|
//
|
||||||
// MAC ...
|
// MAC ...
|
||||||
|
|
||||||
//
|
//
|
||||||
#define macBufferIndex 30
|
#define macBufferIndex 32
|
||||||
#define macBufferPlotIndex 26
|
#define macBufferPlotIndex 28
|
||||||
double macBuffer[];
|
double macBuffer[];
|
||||||
|
|
||||||
//
|
//
|
||||||
#property indicator_label27 "MAC"
|
#property indicator_label29 "MAC"
|
||||||
#property indicator_type27 DRAW_LINE
|
#property indicator_type29 DRAW_LINE
|
||||||
#property indicator_color27 clrYellow
|
#property indicator_color29 clrYellow
|
||||||
#property indicator_style27 STYLE_SOLID
|
#property indicator_style29 STYLE_SOLID
|
||||||
#property indicator_width27 1
|
#property indicator_width29 1
|
||||||
|
|
||||||
//
|
//
|
||||||
// Data Buffers ...
|
// Data Buffers ...
|
||||||
|
|
||||||
#define mLastBufferIndex 30
|
#define mLastBufferIndex 32
|
||||||
|
|
||||||
//
|
//
|
||||||
#define trendStateBufferIndex mLastBufferIndex + 1
|
#define trendStateBufferIndex mLastBufferIndex + 1
|
||||||
@@ -1361,6 +1395,40 @@ void DefineBuffers()
|
|||||||
//
|
//
|
||||||
PlotIndexSetDouble(fiboLevel3BufferIndex, PLOT_EMPTY_VALUE, emptyValue);
|
PlotIndexSetDouble(fiboLevel3BufferIndex, PLOT_EMPTY_VALUE, emptyValue);
|
||||||
|
|
||||||
|
//
|
||||||
|
// FIBO L4 ...
|
||||||
|
|
||||||
|
//
|
||||||
|
ENUM_DRAW_TYPE fiboL4DrawType = showFiboLevel4 ? DRAW_LINE : DRAW_NONE;
|
||||||
|
|
||||||
|
//
|
||||||
|
ArraySetAsSeries(fiboLevel4Buffer, true);
|
||||||
|
SetIndexBuffer(fiboLevel4BufferIndex, fiboLevel4Buffer, INDICATOR_DATA);
|
||||||
|
|
||||||
|
//
|
||||||
|
PlotIndexSetInteger(fiboLevel4BufferIndex, PLOT_SHOW_DATA, showFiboLevel4);
|
||||||
|
PlotIndexSetInteger(fiboLevel4BufferIndex, PLOT_DRAW_TYPE, fiboL4DrawType);
|
||||||
|
|
||||||
|
//
|
||||||
|
PlotIndexSetDouble(fiboLevel4BufferIndex, PLOT_EMPTY_VALUE, emptyValue);
|
||||||
|
|
||||||
|
//
|
||||||
|
// FIBO L5 ...
|
||||||
|
|
||||||
|
//
|
||||||
|
ENUM_DRAW_TYPE fiboL5DrawType = showFiboLevel5 ? DRAW_LINE : DRAW_NONE;
|
||||||
|
|
||||||
|
//
|
||||||
|
ArraySetAsSeries(fiboLevel5Buffer, true);
|
||||||
|
SetIndexBuffer(fiboLevel5BufferIndex, fiboLevel5Buffer, INDICATOR_DATA);
|
||||||
|
|
||||||
|
//
|
||||||
|
PlotIndexSetInteger(fiboLevel5BufferIndex, PLOT_SHOW_DATA, showFiboLevel5);
|
||||||
|
PlotIndexSetInteger(fiboLevel5BufferIndex, PLOT_DRAW_TYPE, fiboL5DrawType);
|
||||||
|
|
||||||
|
//
|
||||||
|
PlotIndexSetDouble(fiboLevel5BufferIndex, PLOT_EMPTY_VALUE, emptyValue);
|
||||||
|
|
||||||
//
|
//
|
||||||
// SAR ...
|
// SAR ...
|
||||||
|
|
||||||
@@ -1819,6 +1887,14 @@ void FillBuffersZero(int barIndex)
|
|||||||
valeBuffer[barIndex] = emptyValue;
|
valeBuffer[barIndex] = emptyValue;
|
||||||
valeGoldenBuffer[barIndex] = emptyValue;
|
valeGoldenBuffer[barIndex] = emptyValue;
|
||||||
|
|
||||||
|
//
|
||||||
|
// FiBo ...
|
||||||
|
fiboLevel1Buffer[barIndex] = emptyValue;
|
||||||
|
fiboLevel2Buffer[barIndex] = emptyValue;
|
||||||
|
fiboLevel3Buffer[barIndex] = emptyValue;
|
||||||
|
fiboLevel4Buffer[barIndex] = emptyValue;
|
||||||
|
fiboLevel5Buffer[barIndex] = emptyValue;
|
||||||
|
|
||||||
//
|
//
|
||||||
// SAR ...
|
// SAR ...
|
||||||
sarBuffer[barIndex] = emptyValue;
|
sarBuffer[barIndex] = emptyValue;
|
||||||
@@ -2030,12 +2106,6 @@ void CalculateValues(
|
|||||||
double iHHH = hHHBuffer[bar_index];
|
double iHHH = hHHBuffer[bar_index];
|
||||||
double iHLL = hLLBuffer[bar_index];
|
double iHLL = hLLBuffer[bar_index];
|
||||||
|
|
||||||
//
|
|
||||||
// Calculate BOS ...
|
|
||||||
|
|
||||||
//
|
|
||||||
// Calculate CHOCH ...
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Calculate Support ...
|
// Calculate Support ...
|
||||||
double lastSupport =
|
double lastSupport =
|
||||||
@@ -2131,15 +2201,105 @@ void CalculateValues(
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Calculate Swings ...
|
||||||
|
|
||||||
|
//
|
||||||
|
double lastSwingLow =
|
||||||
|
isFirstBar
|
||||||
|
? emptyValue
|
||||||
|
: swingLowBuffer[lastBarIndex];
|
||||||
|
double lastSwingHigh =
|
||||||
|
isFirstBar
|
||||||
|
? emptyValue
|
||||||
|
: swingHighBuffer[lastBarIndex];
|
||||||
|
|
||||||
|
//
|
||||||
|
bool isSwingLow = IsSwingLow(
|
||||||
|
high,
|
||||||
|
low,
|
||||||
|
bar_index,
|
||||||
|
swingLength //
|
||||||
|
);
|
||||||
|
bool isSwingHigh = IsSwingHigh(
|
||||||
|
high,
|
||||||
|
low,
|
||||||
|
bar_index,
|
||||||
|
swingLength //
|
||||||
|
);
|
||||||
|
bool hasSwing = isSwingLow ||
|
||||||
|
isSwingHigh;
|
||||||
|
double iSwingLow = emptyValue;
|
||||||
|
double iSwingHigh = emptyValue;
|
||||||
|
if (!hasSwing)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// FillBuffersZero(bar_index);
|
||||||
|
|
||||||
|
//
|
||||||
|
iSwingLow = lastSwingLow;
|
||||||
|
iSwingHigh = lastSwingHigh;
|
||||||
|
|
||||||
|
//
|
||||||
|
swingLowBuffer[bar_index] = lastSwingLow;
|
||||||
|
swingHighBuffer[bar_index] = lastSwingHigh;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//
|
||||||
|
iSwingLow = low[bar_index];
|
||||||
|
double iSwingHigh = high[bar_index];
|
||||||
|
|
||||||
|
//
|
||||||
|
if (isSwingLow && !isSwingHigh)
|
||||||
|
{
|
||||||
|
iSwingHigh = lastSwingHigh;
|
||||||
|
}
|
||||||
|
else if (isSwingHigh && !isSwingLow)
|
||||||
|
{
|
||||||
|
iSwingLow = lastSwingLow;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
if (iSwingLow > lastSwingLow &&
|
||||||
|
iSwingHigh == lastSwingHigh)
|
||||||
|
{
|
||||||
|
iSwingLow = lastSwingLow;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
if (iSwingHigh < lastSwingHigh &&
|
||||||
|
iSwingLow == lastSwingLow)
|
||||||
|
{
|
||||||
|
iSwingHigh = lastSwingHigh;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
swingLowBuffer[bar_index] = iSwingLow;
|
||||||
|
swingHighBuffer[bar_index] = iSwingHigh;
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Calculate Fibo Levels ...
|
// Calculate Fibo Levels ...
|
||||||
|
|
||||||
//
|
//
|
||||||
double iFiboUpper = peakBuffer[bar_index];
|
double iFiboValues[] = {
|
||||||
double iFiboLower = valeBuffer[bar_index];
|
peakBuffer[bar_index],
|
||||||
|
valeBuffer[bar_index],
|
||||||
|
supBuffer[bar_index],
|
||||||
|
swingLowBuffer[bar_index],
|
||||||
|
swingHighBuffer[bar_index],
|
||||||
|
resBuffer[bar_index], //
|
||||||
|
};
|
||||||
|
|
||||||
//
|
//
|
||||||
double iFiboLevel1 = GetFibonacciLevel(
|
double iFiboUpper = GetMax(iFiboValues);
|
||||||
|
double iFiboLower = GetMin(iFiboValues);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Fibo Level 1 ...
|
||||||
|
double iFiboLevel1 = emptyValue;
|
||||||
|
iFiboLevel1 = GetFibonacciLevel(
|
||||||
iFiboUpper,
|
iFiboUpper,
|
||||||
iFiboLower,
|
iFiboLower,
|
||||||
fiboLevel1,
|
fiboLevel1,
|
||||||
@@ -2148,7 +2308,9 @@ void CalculateValues(
|
|||||||
fiboLevel1Buffer[bar_index] = iFiboLevel1;
|
fiboLevel1Buffer[bar_index] = iFiboLevel1;
|
||||||
|
|
||||||
//
|
//
|
||||||
double iFiboLevel2 = GetFibonacciLevel(
|
// Fibo Level 2 ...
|
||||||
|
double iFiboLevel2 = emptyValue;
|
||||||
|
iFiboLevel2 = GetFibonacciLevel(
|
||||||
iFiboUpper,
|
iFiboUpper,
|
||||||
iFiboLower,
|
iFiboLower,
|
||||||
fiboLevel2,
|
fiboLevel2,
|
||||||
@@ -2157,7 +2319,9 @@ void CalculateValues(
|
|||||||
fiboLevel2Buffer[bar_index] = iFiboLevel2;
|
fiboLevel2Buffer[bar_index] = iFiboLevel2;
|
||||||
|
|
||||||
//
|
//
|
||||||
double iFiboLevel3 = GetFibonacciLevel(
|
// Fibo Level 3 ...
|
||||||
|
double iFiboLevel3 = emptyValue;
|
||||||
|
iFiboLevel3 = GetFibonacciLevel(
|
||||||
iFiboUpper,
|
iFiboUpper,
|
||||||
iFiboLower,
|
iFiboLower,
|
||||||
fiboLevel3,
|
fiboLevel3,
|
||||||
@@ -2165,6 +2329,28 @@ void CalculateValues(
|
|||||||
);
|
);
|
||||||
fiboLevel3Buffer[bar_index] = iFiboLevel3;
|
fiboLevel3Buffer[bar_index] = iFiboLevel3;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Fibo Level 4 ...
|
||||||
|
double iFiboLevel4 = emptyValue;
|
||||||
|
iFiboLevel4 = GetFibonacciLevel(
|
||||||
|
iFiboUpper,
|
||||||
|
iFiboLower,
|
||||||
|
fiboLevel4,
|
||||||
|
X_DIRECTION_BEARISH //
|
||||||
|
);
|
||||||
|
fiboLevel4Buffer[bar_index] = iFiboLevel4;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Fibo Level 5 ...
|
||||||
|
double iFiboLevel5 = emptyValue;
|
||||||
|
iFiboLevel5 = GetFibonacciLevel(
|
||||||
|
iFiboUpper,
|
||||||
|
iFiboLower,
|
||||||
|
fiboLevel5,
|
||||||
|
X_DIRECTION_BEARISH //
|
||||||
|
);
|
||||||
|
fiboLevel5Buffer[bar_index] = iFiboLevel5;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Calculate Trend Color Buffer ...
|
// Calculate Trend Color Buffer ...
|
||||||
double iClose = close[bar_index];
|
double iClose = close[bar_index];
|
||||||
@@ -2279,43 +2465,6 @@ void CalculateValues(
|
|||||||
peakGoldenBuffer[bar_index] = iPeakGold;
|
peakGoldenBuffer[bar_index] = iPeakGold;
|
||||||
valeGoldenBuffer[bar_index] = iValeGold;
|
valeGoldenBuffer[bar_index] = iValeGold;
|
||||||
|
|
||||||
//
|
|
||||||
// Calculate Swings ...
|
|
||||||
|
|
||||||
//
|
|
||||||
double lastSwingLow =
|
|
||||||
isFirstBar
|
|
||||||
? emptyValue
|
|
||||||
: swingLowBuffer[lastBarIndex];
|
|
||||||
bool isSwingLow = IsSwingLow(
|
|
||||||
high,
|
|
||||||
low,
|
|
||||||
bar_index,
|
|
||||||
swingLength //
|
|
||||||
);
|
|
||||||
double iSwingLow =
|
|
||||||
isSwingLow
|
|
||||||
? low[bar_index]
|
|
||||||
: lastSwingLow;
|
|
||||||
swingLowBuffer[bar_index] = iSwingLow;
|
|
||||||
|
|
||||||
//
|
|
||||||
double lastSwingHigh =
|
|
||||||
isFirstBar
|
|
||||||
? emptyValue
|
|
||||||
: swingHighBuffer[lastBarIndex];
|
|
||||||
bool isSwingHigh = IsSwingHigh(
|
|
||||||
high,
|
|
||||||
low,
|
|
||||||
bar_index,
|
|
||||||
swingLength //
|
|
||||||
);
|
|
||||||
double iSwingHigh =
|
|
||||||
isSwingHigh
|
|
||||||
? high[bar_index]
|
|
||||||
: lastSwingHigh;
|
|
||||||
swingHighBuffer[bar_index] = iSwingHigh;
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// TKI State and Color ...
|
// TKI State and Color ...
|
||||||
|
|
||||||
|
|||||||
@@ -292,6 +292,8 @@ struct XCAEAConditions
|
|||||||
double fiboLevel1Buffer[];
|
double fiboLevel1Buffer[];
|
||||||
double fiboLevel2Buffer[];
|
double fiboLevel2Buffer[];
|
||||||
double fiboLevel3Buffer[];
|
double fiboLevel3Buffer[];
|
||||||
|
double fiboLevel4Buffer[];
|
||||||
|
double fiboLevel5Buffer[];
|
||||||
double trendStateBuffer[];
|
double trendStateBuffer[];
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -951,6 +953,8 @@ struct XCAEAConditions
|
|||||||
Clean(fiboLevel1Buffer);
|
Clean(fiboLevel1Buffer);
|
||||||
Clean(fiboLevel2Buffer);
|
Clean(fiboLevel2Buffer);
|
||||||
Clean(fiboLevel3Buffer);
|
Clean(fiboLevel3Buffer);
|
||||||
|
Clean(fiboLevel4Buffer);
|
||||||
|
Clean(fiboLevel5Buffer);
|
||||||
Clean(vidyaStateBuffer);
|
Clean(vidyaStateBuffer);
|
||||||
Clean(trendStateBuffer);
|
Clean(trendStateBuffer);
|
||||||
|
|
||||||
@@ -984,6 +988,8 @@ struct XCAEAConditions
|
|||||||
ArraySetAsSeries(fiboLevel1Buffer, true);
|
ArraySetAsSeries(fiboLevel1Buffer, true);
|
||||||
ArraySetAsSeries(fiboLevel2Buffer, true);
|
ArraySetAsSeries(fiboLevel2Buffer, true);
|
||||||
ArraySetAsSeries(fiboLevel3Buffer, true);
|
ArraySetAsSeries(fiboLevel3Buffer, true);
|
||||||
|
ArraySetAsSeries(fiboLevel4Buffer, true);
|
||||||
|
ArraySetAsSeries(fiboLevel5Buffer, true);
|
||||||
ArraySetAsSeries(vidyaStateBuffer, true);
|
ArraySetAsSeries(vidyaStateBuffer, true);
|
||||||
ArraySetAsSeries(trendStateBuffer, true);
|
ArraySetAsSeries(trendStateBuffer, true);
|
||||||
|
|
||||||
@@ -3710,6 +3716,18 @@ class XCXCAEAHelper : XCBase
|
|||||||
conditions.fiboLevel3Buffer //
|
conditions.fiboLevel3Buffer //
|
||||||
);
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
Copy(
|
||||||
|
xcaConditions.fiboLevel4Buffer,
|
||||||
|
conditions.fiboLevel4Buffer //
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
Copy(
|
||||||
|
xcaConditions.fiboLevel5Buffer,
|
||||||
|
conditions.fiboLevel5Buffer //
|
||||||
|
);
|
||||||
|
|
||||||
//
|
//
|
||||||
Copy(
|
Copy(
|
||||||
xcaConditions.trendStateBuffer,
|
xcaConditions.trendStateBuffer,
|
||||||
|
|||||||
Reference in New Issue
Block a user