5785 lines
127 KiB
Plaintext
5785 lines
127 KiB
Plaintext
///////////////////////////////////////////////////////
|
|
//
|
|
// SaherElm IT Center MQL5 Class Library
|
|
// --------------------------------------
|
|
// Name: XPOI
|
|
// Description: Provides Point of Interests ...
|
|
// - Swing Highs;
|
|
// - Swing Lows;
|
|
//
|
|
// Maintainer:
|
|
// ------------
|
|
// Hadi Khazaee Asl (hadi_khazaee_asl@yahoo.com)
|
|
//
|
|
//////////////////////////////////////////////////////
|
|
//
|
|
// Global Properties ...
|
|
#property library
|
|
#property copyright "Copyright 2023, SaherElm IT Center"
|
|
#property link "https://www.saherelm.ir"
|
|
#property version "1.00"
|
|
#property strict
|
|
|
|
//
|
|
// Imports ...
|
|
|
|
//
|
|
#include "../Classes/x-saherelm.x-chart-objects.class.mq5"
|
|
#include "../Classes/x-saherelm.xalert.class.mq5"
|
|
|
|
//
|
|
#include <Arrays/ArrayObj.mqh>
|
|
#include <ChartObjects/ChartObject.mqh>
|
|
#include <ChartObjects/ChartObjectsArrows.mqh>
|
|
#include <ChartObjects/ChartObjectsLines.mqh>
|
|
|
|
//
|
|
// Implementation ...
|
|
|
|
//
|
|
class XCPOI : public XSCBaseAlert
|
|
{
|
|
//
|
|
public:
|
|
//
|
|
|
|
//
|
|
// Constructors ...
|
|
/**
|
|
* Create an Instance ...
|
|
*
|
|
* @param symbol: String ...
|
|
* @param period: ENUM_TIMEFRAMES member ...
|
|
*/
|
|
void XCPOI(
|
|
string symbol,
|
|
ENUM_TIMEFRAMES period //
|
|
)
|
|
{
|
|
//
|
|
// Attach Required Properties ...
|
|
mSymbol = symbol;
|
|
mPeriod = period;
|
|
|
|
//
|
|
// Initialize Bar Tracker ...
|
|
mBarTracker.Init(
|
|
mSymbol,
|
|
mPeriod //
|
|
);
|
|
|
|
//
|
|
// Apply Default Configurations ...
|
|
ApplyDefaultConfig();
|
|
}
|
|
|
|
//
|
|
// Deconstructor ...
|
|
void ~XCPOI()
|
|
{
|
|
//
|
|
DestroyPOIs();
|
|
DestroyObjects();
|
|
DestroySessions();
|
|
DestroyEventListeners();
|
|
}
|
|
|
|
//
|
|
// Getter(s) / Setter(s) ...
|
|
|
|
/**
|
|
* Get Chart ID ...
|
|
*
|
|
* @return ( long )
|
|
*/
|
|
long ChartID()
|
|
{
|
|
return mChartID;
|
|
}
|
|
|
|
/**
|
|
* Set Chart ID ...
|
|
*
|
|
* @param value: Long
|
|
*/
|
|
void ChartID(long value)
|
|
{
|
|
//
|
|
if (value < 0)
|
|
{
|
|
value = 0;
|
|
}
|
|
|
|
//
|
|
mChartID = value;
|
|
}
|
|
|
|
/**
|
|
* Get Sub Window Number ...
|
|
*
|
|
* @return ( int )
|
|
*/
|
|
int Window()
|
|
{
|
|
return mWindow;
|
|
}
|
|
|
|
/**
|
|
* Get Sub Window Number ...
|
|
*
|
|
* @param value: Integer ...
|
|
*/
|
|
void Window(int value)
|
|
{
|
|
//
|
|
if (value < 0)
|
|
{
|
|
value = 0;
|
|
}
|
|
|
|
//
|
|
mWindow = value;
|
|
}
|
|
|
|
/**
|
|
* Get Max Number of POIs which holds ...
|
|
*
|
|
* @return ( int )
|
|
*/
|
|
int MaxNumberOfPOIs()
|
|
{
|
|
return mMaxNumberOfPOIs;
|
|
}
|
|
|
|
/**
|
|
* Set Max Number of POIs which holds ...
|
|
* 0 => Infinity ...
|
|
*
|
|
* @param value: Integer ...
|
|
*/
|
|
void MaxNumberOfPOIs(int value)
|
|
{
|
|
//
|
|
if (value < 0)
|
|
{
|
|
value = 0;
|
|
}
|
|
|
|
//
|
|
mMaxNumberOfPOIs = value;
|
|
}
|
|
|
|
/**
|
|
* Get Number of POI(s) which must Find at Initializations ...
|
|
*
|
|
* @return ( int )
|
|
*/
|
|
int MaxNumberOfRequiredPOIs()
|
|
{
|
|
return mMaxNumberOfRequiredPOIs;
|
|
}
|
|
|
|
/**
|
|
* Set Number of POI(s) which must Find at Initializations ...
|
|
* 2 is Default ...
|
|
*
|
|
* @param value: Integer ...
|
|
*/
|
|
void MaxNumberOfRequiredPOIs(int value)
|
|
{
|
|
//
|
|
if (value < 2)
|
|
{
|
|
value = 2;
|
|
}
|
|
|
|
//
|
|
mMaxNumberOfRequiredPOIs = value;
|
|
}
|
|
|
|
/**
|
|
* Check Is Locked or not ...
|
|
*
|
|
* @return ( bool )
|
|
*/
|
|
bool IsLocked()
|
|
{
|
|
return mLock;
|
|
}
|
|
|
|
//
|
|
// POI(s) Configs ...
|
|
|
|
//
|
|
// Trading Days ...
|
|
|
|
/**
|
|
* Get Draw Trading Days State ...
|
|
*
|
|
* @return ( bool )
|
|
*/
|
|
bool AllowDrawTradingDays()
|
|
{
|
|
return mAllowDrawTradingDays;
|
|
}
|
|
|
|
/**
|
|
* Set Draw Trading Days State ...
|
|
*
|
|
* @param value: Boolean ...
|
|
*/
|
|
void AllowDrawTradingDays(bool value)
|
|
{
|
|
mAllowDrawTradingDays = value;
|
|
}
|
|
|
|
/**
|
|
* Get Trading Days Start Color ...
|
|
*
|
|
* @return ( color )
|
|
*/
|
|
color TradingDaysStartColor()
|
|
{
|
|
return mTradingDaysStartColor;
|
|
}
|
|
|
|
/**
|
|
* Set Trading Days Start Color ...
|
|
*
|
|
* @param value: Argument 1
|
|
*/
|
|
void TradingDaysStartColor(color value)
|
|
{
|
|
mTradingDaysStartColor = value;
|
|
}
|
|
|
|
/**
|
|
* Get Trading Days Start Style ...
|
|
*
|
|
* @return ( ENUM_LINE_STYLE )
|
|
*/
|
|
ENUM_LINE_STYLE TradingDaysStartStyle()
|
|
{
|
|
return mTradingDaysStartStyle;
|
|
}
|
|
|
|
/**
|
|
* Set Trading Days Start Style ...
|
|
*
|
|
* @param value: ENUM_LINE_STYLE member ...
|
|
*/
|
|
void TradingDaysStartStyle(ENUM_LINE_STYLE value)
|
|
{
|
|
mTradingDaysStartStyle = value;
|
|
}
|
|
|
|
/**
|
|
* Get Trading Days End Color ...
|
|
*
|
|
* @return ( color )
|
|
*/
|
|
color TradingDaysEndColor()
|
|
{
|
|
return mTradingDaysEndColor;
|
|
}
|
|
|
|
/**
|
|
* Set Trading Days End Color ...
|
|
*
|
|
* @param value: Argument 1
|
|
*/
|
|
void TradingDaysEndColor(color value)
|
|
{
|
|
mTradingDaysEndColor = value;
|
|
}
|
|
|
|
/**
|
|
* Get Trading Days End Style ...
|
|
*
|
|
* @return ( ENUM_LINE_STYLE )
|
|
*/
|
|
ENUM_LINE_STYLE TradingDaysEndStyle()
|
|
{
|
|
return mTradingDaysEndStyle;
|
|
}
|
|
|
|
/**
|
|
* Set Trading Days End Style ...
|
|
*
|
|
* @param value: ENUM_LINE_STYLE member ...
|
|
*/
|
|
void TradingDaysEndStyle(ENUM_LINE_STYLE value)
|
|
{
|
|
mTradingDaysEndStyle = value;
|
|
}
|
|
|
|
//
|
|
// Sessions ...
|
|
|
|
/**
|
|
* Get Draw Market Sessions State ...
|
|
*
|
|
* @return ( bool )
|
|
*/
|
|
bool AllowDrawMarketSessions()
|
|
{
|
|
return mAllowDrawMarketSessions;
|
|
}
|
|
|
|
/**
|
|
* Set Draw Market Sessions State ...
|
|
*
|
|
* @param value: Boolean ...
|
|
*/
|
|
void AllowDrawMarketSessions(bool value)
|
|
{
|
|
mAllowDrawMarketSessions = value;
|
|
}
|
|
|
|
/**
|
|
* Get Session Working Hors ...
|
|
*
|
|
* @return ( int )
|
|
*/
|
|
int SessionOpenHours()
|
|
{
|
|
return mSessionOpenHours;
|
|
}
|
|
|
|
/**
|
|
* Set Session Working Hors ...
|
|
*
|
|
* @param value: Integer ...
|
|
*/
|
|
void SessionOpenHours(int value)
|
|
{
|
|
//
|
|
if (value <= 0)
|
|
{
|
|
value = 9;
|
|
}
|
|
|
|
//
|
|
mSessionOpenHours = value;
|
|
}
|
|
|
|
//
|
|
// Swing High ...
|
|
|
|
/**
|
|
* Get Draw Swing Highs State ...
|
|
*
|
|
* @return ( bool )
|
|
*/
|
|
bool AllowDrawSwingHighs()
|
|
{
|
|
return mAllowDrawSwingHighs;
|
|
}
|
|
|
|
/**
|
|
* Set Draw Swing Highs State ...
|
|
*
|
|
* @param value: Boolean
|
|
*/
|
|
void AllowDrawSwingHighs(bool value)
|
|
{
|
|
mAllowDrawSwingHighs = value;
|
|
}
|
|
|
|
/**
|
|
* Get Threshold Required for Swing High Detection ...
|
|
*
|
|
* @return ( double )
|
|
*/
|
|
double SwingHighThreshold()
|
|
{
|
|
return mSwingHighThreshold;
|
|
}
|
|
|
|
/**
|
|
* Set Threshold Required for Swing High Detection ...
|
|
*
|
|
* @param value: Double ...
|
|
*/
|
|
void SwingHighThreshold(double value)
|
|
{
|
|
//
|
|
if (value < 0)
|
|
{
|
|
value = 0;
|
|
}
|
|
|
|
//
|
|
mSwingHighThreshold = value;
|
|
}
|
|
|
|
/**
|
|
* Get Swing High Arrow Code ...
|
|
*
|
|
* @return ( char )
|
|
*/
|
|
char SwingHighArrowCode()
|
|
{
|
|
return mSwingHighArrowCode;
|
|
}
|
|
|
|
/**
|
|
* Set Swing High Arrow Code ...
|
|
*
|
|
* @param value: Char ...
|
|
*/
|
|
void SwingHighArrowCode(char value)
|
|
{
|
|
mSwingHighArrowCode = value;
|
|
}
|
|
|
|
/**
|
|
* Get Swing High Color ...
|
|
*
|
|
* @return ( color )
|
|
*/
|
|
color SwingHighColor()
|
|
{
|
|
return mSwingHighColor;
|
|
}
|
|
|
|
/**
|
|
* Get Swing High Color ...
|
|
*
|
|
* @param value: Color
|
|
*/
|
|
void SwingHighColor(color value)
|
|
{
|
|
mSwingHighColor = value;
|
|
}
|
|
|
|
/**
|
|
* Get Swing High Width ...
|
|
*
|
|
* @return ( int )
|
|
*/
|
|
int SwingHighWidth()
|
|
{
|
|
return mSwingHighWidth;
|
|
}
|
|
|
|
/**
|
|
* Set Swing High Width ...
|
|
*
|
|
* @param value: Integer ...
|
|
*/
|
|
void SwingHighWidth(int value)
|
|
{
|
|
//
|
|
if (value < 1)
|
|
{
|
|
value = 1;
|
|
}
|
|
|
|
//
|
|
mSwingHighWidth = value;
|
|
}
|
|
|
|
//
|
|
// Swing Low ...
|
|
|
|
/**
|
|
* Get Draw Swing Lows State ...
|
|
*
|
|
* @return ( bool )
|
|
*/
|
|
bool AllowDrawSwingLows()
|
|
{
|
|
return mAllowDrawSwingLows;
|
|
}
|
|
|
|
/**
|
|
* Set Draw Swing Lows State ...
|
|
*
|
|
* @param value: Boolean
|
|
*/
|
|
void AllowDrawSwingLows(bool value)
|
|
{
|
|
mAllowDrawSwingLows = value;
|
|
}
|
|
|
|
/**
|
|
* Get Threshold Required for Swing Low Detection ...
|
|
*
|
|
* @return ( double )
|
|
*/
|
|
double SwingLowThreshold()
|
|
{
|
|
return mSwingLowThreshold;
|
|
}
|
|
|
|
/**
|
|
* Set Threshold Required for Swing Low Detection ...
|
|
*
|
|
* @param value: Double ...
|
|
*/
|
|
void SwingLowThreshold(double value)
|
|
{
|
|
//
|
|
if (value < 0)
|
|
{
|
|
value = 0;
|
|
}
|
|
|
|
//
|
|
mSwingLowThreshold = value;
|
|
}
|
|
|
|
/**
|
|
* Get Swing Low Arrow Code ...
|
|
*
|
|
* @return ( char )
|
|
*/
|
|
char SwingLowArrowCode()
|
|
{
|
|
return mSwingLowArrowCode;
|
|
}
|
|
|
|
/**
|
|
* Set Swing Low Arrow Code ...
|
|
*
|
|
* @param value: Char ...
|
|
*/
|
|
void SwingLowArrowCode(char value)
|
|
{
|
|
mSwingLowArrowCode = value;
|
|
}
|
|
|
|
/**
|
|
* Get Swing Low Color ...
|
|
*
|
|
* @return ( color )
|
|
*/
|
|
color SwingLowColor()
|
|
{
|
|
return mSwingLowColor;
|
|
}
|
|
|
|
/**
|
|
* Get Swing Low Color ...
|
|
*
|
|
* @param value: Color
|
|
*/
|
|
void SwingLowColor(color value)
|
|
{
|
|
mSwingLowColor = value;
|
|
}
|
|
|
|
/**
|
|
* Get Swing Low Width ...
|
|
*
|
|
* @return ( int )
|
|
*/
|
|
int SwingLowWidth()
|
|
{
|
|
return mSwingLowWidth;
|
|
}
|
|
|
|
/**
|
|
* Set Swing Low Width ...
|
|
*
|
|
* @param value: Integer ...
|
|
*/
|
|
void SwingLowWidth(int value)
|
|
{
|
|
//
|
|
if (value < 1)
|
|
{
|
|
value = 1;
|
|
}
|
|
|
|
//
|
|
mSwingLowWidth = value;
|
|
}
|
|
|
|
//
|
|
// Momentum Bars ...
|
|
|
|
/**
|
|
* Get Draw Momentum Bars State ...
|
|
*
|
|
* @return ( bool )
|
|
*/
|
|
bool AllowDrawMomentumBars()
|
|
{
|
|
return mAllowDrawMomentumBars;
|
|
}
|
|
|
|
/**
|
|
* Set Draw Momentum Bars State ...
|
|
*
|
|
* @param value: Boolean
|
|
*/
|
|
void AllowDrawMomentumBars(bool value)
|
|
{
|
|
mAllowDrawMomentumBars = value;
|
|
}
|
|
|
|
/**
|
|
* Get Momentum Bar Percent ...
|
|
*
|
|
* @return ( int )
|
|
*/
|
|
int MomentumBarPercent()
|
|
{
|
|
return mMomentumBarPercent;
|
|
}
|
|
|
|
/**
|
|
* Set Momentum Bar Percent ...
|
|
*
|
|
* @param value: Integer
|
|
*/
|
|
void MomentumBarPercent(int value)
|
|
{
|
|
//
|
|
if (value < 0)
|
|
{
|
|
value = 0;
|
|
}
|
|
|
|
//
|
|
mMomentumBarPercent = value;
|
|
}
|
|
|
|
/**
|
|
* Get Momentum Bar Sharp Ratio ...
|
|
*
|
|
* @return ( double )
|
|
*/
|
|
double MomentumBarSharpRatio()
|
|
{
|
|
return mMomentumBarSharpRatio;
|
|
}
|
|
|
|
/**
|
|
* Set Momentum Bar Sharp Ratio ...
|
|
*
|
|
* @param value: Double ...
|
|
*/
|
|
void MomentumBarSharpRatio(double value)
|
|
{
|
|
//
|
|
if (value < 0)
|
|
{
|
|
value = 0;
|
|
}
|
|
|
|
//
|
|
mMomentumBarSharpRatio = value;
|
|
}
|
|
|
|
/**
|
|
* Get Momentum Bar Loopback ...
|
|
*
|
|
* @return ( int )
|
|
*/
|
|
int MomentumBarLoopBack()
|
|
{
|
|
return mMomentumBarLoopBack;
|
|
}
|
|
|
|
/**
|
|
* Set Momentum Bar Loopback ...
|
|
*
|
|
* @param value: Integer ...
|
|
*/
|
|
void MomentumBarLoopBack(int value)
|
|
{
|
|
//
|
|
if (value < 0)
|
|
{
|
|
value = 0;
|
|
}
|
|
|
|
//
|
|
mMomentumBarLoopBack = value;
|
|
}
|
|
|
|
/**
|
|
* Get Momentum Bar Width ...
|
|
*
|
|
* @return ( int )
|
|
*/
|
|
int MomentumBarWidth()
|
|
{
|
|
return mMomentumBarWidth;
|
|
}
|
|
|
|
/**
|
|
* Set Momentum Bar Width ...
|
|
*
|
|
* @param value: Integer ...
|
|
*/
|
|
void MomentumBarWidth(int value)
|
|
{
|
|
mMomentumBarWidth = value;
|
|
}
|
|
|
|
/**
|
|
* Get Bullish Momentum Bar Arrow Code ...
|
|
*
|
|
* @return ( char )
|
|
*/
|
|
char MomentumBarBullishArrowCode()
|
|
{
|
|
return mMomentumBarBullishArrowCode;
|
|
}
|
|
|
|
/**
|
|
* Set Bullish Momentum Bar Arrow Code ...
|
|
*
|
|
* @param value: Char ...
|
|
*/
|
|
void MomentumBarBullishArrowCode(char value)
|
|
{
|
|
mMomentumBarBullishArrowCode = value;
|
|
}
|
|
|
|
/**
|
|
* Get Bullish Momentum Bar Color ...
|
|
*
|
|
* @return ( char )
|
|
*/
|
|
char MomentumBarBearishArrowCode()
|
|
{
|
|
return mMomentumBarBearishArrowCode;
|
|
}
|
|
|
|
/**
|
|
* Set Bullish Momentum Bar Color ...
|
|
*
|
|
* @param value: Color ...
|
|
*/
|
|
void MomentumBarBearishArrowCode(char value)
|
|
{
|
|
mMomentumBarBearishArrowCode = value;
|
|
}
|
|
|
|
/**
|
|
* Get Bearish Momentum Bar Arrow Code ...
|
|
*
|
|
* @return ( color )
|
|
*/
|
|
color MomentumBarBullishColor()
|
|
{
|
|
return mMomentumBarBullishColor;
|
|
}
|
|
|
|
/**
|
|
* Set Bearish Momentum Bar Arrow Code ...
|
|
*
|
|
* @param value: Color ...
|
|
*/
|
|
void MomentumBarBullishColor(color value)
|
|
{
|
|
mMomentumBarBullishColor = value;
|
|
}
|
|
|
|
/**
|
|
* Get Bearish Momentum Bar Color ...
|
|
*
|
|
* @return ( color )
|
|
*/
|
|
color MomentumBarBearishColor()
|
|
{
|
|
return mMomentumBarBearishColor;
|
|
}
|
|
|
|
/**
|
|
* Set Bearish Momentum Bar Color ...
|
|
*
|
|
* @param value: Color ...
|
|
*/
|
|
void MomentumBarBearishColor(color value)
|
|
{
|
|
mMomentumBarBearishColor = value;
|
|
}
|
|
|
|
//
|
|
// Rejection Bars ...
|
|
|
|
/**
|
|
* Get Draw Rejection Bars State ...
|
|
*
|
|
* @return ( bool )
|
|
*/
|
|
bool AllowDrawRejectionBars()
|
|
{
|
|
return mAllowDrawRejectionBars;
|
|
}
|
|
|
|
/**
|
|
* Set Draw Rejection Bars State ...
|
|
*
|
|
* @param value: Boolean ...
|
|
*/
|
|
void AllowDrawRejectionBars(bool value)
|
|
{
|
|
mAllowDrawRejectionBars = value;
|
|
}
|
|
|
|
/**
|
|
* Get Rejection Bar Percent ...
|
|
*
|
|
* @return ( int )
|
|
*/
|
|
int RejectionBarPercent()
|
|
{
|
|
return mRejectionBarPercent;
|
|
}
|
|
|
|
/**
|
|
* Set Rejection Bar Percent ...
|
|
*
|
|
* @param value: Integer
|
|
*/
|
|
void RejectionBarPercent(int value)
|
|
{
|
|
mRejectionBarPercent = value;
|
|
}
|
|
|
|
/**
|
|
* Get Rejection Bar Sharp Ratio ...
|
|
*
|
|
* @return ( double )
|
|
*/
|
|
double RejectionBarSharpRatio()
|
|
{
|
|
return mRejectionBarSharpRatio;
|
|
}
|
|
|
|
/**
|
|
* Set Rejection Bar Sharp Ratio ...
|
|
*
|
|
* @param value: Double ...
|
|
*/
|
|
void RejectionBarSharpRatio(double value)
|
|
{
|
|
mRejectionBarSharpRatio = value;
|
|
}
|
|
|
|
/**
|
|
* Get Rejection Bar Loopback ...
|
|
*
|
|
* @return ( int )
|
|
*/
|
|
int RejectionBarLoopBack()
|
|
{
|
|
return mRejectionBarLoopBack;
|
|
}
|
|
|
|
/**
|
|
* Set Rejection Bar Loopback ...
|
|
*
|
|
* @param value: Integer ...
|
|
*/
|
|
void RejectionBarLoopBack(int value)
|
|
{
|
|
mRejectionBarLoopBack = value;
|
|
}
|
|
|
|
/**
|
|
* Get Rejection Bar Width ...
|
|
*
|
|
* @return ( int )
|
|
*/
|
|
int RejectionBarWidth()
|
|
{
|
|
return mRejectionBarWidth;
|
|
}
|
|
|
|
/**
|
|
* Set Rejection Bar Width ...
|
|
*
|
|
* @param value: Integer ...
|
|
*/
|
|
void RejectionBarWidth(int value)
|
|
{
|
|
mRejectionBarWidth = value;
|
|
}
|
|
|
|
/**
|
|
* Get Bullish Rejection Bar Arrow Code ...
|
|
*
|
|
* @return ( char )
|
|
*/
|
|
char RejectionBarBullishArrowCode()
|
|
{
|
|
return mRejectionBarBullishArrowCode;
|
|
}
|
|
|
|
/**
|
|
* Set Bullish Rejection Bar Arrow Code ...
|
|
*
|
|
* @param value: Char ...
|
|
*/
|
|
void RejectionBarBullishArrowCode(char value)
|
|
{
|
|
mRejectionBarBullishArrowCode = value;
|
|
}
|
|
|
|
/**
|
|
* Get Bullish Rejection Bar Color ...
|
|
*
|
|
* @return ( char )
|
|
*/
|
|
char RejectionBarBearishArrowCode()
|
|
{
|
|
return mRejectionBarBearishArrowCode;
|
|
}
|
|
|
|
/**
|
|
* Set Bullish Rejection Bar Color ...
|
|
*
|
|
* @param value: Color ...
|
|
*/
|
|
void RejectionBarBearishArrowCode(char value)
|
|
{
|
|
mRejectionBarBearishArrowCode = value;
|
|
}
|
|
|
|
/**
|
|
* Get Bearish Rejection Bar Arrow Code ...
|
|
*
|
|
* @return ( color )
|
|
*/
|
|
color RejectionBarBullishColor()
|
|
{
|
|
return mRejectionBarBullishColor;
|
|
}
|
|
|
|
/**
|
|
* Set Bearish Rejection Bar Arrow Code ...
|
|
*
|
|
* @param value: Color ...
|
|
*/
|
|
void RejectionBarBullishColor(color value)
|
|
{
|
|
mRejectionBarBullishColor = value;
|
|
}
|
|
|
|
/**
|
|
* Get Bearish Rejection Bar Color ...
|
|
*
|
|
* @return ( color )
|
|
*/
|
|
color RejectionBarBearishColor()
|
|
{
|
|
return mRejectionBarBearishColor;
|
|
}
|
|
|
|
/**
|
|
* Set Bearish Rejection Bar Color ...
|
|
*
|
|
* @param value: Color ...
|
|
*/
|
|
void RejectionBarBearishColor(color value)
|
|
{
|
|
mRejectionBarBearishColor = value;
|
|
}
|
|
|
|
//
|
|
// Support Zone ...
|
|
|
|
/**
|
|
* Get Draw Support Zone State ...
|
|
*
|
|
* @return ( bool )
|
|
*/
|
|
bool AllowDrawSupportZones()
|
|
{
|
|
return mAllowDrawSupportZones;
|
|
}
|
|
|
|
/**
|
|
* Set Draw Support Zone State ...
|
|
*
|
|
* @param value: Boolean ...
|
|
*/
|
|
void AllowDrawSupportZones(bool value)
|
|
{
|
|
mAllowDrawSupportZones = value;
|
|
}
|
|
|
|
/**
|
|
* Get Support Zone Loopback ...
|
|
*
|
|
* @return ( int )
|
|
*/
|
|
int SupportZoneLoopBack()
|
|
{
|
|
return mSupportZoneLoopBack;
|
|
}
|
|
|
|
/**
|
|
* Set Support Zone Loopback ...
|
|
*
|
|
* @param value: Integer ...
|
|
*/
|
|
void SupportZoneLoopBack(int value)
|
|
{
|
|
//
|
|
if (value < 10)
|
|
{
|
|
value = 10;
|
|
}
|
|
|
|
//
|
|
mSupportZoneLoopBack = value;
|
|
}
|
|
|
|
/**
|
|
* Get Support Zone Width ...
|
|
*
|
|
* @return ( int )
|
|
*/
|
|
int SupportZoneWidth()
|
|
{
|
|
return mSupportZoneWidth;
|
|
}
|
|
|
|
/**
|
|
* Set Support Zone Width ...
|
|
*
|
|
* @param value: Integer ...
|
|
*/
|
|
void SupportZoneWidth(int value)
|
|
{
|
|
//
|
|
if (value < 1)
|
|
{
|
|
value = 1;
|
|
}
|
|
|
|
//
|
|
mSupportZoneWidth = value;
|
|
}
|
|
|
|
/**
|
|
* Get Support Zone Color ...
|
|
*
|
|
* @return ( color )
|
|
*/
|
|
color SupportZoneColor()
|
|
{
|
|
return mSupportZoneColor;
|
|
}
|
|
|
|
/**
|
|
* Set Support Zone Color ...
|
|
*
|
|
* @param value: Color ...
|
|
*/
|
|
void SupportZoneColor(color value)
|
|
{
|
|
mSupportZoneColor = value;
|
|
}
|
|
|
|
/**
|
|
* Get Support Zone Style ...
|
|
*
|
|
* @return ( ENUM_LINE_STYLE )
|
|
*/
|
|
ENUM_LINE_STYLE SupportZoneStyle()
|
|
{
|
|
return mSupportZoneStyle;
|
|
}
|
|
|
|
/**
|
|
* Set Support Zone Style ...
|
|
*
|
|
* @param value: ENUM_LINE_STYLE member ...
|
|
*/
|
|
void SupportZoneStyle(ENUM_LINE_STYLE value)
|
|
{
|
|
mSupportZoneStyle = value;
|
|
}
|
|
|
|
/**
|
|
* Get Support Zone Price Type ...
|
|
*
|
|
* @return ( ENUM_LINE_STYLE )
|
|
*/
|
|
ENUM_X_PRICE SupportZonePriceType()
|
|
{
|
|
return mSupportZonePriceType;
|
|
}
|
|
|
|
/**
|
|
* Set Support Zone Price Type ...
|
|
*
|
|
* @param value: ENUM_X_PRICE member ...
|
|
*/
|
|
void SupportZonePriceType(ENUM_X_PRICE value)
|
|
{
|
|
mSupportZonePriceType = value;
|
|
}
|
|
|
|
//
|
|
// Resistance Zone ...
|
|
|
|
/**
|
|
* Get Draw Resistance Zone State ...
|
|
*
|
|
* @return ( bool )
|
|
*/
|
|
bool AllowDrawResistanceZones()
|
|
{
|
|
return mAllowDrawResistanceZones;
|
|
}
|
|
|
|
/**
|
|
* Set Draw Resistance Zone State ...
|
|
*
|
|
* @param value: Boolean ...
|
|
*/
|
|
void AllowDrawResistanceZones(bool value)
|
|
{
|
|
mAllowDrawResistanceZones = value;
|
|
}
|
|
|
|
/**
|
|
* Get Resistance Zone Loopback ...
|
|
*
|
|
* @return ( int )
|
|
*/
|
|
int ResistanceZoneLoopBack()
|
|
{
|
|
return mResistanceZoneLoopBack;
|
|
}
|
|
|
|
/**
|
|
* Set Resistance Zone Loopback ...
|
|
*
|
|
* @param value: Integer ...
|
|
*/
|
|
void ResistanceZoneLoopBack(int value)
|
|
{
|
|
//
|
|
if (value < 10)
|
|
{
|
|
value = 10;
|
|
}
|
|
|
|
//
|
|
mResistanceZoneLoopBack = value;
|
|
}
|
|
|
|
/**
|
|
* Get Resistance Zone Width ...
|
|
*
|
|
* @return ( int )
|
|
*/
|
|
int ResistanceZoneWidth()
|
|
{
|
|
return mResistanceZoneWidth;
|
|
}
|
|
|
|
/**
|
|
* Set Resistance Zone Width ...
|
|
*
|
|
* @param value: Integer ...
|
|
*/
|
|
void ResistanceZoneWidth(int value)
|
|
{
|
|
//
|
|
if (value < 1)
|
|
{
|
|
value = 1;
|
|
}
|
|
|
|
//
|
|
mResistanceZoneWidth = value;
|
|
}
|
|
|
|
/**
|
|
* Get Resistance Zone Color ...
|
|
*
|
|
* @return ( color )
|
|
*/
|
|
color ResistanceZoneColor()
|
|
{
|
|
return mResistanceZoneColor;
|
|
}
|
|
|
|
/**
|
|
* Set Resistance Zone Color ...
|
|
*
|
|
* @param value: Color ...
|
|
*/
|
|
void ResistanceZoneColor(color value)
|
|
{
|
|
mResistanceZoneColor = value;
|
|
}
|
|
|
|
/**
|
|
* Get Resistance Zone Style ...
|
|
*
|
|
* @return ( ENUM_LINE_STYLE )
|
|
*/
|
|
ENUM_LINE_STYLE ResistanceZoneStyle()
|
|
{
|
|
return mResistanceZoneStyle;
|
|
}
|
|
|
|
/**
|
|
* Set Resistance Zone Style ...
|
|
*
|
|
* @param value: ENUM_LINE_STYLE member ...
|
|
*/
|
|
void ResistanceZoneStyle(ENUM_LINE_STYLE value)
|
|
{
|
|
mResistanceZoneStyle = value;
|
|
}
|
|
|
|
/**
|
|
* Get Resistance Zone Price Type ...
|
|
*
|
|
* @return ( ENUM_LINE_STYLE )
|
|
*/
|
|
ENUM_X_PRICE ResistanceZonePriceType()
|
|
{
|
|
return mResistanceZonePriceType;
|
|
}
|
|
|
|
/**
|
|
* Set Resistance Zone Price Type ...
|
|
*
|
|
* @param value: ENUM_X_PRICE member ...
|
|
*/
|
|
void ResistanceZonePriceType(ENUM_X_PRICE value)
|
|
{
|
|
mResistanceZonePriceType = value;
|
|
}
|
|
|
|
//
|
|
// Supply Zone ...
|
|
|
|
/**
|
|
* Get Draw Supply Zone State ...
|
|
*
|
|
* @return ( bool )
|
|
*/
|
|
bool AllowDrawSupplyZones()
|
|
{
|
|
return mAllowDrawSupplyZones;
|
|
}
|
|
|
|
/**
|
|
* Set Draw Supply Zone State ...
|
|
*
|
|
* @param value: Boolean ...
|
|
*/
|
|
void AllowDrawSupplyZones(bool value)
|
|
{
|
|
mAllowDrawSupplyZones = value;
|
|
}
|
|
|
|
/**
|
|
* Get Supply Zone Width ...
|
|
*
|
|
* @return ( int )
|
|
*/
|
|
int SupplyZoneWidth()
|
|
{
|
|
return mSupplyZoneWidth;
|
|
}
|
|
|
|
/**
|
|
* Set Supply Zone Width ...
|
|
*
|
|
* @param value: Integer ...
|
|
*/
|
|
void SupplyZoneWidth(int value)
|
|
{
|
|
//
|
|
if (value < 1)
|
|
{
|
|
value = 1;
|
|
}
|
|
|
|
//
|
|
mSupplyZoneWidth = value;
|
|
}
|
|
|
|
/**
|
|
* Get Supply Zone Color ...
|
|
*
|
|
* @return ( color )
|
|
*/
|
|
color SupplyZoneColor()
|
|
{
|
|
return mSupplyZoneColor;
|
|
}
|
|
|
|
/**
|
|
* Set Supply Zone Color ...
|
|
*
|
|
* @param value: Color ...
|
|
*/
|
|
void SupplyZoneColor(color value)
|
|
{
|
|
mSupplyZoneColor = value;
|
|
}
|
|
|
|
/**
|
|
* Get Supply Zone Style ...
|
|
*
|
|
* @return ( ENUM_LINE_STYLE )
|
|
*/
|
|
ENUM_LINE_STYLE SupplyZoneStyle()
|
|
{
|
|
return mSupplyZoneStyle;
|
|
}
|
|
|
|
/**
|
|
* Set Supply Zone Style ...
|
|
*
|
|
* @param value: ENUM_LINE_STYLE member ...
|
|
*/
|
|
void SupplyZoneStyle(ENUM_LINE_STYLE value)
|
|
{
|
|
mSupplyZoneStyle = value;
|
|
}
|
|
|
|
/**
|
|
* Get Supply Zone Detecting Period ...
|
|
*
|
|
* @return ( ENUM_TIMEFRAMES ) ...
|
|
*/
|
|
ENUM_TIMEFRAMES SupplyZonePeriod()
|
|
{
|
|
return mSupplyZonePeriod;
|
|
}
|
|
|
|
/**
|
|
* Set Supply Zone Detecting Period ...
|
|
*
|
|
* @param value: ENUM_TIMEFRAMES member ...
|
|
*/
|
|
void SupplyZonePeriod(ENUM_TIMEFRAMES value)
|
|
{
|
|
mSupplyZonePeriod = value;
|
|
}
|
|
|
|
//
|
|
// Demand Zone ...
|
|
|
|
/**
|
|
* Get Draw Demand Zone State ...
|
|
*
|
|
* @return ( bool )
|
|
*/
|
|
bool AllowDrawDemandZones()
|
|
{
|
|
return mAllowDrawDemandZones;
|
|
}
|
|
|
|
/**
|
|
* Set Draw Demand Zone State ...
|
|
*
|
|
* @param value: Boolean ...
|
|
*/
|
|
void AllowDrawDemandZones(bool value)
|
|
{
|
|
mAllowDrawDemandZones = value;
|
|
}
|
|
|
|
/**
|
|
* Get Demand Zone Width ...
|
|
*
|
|
* @return ( int )
|
|
*/
|
|
int DemandZoneWidth()
|
|
{
|
|
return mDemandZoneWidth;
|
|
}
|
|
|
|
/**
|
|
* Set Demand Zone Width ...
|
|
*
|
|
* @param value: Integer ...
|
|
*/
|
|
void DemandZoneWidth(int value)
|
|
{
|
|
//
|
|
if (value < 1)
|
|
{
|
|
value = 1;
|
|
}
|
|
|
|
//
|
|
mDemandZoneWidth = value;
|
|
}
|
|
|
|
/**
|
|
* Get Demand Zone Color ...
|
|
*
|
|
* @return ( color )
|
|
*/
|
|
color DemandZoneColor()
|
|
{
|
|
return mDemandZoneColor;
|
|
}
|
|
|
|
/**
|
|
* Set Demand Zone Color ...
|
|
*
|
|
* @param value: Color ...
|
|
*/
|
|
void DemandZoneColor(color value)
|
|
{
|
|
mDemandZoneColor = value;
|
|
}
|
|
|
|
/**
|
|
* Get Demand Zone Style ...
|
|
*
|
|
* @return ( ENUM_LINE_STYLE )
|
|
*/
|
|
ENUM_LINE_STYLE DemandZoneStyle()
|
|
{
|
|
return mDemandZoneStyle;
|
|
}
|
|
|
|
/**
|
|
* Set Demand Zone Style ...
|
|
*
|
|
* @param value: ENUM_LINE_STYLE member ...
|
|
*/
|
|
void DemandZoneStyle(ENUM_LINE_STYLE value)
|
|
{
|
|
mDemandZoneStyle = value;
|
|
}
|
|
|
|
/**
|
|
* Get Demand Zone Detecting Period ...
|
|
*
|
|
* @return ( ENUM_TIMEFRAMES ) ...
|
|
*/
|
|
ENUM_TIMEFRAMES DemandZonePeriod()
|
|
{
|
|
return mDemandZonePeriod;
|
|
}
|
|
|
|
/**
|
|
* Set Demand Zone Detecting Period ...
|
|
*
|
|
* @param value: ENUM_TIMEFRAMES member ...
|
|
*/
|
|
void DemandZonePeriod(ENUM_TIMEFRAMES value)
|
|
{
|
|
mDemandZonePeriod = value;
|
|
}
|
|
|
|
//
|
|
// Actions ...
|
|
|
|
/**
|
|
* Initialize POI Detector ...
|
|
*/
|
|
void Init()
|
|
{
|
|
//
|
|
// Detect Previous POI(s) ...
|
|
DetectRequiredPOIs();
|
|
}
|
|
|
|
/**
|
|
* Update POI(s) ...
|
|
*
|
|
* @param state: an Array Refrence of ENUM_XPOI_EVENTS members ...
|
|
*/
|
|
int Update(
|
|
ENUM_XPOI_EVENTS &state[] //
|
|
)
|
|
{
|
|
//
|
|
int result = 0;
|
|
|
|
//
|
|
Clean(state);
|
|
|
|
//
|
|
// Check Bar Tracker if Waits ...
|
|
if (!mBarTracker.IsNewBar())
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
int zIndex = 0;
|
|
int cIndex = zIndex + 1;
|
|
int pIndex = cIndex + 1;
|
|
|
|
//
|
|
datetime cTime = TimeCurrent();
|
|
|
|
//
|
|
XOHCL zBar;
|
|
bool isInited = zBar.Init(
|
|
mSymbol,
|
|
mPeriod,
|
|
zIndex //
|
|
);
|
|
if (!isInited)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
XOHCL cBar;
|
|
isInited = cBar.Init(
|
|
mSymbol,
|
|
mPeriod,
|
|
cIndex //
|
|
);
|
|
if (!isInited)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
XOHCL pBar;
|
|
isInited = pBar.Init(
|
|
mSymbol,
|
|
mPeriod,
|
|
pIndex //
|
|
);
|
|
if (!isInited)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
XOHCL zDayBar;
|
|
isInited = zDayBar.Init(
|
|
mSymbol,
|
|
PERIOD_D1,
|
|
zIndex //
|
|
);
|
|
if (!isInited)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Trading Days ...
|
|
|
|
//
|
|
int tradingDaysCount = ArraySize(mTradingDays);
|
|
int tradingDayIDX = HasTradeDay(zDayBar.time);
|
|
if (IsValidIndex(tradingDayIDX))
|
|
{
|
|
//
|
|
if (zBar.time == mTradingDays[tradingDayIDX].to)
|
|
{
|
|
//
|
|
Add(
|
|
X_TRADE_DAY_LAST_BAR,
|
|
state //
|
|
);
|
|
OnTradingDayEvent(X_TRADE_DAY_LAST_BAR);
|
|
NotifyTradingDayEventListeners(X_TRADE_DAY_LAST_BAR);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
//
|
|
// there isn't any Trading Day ...
|
|
// create one ...
|
|
|
|
//
|
|
XTradeDay tradeDay;
|
|
tradeDay.from = zDayBar.time;
|
|
tradeDay.to = zDayBar.GetLastBarTimeOfPeriod(mPeriod);
|
|
|
|
//
|
|
AddRef(
|
|
tradeDay,
|
|
mTradingDays //
|
|
);
|
|
|
|
//
|
|
DrawTradingDays();
|
|
|
|
//
|
|
// Notfy Day Started ...
|
|
if (zBar.time == zDayBar.time)
|
|
{
|
|
//
|
|
Add(
|
|
X_TRADE_DAY_FIRST_BAR,
|
|
state //
|
|
);
|
|
OnTradingDayEvent(X_TRADE_DAY_FIRST_BAR);
|
|
NotifyTradingDayEventListeners(X_TRADE_DAY_FIRST_BAR);
|
|
}
|
|
}
|
|
|
|
//
|
|
// Market Session ...
|
|
|
|
//
|
|
int marketSessionsCount = ArraySize(mMarketSessions);
|
|
int sessionsCount = ArraySize(mSessions);
|
|
bool isSessionFound = false;
|
|
if (IsValidSize(sessionsCount))
|
|
{
|
|
//
|
|
for (int i = 0; i < sessionsCount; i++)
|
|
{
|
|
//
|
|
XSession iSession = mSessions[i];
|
|
int marketSessionIDX = HasMarketSessionByStartTime(
|
|
iSession.session,
|
|
zBar.time //
|
|
);
|
|
|
|
//
|
|
if (!IsValidIndex(marketSessionIDX))
|
|
{
|
|
//
|
|
datetime zTimeGMT = GetUTCTime(zBar.time);
|
|
string zTimeString = GetTimeString(zTimeGMT);
|
|
|
|
//
|
|
bool isStarted = iSession.start == zTimeString;
|
|
|
|
//
|
|
if (isStarted)
|
|
{
|
|
//
|
|
XMarketSession iMarketSession;
|
|
iMarketSession.session = iSession.session;
|
|
iMarketSession.from = zBar.time;
|
|
|
|
//
|
|
int iSessionWorkingHoure = SessionOpenHours();
|
|
int iSessionWorkingSeconds = iSessionWorkingHoure * 60 * 60;
|
|
iMarketSession.to = (datetime)((int)zBar.time + iSessionWorkingSeconds);
|
|
|
|
//
|
|
isSessionFound = AddRef(
|
|
iMarketSession,
|
|
mMarketSessions //
|
|
);
|
|
|
|
//
|
|
marketSessionsCount = ArraySize(mMarketSessions);
|
|
|
|
//
|
|
DrawMarketSessions();
|
|
|
|
//
|
|
Add(
|
|
X_SESSION_FIRST_BAR,
|
|
state //
|
|
);
|
|
OnMarketSessionEvent(
|
|
iMarketSession.session,
|
|
X_SESSION_FIRST_BAR //
|
|
);
|
|
NotifyMarketSessionEventListeners(
|
|
iMarketSession.session,
|
|
X_SESSION_FIRST_BAR //
|
|
);
|
|
}
|
|
}
|
|
|
|
//
|
|
// Check End Time for Last Bar ...
|
|
for (int i = 0; i < marketSessionsCount; i++)
|
|
{
|
|
//
|
|
XMarketSession iMarketSession = mMarketSessions[i];
|
|
|
|
//
|
|
// Calculate Last Bar Time ...
|
|
datetime endTime = iMarketSession.to;
|
|
datetime lastBarTime = (datetime)((int)endTime - PeriodSeconds(mPeriod));
|
|
if (zBar.time == lastBarTime)
|
|
{
|
|
//
|
|
Add(
|
|
X_SESSION_LAST_BAR,
|
|
state //
|
|
);
|
|
OnMarketSessionEvent(
|
|
iMarketSession.session,
|
|
X_SESSION_LAST_BAR //
|
|
);
|
|
NotifyMarketSessionEventListeners(
|
|
iMarketSession.session,
|
|
X_SESSION_LAST_BAR //
|
|
);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
//
|
|
// Swing Highs and Lows ...
|
|
|
|
//
|
|
// Swing Highs ...
|
|
|
|
//
|
|
int swingHighsCount = ArraySize(mSwingHighs);
|
|
bool isSingHigh = pBar.IsSimpleSwingHigh(SwingHighThreshold());
|
|
if (isSingHigh)
|
|
{
|
|
//
|
|
AddRef(
|
|
pBar,
|
|
mSwingHighs //
|
|
);
|
|
swingHighsCount = ArraySize(mSwingHighs);
|
|
|
|
//
|
|
DrawSwingHighs();
|
|
|
|
//
|
|
Add(
|
|
X_SWING_HIGH_DETECTED,
|
|
state //
|
|
);
|
|
OnSwingHighEvent(X_SWING_HIGH_DETECTED, pBar);
|
|
NotifySwingHighEventListeners(X_SWING_HIGH_DETECTED, pBar);
|
|
}
|
|
|
|
//
|
|
// Swing Lows ...
|
|
|
|
//
|
|
int swingLowsCount = ArraySize(mSwingLows);
|
|
bool isSingLow = pBar.IsSimpleSwingLow(SwingLowThreshold());
|
|
if (isSingLow)
|
|
{
|
|
//
|
|
AddRef(
|
|
pBar,
|
|
mSwingLows //
|
|
);
|
|
swingLowsCount = ArraySize(mSwingLows);
|
|
|
|
//
|
|
DrawSwingLows();
|
|
|
|
//
|
|
Add(
|
|
X_SWING_LOW_DETECTED,
|
|
state //
|
|
);
|
|
OnSwingLowEvent(X_SWING_LOW_DETECTED, pBar);
|
|
NotifySwingLowEventListeners(X_SWING_LOW_DETECTED, pBar);
|
|
}
|
|
|
|
//
|
|
// Momentum Bars ...
|
|
|
|
//
|
|
int momentumBarsCount = ArraySize(mMomentumBars);
|
|
bool isStrongBar = cBar.IsStrong(MomentumBarPercent());
|
|
bool isSharpBullish = cBar.IsSharpBullish(
|
|
MomentumBarLoopBack(),
|
|
MomentumBarSharpRatio() //
|
|
);
|
|
bool isSharpBearish = cBar.IsSharpBearish(
|
|
MomentumBarLoopBack(),
|
|
MomentumBarSharpRatio() //
|
|
);
|
|
bool isMomentumBar =
|
|
isStrongBar &&
|
|
(isSharpBearish ||
|
|
isSharpBullish);
|
|
if (isMomentumBar)
|
|
{
|
|
//
|
|
AddRef(
|
|
cBar,
|
|
mMomentumBars //
|
|
);
|
|
momentumBarsCount = ArraySize(mMomentumBars);
|
|
|
|
//
|
|
DrawMomentumBars();
|
|
|
|
//
|
|
Add(
|
|
X_MOMENTUM_BAR_DETECTED,
|
|
state //
|
|
);
|
|
OnMomentumBarEvent(X_MOMENTUM_BAR_DETECTED, cBar);
|
|
NotifyMomentumBarEventListeners(X_MOMENTUM_BAR_DETECTED, cBar);
|
|
}
|
|
|
|
//
|
|
// Rejection Bars ...
|
|
|
|
//
|
|
int rejectionBarsCount = ArraySize(mRejectionBars);
|
|
int rejectionBarLoopBackBarIndex = RejectionBarLoopBack() + 1;
|
|
XOHCL iRBar;
|
|
bool isIRBarInited = iRBar.Init(
|
|
Symbol(),
|
|
Period(),
|
|
rejectionBarLoopBackBarIndex //
|
|
);
|
|
if (isIRBarInited)
|
|
{
|
|
//
|
|
bool isRejectionBar =
|
|
iRBar.HasStrongLowShadow(
|
|
RejectionBarPercent(),
|
|
RejectionBarLoopBack(),
|
|
RejectionBarSharpRatio() //
|
|
) ||
|
|
iRBar.HasStrongHighShadow(
|
|
RejectionBarPercent(),
|
|
RejectionBarLoopBack(),
|
|
RejectionBarSharpRatio() //
|
|
);
|
|
if (isRejectionBar)
|
|
{
|
|
//
|
|
AddRef(
|
|
iRBar,
|
|
mRejectionBars //
|
|
);
|
|
rejectionBarsCount = ArraySize(mRejectionBars);
|
|
|
|
//
|
|
DrawRejectionBars();
|
|
|
|
//
|
|
Add(
|
|
X_REJECTION_BAR_DETECTED,
|
|
state //
|
|
);
|
|
OnRejectionBarEvent(X_REJECTION_BAR_DETECTED, iRBar);
|
|
NotifyRejectionBarEventListeners(X_REJECTION_BAR_DETECTED, iRBar);
|
|
}
|
|
}
|
|
|
|
//
|
|
// Support and Resistance Zones ...
|
|
|
|
//
|
|
// Support Zones ...
|
|
|
|
//
|
|
int supportZonesCount = ArraySize(mSupportZones);
|
|
XOHCL support;
|
|
bool hasSupport = cBar.HasSupport(
|
|
support,
|
|
SupportZonePriceType(),
|
|
SupportZoneLoopBack() //
|
|
);
|
|
if (hasSupport)
|
|
{
|
|
//
|
|
bool isAdded = AddSupportZone(support);
|
|
if (isAdded)
|
|
{
|
|
//
|
|
supportZonesCount = ArraySize(mSupportZones);
|
|
|
|
//
|
|
DrawSupportZones();
|
|
|
|
//
|
|
Add(
|
|
X_SUPPORT_ZONE_DETECTED,
|
|
state //
|
|
);
|
|
OnSupportZoneEvent(X_SUPPORT_ZONE_DETECTED, support);
|
|
NotifySupportZoneEventListeners(X_SUPPORT_ZONE_DETECTED, support);
|
|
}
|
|
}
|
|
|
|
//
|
|
// Resistance Zone ...
|
|
|
|
//
|
|
int resistanceZonesCount = ArraySize(mResistanceZones);
|
|
XOHCL resistance;
|
|
bool hasResistance = cBar.HasResistance(
|
|
resistance,
|
|
ResistanceZonePriceType(),
|
|
ResistanceZoneLoopBack() //
|
|
);
|
|
if (hasResistance)
|
|
{
|
|
//
|
|
bool isAdded = AddResistanceZone(resistance);
|
|
if (isAdded)
|
|
{
|
|
//
|
|
resistanceZonesCount = ArraySize(mResistanceZones);
|
|
|
|
//
|
|
DrawResistanceZones();
|
|
|
|
//
|
|
Add(
|
|
X_RESISTANCE_ZONE_DETECTED,
|
|
state //
|
|
);
|
|
OnResistanceZoneEvent(X_RESISTANCE_ZONE_DETECTED, resistance);
|
|
NotifyResistanceZoneEventListeners(X_RESISTANCE_ZONE_DETECTED, resistance);
|
|
}
|
|
}
|
|
|
|
//
|
|
// Supply and Demand Zones ...
|
|
|
|
//
|
|
// Supply Zones ...
|
|
|
|
//
|
|
int supplyZonesCount = ArraySize(mSupplyZones);
|
|
datetime endTime = cBar.time;
|
|
XOHCL cSupplyBar;
|
|
bool isSupplyBarInited = cSupplyBar.Init(
|
|
Symbol(),
|
|
SupplyZonePeriod(),
|
|
0 //
|
|
);
|
|
if (isSupplyBarInited)
|
|
{
|
|
//
|
|
datetime lastSupplyBarTime = cSupplyBar
|
|
.GetLastBarTimeOfPeriod(Period());
|
|
if (zBar.time == lastSupplyBarTime)
|
|
{
|
|
//
|
|
datetime startTime = cSupplyBar.time;
|
|
int cSupplyZonePeriodIndex = iBarShift(
|
|
Symbol(),
|
|
Period(),
|
|
cSupplyBar.time //
|
|
);
|
|
|
|
//
|
|
// Find Swings ...
|
|
XOHCL swings[];
|
|
for (int i = 0; i < cSupplyZonePeriodIndex; i++)
|
|
{
|
|
//
|
|
XOHCL iBar;
|
|
bool isIBarInited = iBar.Init(
|
|
Symbol(),
|
|
Period(),
|
|
i //
|
|
);
|
|
if (!isIBarInited)
|
|
{
|
|
continue;
|
|
}
|
|
|
|
//
|
|
// Check is Bar Swing or not ...
|
|
bool isSwing = iBar.IsSimpleSwingHigh();
|
|
if (!isSwing)
|
|
{
|
|
continue;
|
|
}
|
|
|
|
//
|
|
AddRef(
|
|
iBar,
|
|
swings //
|
|
);
|
|
}
|
|
|
|
//
|
|
// Select Max Swing for Supply Zone ...
|
|
XOHCL selectedSwing;
|
|
int swingsCount = ArraySize(swings);
|
|
if (IsValidSize(swingsCount))
|
|
{
|
|
//
|
|
for (int i = 0; i < swingsCount; i++)
|
|
{
|
|
//
|
|
XOHCL iSwing = swings[i];
|
|
if (!selectedSwing.IsValid() ||
|
|
selectedSwing.high < iSwing.high)
|
|
{
|
|
selectedSwing = iSwing;
|
|
}
|
|
}
|
|
}
|
|
|
|
//
|
|
// Check Swing ...
|
|
if (selectedSwing.IsValid())
|
|
{
|
|
//
|
|
XZone zone;
|
|
bool isInited = zone.Init(
|
|
selectedSwing.high,
|
|
selectedSwing.low,
|
|
ToString(X_POI_SUPPLY_ZONE) + "_" + ToString(SupplyZonePeriod()),
|
|
startTime,
|
|
endTime //
|
|
);
|
|
if (isInited)
|
|
{
|
|
//
|
|
int zoneIDX = FindZoneIndex(
|
|
zone,
|
|
mSupplyZones //
|
|
);
|
|
|
|
//
|
|
if (!IsValidIndex(zoneIDX))
|
|
{
|
|
//
|
|
AddRef(
|
|
zone,
|
|
mSupplyZones //
|
|
);
|
|
|
|
//
|
|
supplyZonesCount = ArraySize(mSupplyZones);
|
|
|
|
//
|
|
DrawSupplyZones();
|
|
|
|
//
|
|
Add(
|
|
X_SUPPLY_ZONE_DETECTED,
|
|
state //
|
|
);
|
|
OnSupplyZoneEvent(X_SUPPLY_ZONE_DETECTED, zone);
|
|
NotifySupplyZoneEventListeners(X_SUPPLY_ZONE_DETECTED, zone);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
//
|
|
// Demand Zones ...
|
|
|
|
//
|
|
int demandZonesCount = ArraySize(mDemandZones);
|
|
endTime = cBar.time;
|
|
XOHCL cDemandBar;
|
|
bool isDemandBarInited = cDemandBar.Init(
|
|
Symbol(),
|
|
DemandZonePeriod(),
|
|
0 //
|
|
);
|
|
if (isDemandBarInited)
|
|
{
|
|
//
|
|
datetime lastDemandBarTime = cDemandBar
|
|
.GetLastBarTimeOfPeriod(Period());
|
|
if (zBar.time == lastDemandBarTime)
|
|
{
|
|
//
|
|
datetime startTime = cDemandBar.time;
|
|
int cDemandZonePeriodIndex = iBarShift(
|
|
Symbol(),
|
|
Period(),
|
|
cDemandBar.time //
|
|
);
|
|
|
|
//
|
|
// Find Swings ...
|
|
XOHCL swings[];
|
|
for (int i = 0; i < cDemandZonePeriodIndex; i++)
|
|
{
|
|
//
|
|
XOHCL iBar;
|
|
bool isIBarInited = iBar.Init(
|
|
Symbol(),
|
|
Period(),
|
|
i //
|
|
);
|
|
if (!isIBarInited)
|
|
{
|
|
continue;
|
|
}
|
|
|
|
//
|
|
// Check is Bar Swing or not ...
|
|
bool isSwing = iBar.IsSimpleSwingLow();
|
|
if (!isSwing)
|
|
{
|
|
continue;
|
|
}
|
|
|
|
//
|
|
AddRef(
|
|
iBar,
|
|
swings //
|
|
);
|
|
}
|
|
|
|
//
|
|
// Select Max Swing for Supply Zone ...
|
|
XOHCL selectedSwing;
|
|
int swingsCount = ArraySize(swings);
|
|
if (IsValidSize(swingsCount))
|
|
{
|
|
//
|
|
for (int i = 0; i < swingsCount; i++)
|
|
{
|
|
//
|
|
XOHCL iSwing = swings[i];
|
|
if (!selectedSwing.IsValid() ||
|
|
selectedSwing.low > iSwing.low)
|
|
{
|
|
selectedSwing = iSwing;
|
|
}
|
|
}
|
|
}
|
|
|
|
//
|
|
// Check Swing ...
|
|
if (selectedSwing.IsValid())
|
|
{
|
|
//
|
|
XZone zone;
|
|
bool isInited = zone.Init(
|
|
selectedSwing.high,
|
|
selectedSwing.low,
|
|
ToString(X_POI_DEMAND_ZONE) + "_" + ToString(SupplyZonePeriod()),
|
|
startTime,
|
|
endTime //
|
|
);
|
|
if (isInited)
|
|
{
|
|
//
|
|
int zoneIDX = FindZoneIndex(
|
|
zone,
|
|
mDemandZones //
|
|
);
|
|
|
|
//
|
|
if (!IsValidIndex(zoneIDX))
|
|
{
|
|
//
|
|
AddRef(
|
|
zone,
|
|
mDemandZones //
|
|
);
|
|
|
|
//
|
|
demandZonesCount = ArraySize(mDemandZones);
|
|
|
|
//
|
|
DrawDemandZones();
|
|
|
|
//
|
|
Add(
|
|
X_DEMAND_ZONE_DETECTED,
|
|
state //
|
|
);
|
|
OnDemandZoneEvent(X_DEMAND_ZONE_DETECTED, zone);
|
|
NotifyDemandZoneEventListeners(X_DEMAND_ZONE_DETECTED, zone);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
//
|
|
// ...
|
|
|
|
//
|
|
mBarTracker.Waits();
|
|
|
|
//
|
|
result = ArraySize(state);
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* Enable Draw All POI(s) ...
|
|
*/
|
|
void EnableDrawPOIs()
|
|
{
|
|
//
|
|
bool state = true;
|
|
|
|
//
|
|
AllowDrawSwingLows(state);
|
|
AllowDrawSwingHighs(state);
|
|
AllowDrawTradingDays(state);
|
|
AllowDrawSupplyZones(state);
|
|
AllowDrawDemandZones(state);
|
|
AllowDrawSupportZones(state);
|
|
AllowDrawMomentumBars(state);
|
|
AllowDrawRejectionBars(state);
|
|
AllowDrawMarketSessions(state);
|
|
AllowDrawResistanceZones(state);
|
|
|
|
//
|
|
// Sessions ...
|
|
int sessionsCount = ArraySize(mSessions);
|
|
if (IsValidSize(sessionsCount))
|
|
{
|
|
//
|
|
for (int i = 0; i < sessionsCount; i++)
|
|
{
|
|
//
|
|
mSessions[i].allowDraw = state;
|
|
}
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Disable Draw All POI(s) ...
|
|
*/
|
|
void DisableDrawPOIs()
|
|
{
|
|
//
|
|
bool state = false;
|
|
|
|
//
|
|
AllowDrawSwingLows(state);
|
|
AllowDrawSwingHighs(state);
|
|
AllowDrawTradingDays(state);
|
|
AllowDrawSupplyZones(state);
|
|
AllowDrawDemandZones(state);
|
|
AllowDrawSupportZones(state);
|
|
AllowDrawMomentumBars(state);
|
|
AllowDrawRejectionBars(state);
|
|
AllowDrawMarketSessions(state);
|
|
AllowDrawResistanceZones(state);
|
|
|
|
//
|
|
// Sessions ...
|
|
int sessionsCount = ArraySize(mSessions);
|
|
if (IsValidSize(sessionsCount))
|
|
{
|
|
//
|
|
for (int i = 0; i < sessionsCount; i++)
|
|
{
|
|
//
|
|
mSessions[i].allowDraw = state;
|
|
}
|
|
}
|
|
}
|
|
|
|
//
|
|
// Virtual Actions ...
|
|
|
|
/**
|
|
* Apply Default Configurations ...
|
|
*/
|
|
virtual void ApplyDefaultConfig()
|
|
{
|
|
//
|
|
// Common ...
|
|
|
|
//
|
|
ChartID(0);
|
|
Window(0);
|
|
|
|
//
|
|
MaxNumberOfPOIs(10);
|
|
MaxNumberOfRequiredPOIs(2);
|
|
|
|
//
|
|
// Trading Days ...
|
|
TradingDaysStartColor(clrYellow);
|
|
TradingDaysStartStyle(STYLE_DASHDOT);
|
|
TradingDaysEndColor(clrGray);
|
|
TradingDaysEndStyle(STYLE_DASHDOT);
|
|
|
|
//
|
|
// Sessions ...
|
|
|
|
//
|
|
// SYDNEY ...
|
|
// Start: (UTC) 21:00
|
|
// End: (UTC) 06:00
|
|
XSession mSyndeySession;
|
|
mSyndeySession.Init(
|
|
X_SYDNEY,
|
|
"20:00", // Start ...
|
|
"05:00" // End Next Day ...
|
|
);
|
|
mSyndeySession.startColor = clrFireBrick;
|
|
mSyndeySession.endColor = clrFireBrick;
|
|
mSyndeySession.allowDraw = true;
|
|
AddSession(mSyndeySession);
|
|
|
|
//
|
|
// TOKYO ...
|
|
// Start: (UTC) 12:00
|
|
// End: (UTC) 09:00
|
|
XSession mTokyoSession;
|
|
mTokyoSession.Init(
|
|
X_TOKYO,
|
|
"00:00", // Start ...
|
|
"09:00" // End Next Day ...
|
|
);
|
|
mTokyoSession.startColor = clrBlueViolet;
|
|
mTokyoSession.endColor = clrBlueViolet;
|
|
mTokyoSession.allowDraw = true;
|
|
AddSession(mTokyoSession);
|
|
|
|
//
|
|
// LONDON ...
|
|
// Start: (UTC) 07:00
|
|
// End: (UTC) 16:00
|
|
XSession mLondonSession;
|
|
mLondonSession.Init(
|
|
X_LONDON,
|
|
"07:00", // Start ...
|
|
"16:00" // End ...
|
|
);
|
|
mLondonSession.startColor = clrLime;
|
|
mLondonSession.endColor = clrLime;
|
|
mLondonSession.allowDraw = true;
|
|
AddSession(mLondonSession);
|
|
|
|
//
|
|
// NEWYORK ...
|
|
// Start: (UTC) 13:00
|
|
// End: (UTC) 22:00
|
|
XSession mNewYorkSession;
|
|
mNewYorkSession.Init(
|
|
X_NEW_YORK,
|
|
"12:00", // Start ...
|
|
"21:00" // End ...
|
|
);
|
|
mNewYorkSession.startColor = clrAqua;
|
|
mNewYorkSession.endColor = clrAqua;
|
|
mNewYorkSession.allowDraw = true;
|
|
AddSession(mNewYorkSession);
|
|
|
|
//
|
|
SessionOpenHours(9);
|
|
|
|
//
|
|
// Swing High and Low (s) ...
|
|
|
|
//
|
|
// Swing Highs ...
|
|
SwingHighWidth(5);
|
|
SwingHighThreshold(3);
|
|
SwingHighArrowCode(108);
|
|
SwingHighColor(clrMagenta);
|
|
|
|
//
|
|
// Swing Lows ...
|
|
SwingLowWidth(5);
|
|
SwingLowThreshold(3);
|
|
SwingLowArrowCode(108);
|
|
SwingLowColor(clrAqua);
|
|
|
|
//
|
|
// Momentum Bars ...
|
|
MomentumBarPercent(55);
|
|
MomentumBarLoopBack(3);
|
|
MomentumBarSharpRatio(1.2);
|
|
MomentumBarWidth(5);
|
|
MomentumBarBullishArrowCode((char)225);
|
|
MomentumBarBearishArrowCode((char)226);
|
|
MomentumBarBullishColor(clrAqua);
|
|
MomentumBarBearishColor(clrMagenta);
|
|
|
|
//
|
|
// Rejection Bars ...
|
|
RejectionBarPercent(55);
|
|
RejectionBarLoopBack(5);
|
|
RejectionBarSharpRatio(1.5);
|
|
RejectionBarWidth(5);
|
|
RejectionBarBullishArrowCode((char)217);
|
|
RejectionBarBearishArrowCode((char)218);
|
|
RejectionBarBullishColor(clrAqua);
|
|
RejectionBarBearishColor(clrMagenta);
|
|
|
|
//
|
|
// Support and Resistance Zones ...
|
|
|
|
//
|
|
// Support Zones ...
|
|
SupportZoneLoopBack(52);
|
|
SupportZoneWidth(1);
|
|
SupportZoneColor(clrLime);
|
|
SupportZoneStyle(STYLE_DOT);
|
|
SupportZonePriceType(X_PRICE_CLOSE);
|
|
|
|
//
|
|
// Resistance Zones ...
|
|
ResistanceZoneLoopBack(52);
|
|
ResistanceZoneWidth(1);
|
|
ResistanceZoneColor(clrRed);
|
|
ResistanceZoneStyle(STYLE_DOT);
|
|
ResistanceZonePriceType(X_PRICE_CLOSE);
|
|
|
|
//
|
|
// Supply and Deman Zones ...
|
|
|
|
//
|
|
// Supply Zones ...
|
|
SupplyZoneWidth(1);
|
|
SupplyZoneColor(clrDarkRed);
|
|
SupplyZoneStyle(STYLE_DASH);
|
|
SupplyZonePeriod(GetHindMostPeriod(Period()));
|
|
|
|
//
|
|
// Demand Zones ...
|
|
DemandZoneWidth(1);
|
|
DemandZoneColor(clrDarkGreen);
|
|
DemandZoneStyle(STYLE_DASH);
|
|
DemandZonePeriod(GetHindMostPeriod(Period()));
|
|
|
|
//
|
|
}
|
|
|
|
//
|
|
// Session Configurations ...
|
|
|
|
/**
|
|
* Add Sepcific Session to Supported Sessions ...
|
|
*
|
|
* @param session: XSession instance ...
|
|
*/
|
|
void AddSession(XSession &session)
|
|
{
|
|
//
|
|
if (!session.IsValid())
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
AddRef(
|
|
session,
|
|
mSessions //
|
|
);
|
|
}
|
|
|
|
//
|
|
// Event Listeners ...
|
|
|
|
//
|
|
// Trading Days ...
|
|
|
|
/**
|
|
* Calls When new Trading Day Event Happens ...
|
|
*
|
|
* @param event: ENUM_XPOI_EVENTS member ...
|
|
*/
|
|
virtual void OnTradingDayEvent(
|
|
ENUM_XPOI_EVENTS event //
|
|
)
|
|
{
|
|
}
|
|
|
|
/**
|
|
* Register an Event Listener for New Trading Day Events ...
|
|
*
|
|
* @param listener: TXPOIEventHandler instance ...
|
|
*/
|
|
void AddTradingDayEventListener(TXPOIEventHandler listener)
|
|
{
|
|
//
|
|
Add(
|
|
listener,
|
|
mTradingDayEventListeners //
|
|
);
|
|
}
|
|
|
|
//
|
|
// Market Sessions ...
|
|
|
|
/**
|
|
* Calls When new Market Session Event Happens ...
|
|
*
|
|
* @param session: ENUM_XSESSION member ...
|
|
* @param event: ENUM_XPOI_EVENTS member ...
|
|
*/
|
|
virtual void OnMarketSessionEvent(
|
|
ENUM_XSESSION session,
|
|
ENUM_XPOI_EVENTS event //
|
|
)
|
|
{
|
|
}
|
|
|
|
/**
|
|
* Register an Event Listener for New Market Session Events ...
|
|
*
|
|
* @param listener: TXSessionEventHandler instance ...
|
|
*/
|
|
void AddMarketSessionEventListener(TXSessionEventHandler listener)
|
|
{
|
|
//
|
|
Add(
|
|
listener,
|
|
mMarketSessionEventListeners //
|
|
);
|
|
}
|
|
|
|
//
|
|
// Swings ...
|
|
|
|
//
|
|
// Swing Highs ...
|
|
|
|
/**
|
|
* Calls When new Swing High Event ...
|
|
*
|
|
* @param event: ENUM_XPOI_EVENTS member ...
|
|
* @param bar: XOHCL instance ...
|
|
*/
|
|
virtual void OnSwingHighEvent(
|
|
ENUM_XPOI_EVENTS event,
|
|
XOHCL &bar //
|
|
)
|
|
{
|
|
}
|
|
|
|
/**
|
|
* Register an Event Listener for New Swing High Event ...
|
|
*
|
|
* @param listener: TXOHCLEventHandler instance ...
|
|
*/
|
|
void AddSwingHighEventListener(TXOHCLEventHandler listener)
|
|
{
|
|
//
|
|
Add(
|
|
listener,
|
|
mSwingHighEventListeners //
|
|
);
|
|
}
|
|
|
|
//
|
|
// Swing Lows ...
|
|
|
|
/**
|
|
* Calls When new Swing Low Detected ...
|
|
*
|
|
* @param event: ENUM_XPOI_EVENTS member ...
|
|
* @param bar: XOHCL instance ...
|
|
*/
|
|
virtual void OnSwingLowEvent(
|
|
ENUM_XPOI_EVENTS event,
|
|
XOHCL &bar //
|
|
)
|
|
{
|
|
}
|
|
|
|
/**
|
|
* Register an Event Listener for New Swing Low Event ...
|
|
*
|
|
* @param listener: TXOHCLEventHandler instance ...
|
|
*/
|
|
void AddSwingLowEventListener(TXOHCLEventHandler listener)
|
|
{
|
|
//
|
|
Add(
|
|
listener,
|
|
mSwingLowEventListeners //
|
|
);
|
|
}
|
|
|
|
//
|
|
// Momentum Bar ...
|
|
|
|
/**
|
|
* Calls When new Momentum Bar Event ...
|
|
*
|
|
* @param event: ENUM_XPOI_EVENTS member ...
|
|
* @param bar: XOHCL instance ...
|
|
*/
|
|
virtual void OnMomentumBarEvent(
|
|
ENUM_XPOI_EVENTS event,
|
|
XOHCL &bar //
|
|
)
|
|
{
|
|
}
|
|
|
|
/**
|
|
* Register an Event Listener for New Momentum Bar Event ...
|
|
*
|
|
* @param listener: TXOHCLEventHandler instance ...
|
|
*/
|
|
void AddMomentumBarEventListener(TXOHCLEventHandler listener)
|
|
{
|
|
//
|
|
Add(
|
|
listener,
|
|
mMomentumBarEventListeners //
|
|
);
|
|
}
|
|
|
|
//
|
|
// Rejection Bar ...
|
|
|
|
/**
|
|
* Calls When new Rejection Bar Event ...
|
|
*
|
|
* @param event: ENUM_XPOI_EVENTS member ...
|
|
* @param bar: XOHCL instance ...
|
|
*/
|
|
virtual void OnRejectionBarEvent(
|
|
ENUM_XPOI_EVENTS event,
|
|
XOHCL &bar //
|
|
)
|
|
{
|
|
}
|
|
|
|
/**
|
|
* Register an Event Listener for New Rejection Bar Event ...
|
|
*
|
|
* @param listener: TXOHCLEventHandler instance ...
|
|
*/
|
|
void AddRejectionBarEventListener(TXOHCLEventHandler listener)
|
|
{
|
|
//
|
|
Add(
|
|
listener,
|
|
mRejectionBarEventListeners //
|
|
);
|
|
}
|
|
|
|
//
|
|
// Support and Resistance Zones ...
|
|
|
|
//
|
|
// Support Zones ...
|
|
|
|
/**
|
|
* Calls When new Support Zone Event ...
|
|
*
|
|
* @param event: ENUM_XPOI_EVENTS member ...
|
|
* @param bar: XOHCL instance ...
|
|
*/
|
|
virtual void OnSupportZoneEvent(
|
|
ENUM_XPOI_EVENTS event,
|
|
XOHCL &bar //
|
|
)
|
|
{
|
|
}
|
|
|
|
/**
|
|
* Register an Event Listener for New Support Zone Event ...
|
|
*
|
|
* @param listener: TXOHCLEventHandler instance ...
|
|
*/
|
|
void AddSupportZoneEventListener(TXOHCLEventHandler listener)
|
|
{
|
|
//
|
|
Add(
|
|
listener,
|
|
mSupportZoneEventListeners //
|
|
);
|
|
}
|
|
|
|
//
|
|
// Resistance Zones ...
|
|
|
|
/**
|
|
* Calls When new Resistance Zone Event ...
|
|
*
|
|
* @param event: ENUM_XPOI_EVENTS member ...
|
|
* @param bar: XOHCL instance ...
|
|
*/
|
|
virtual void OnResistanceZoneEvent(
|
|
ENUM_XPOI_EVENTS event,
|
|
XOHCL &bar //
|
|
)
|
|
{
|
|
}
|
|
|
|
/**
|
|
* Register an Event Listener for New Resistance Zone Event ...
|
|
*
|
|
* @param listener: TXOHCLEventHandler instance ...
|
|
*/
|
|
void AddResistanceZoneEventListener(TXOHCLEventHandler listener)
|
|
{
|
|
//
|
|
Add(
|
|
listener,
|
|
mResistanceZoneEventListeners //
|
|
);
|
|
}
|
|
|
|
//
|
|
// Supply and Demand Zones ...
|
|
|
|
//
|
|
// Supply Zones ...
|
|
|
|
/**
|
|
* Calls When new Supply Zone Event ...
|
|
*
|
|
* @param event: ENUM_XPOI_EVENTS member ...
|
|
* @param zone: XZone instance ...
|
|
*/
|
|
virtual void OnSupplyZoneEvent(
|
|
ENUM_XPOI_EVENTS event,
|
|
XZone &zone //
|
|
)
|
|
{
|
|
}
|
|
|
|
/**
|
|
* Register an Event Listener for New Supply Zone Event ...
|
|
*
|
|
* @param listener: TXZoneEventHandler instance ...
|
|
*/
|
|
void AddSupplyZoneEventListener(TXZoneEventHandler listener)
|
|
{
|
|
//
|
|
Add(
|
|
listener,
|
|
mSupplyZoneEventListeners //
|
|
);
|
|
}
|
|
|
|
//
|
|
// Demand Zones ...
|
|
|
|
/**
|
|
* Calls When new Demand Zone Event ...
|
|
*
|
|
* @param event: ENUM_XPOI_EVENTS member ...
|
|
* @param zone: XZone instance ...
|
|
*/
|
|
virtual void OnDemandZoneEvent(
|
|
ENUM_XPOI_EVENTS event,
|
|
XZone &zone //
|
|
)
|
|
{
|
|
}
|
|
|
|
/**
|
|
* Register an Event Listener for New Demand Zone Event ...
|
|
*
|
|
* @param listener: TXZoneEventHandler instance ...
|
|
*/
|
|
// void AddDemandZoneEventListener(TXZoneEventHandler listener)
|
|
// {
|
|
// //
|
|
// Add(
|
|
// listener,
|
|
// mDemandZoneEventListeners //
|
|
// );
|
|
// }
|
|
|
|
//
|
|
protected:
|
|
//
|
|
|
|
//
|
|
// Actions ...
|
|
|
|
/**
|
|
* Lock ...
|
|
*/
|
|
void Lock()
|
|
{
|
|
mLock = true;
|
|
}
|
|
|
|
/**
|
|
* Unlock ...
|
|
*/
|
|
void Unlock()
|
|
{
|
|
mLock = false;
|
|
}
|
|
|
|
/**
|
|
* Detect Required POI(s) ...
|
|
*
|
|
* @param barIndex: Integer Start bar index ...
|
|
* 0 is Default ...
|
|
*/
|
|
void DetectRequiredPOIs(int barIndex = 0)
|
|
{
|
|
//
|
|
// Validate Reuired POI(s) ...
|
|
int requiredPOIs = MaxNumberOfRequiredPOIs();
|
|
if (requiredPOIs <= 0)
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
Lock();
|
|
|
|
//
|
|
// Normalize Bar Index ...
|
|
if (barIndex < 0)
|
|
{
|
|
barIndex = 0;
|
|
}
|
|
|
|
//
|
|
bool canContinue = true;
|
|
while (canContinue)
|
|
{
|
|
//
|
|
// Define Index of Bars ...
|
|
int zIndex = barIndex;
|
|
int cIndex = zIndex + 1;
|
|
|
|
//
|
|
datetime cTime = TimeCurrent();
|
|
|
|
//
|
|
XOHCL zBar;
|
|
bool isRetrieved = mBarTracker.GetBar(zBar, zIndex);
|
|
if (!isRetrieved)
|
|
{
|
|
break;
|
|
}
|
|
|
|
//
|
|
XOHCL cBar;
|
|
isRetrieved = mBarTracker.GetBar(cBar, cIndex);
|
|
if (!isRetrieved)
|
|
{
|
|
break;
|
|
}
|
|
|
|
//
|
|
// Detect POI(s) based On Current Bar ...
|
|
|
|
//
|
|
// Trade Days ...
|
|
int daysCount = ArraySize(mTradingDays);
|
|
if (daysCount < requiredPOIs)
|
|
{
|
|
//
|
|
XOHCL zDayBar;
|
|
isRetrieved = zDayBar.Init(
|
|
mSymbol,
|
|
PERIOD_D1,
|
|
zIndex //
|
|
);
|
|
if (!isRetrieved)
|
|
{
|
|
break;
|
|
}
|
|
|
|
//
|
|
XOHCL cDayBar;
|
|
isRetrieved = cDayBar.Init(
|
|
mSymbol,
|
|
PERIOD_D1,
|
|
cIndex //
|
|
);
|
|
if (!isRetrieved)
|
|
{
|
|
break;
|
|
}
|
|
|
|
//
|
|
XTradeDay tradeDay;
|
|
tradeDay.from = zDayBar.time;
|
|
|
|
//
|
|
datetime lastBarTime = zDayBar.GetLastBarTimeOfPeriod(mPeriod);
|
|
tradeDay.to = lastBarTime;
|
|
|
|
//
|
|
int idx = HasTradeDay(tradeDay.from);
|
|
if (!IsValidIndex(idx))
|
|
{
|
|
//
|
|
AddRef(
|
|
tradeDay,
|
|
mTradingDays //
|
|
);
|
|
|
|
//
|
|
daysCount = ArraySize(mTradingDays);
|
|
}
|
|
}
|
|
|
|
//
|
|
// Market Sessions ...
|
|
int sessionsCount = ArraySize(mSessions);
|
|
int marketSessionsCount = ArraySize(mMarketSessions);
|
|
if (IsValidSize(sessionsCount) &&
|
|
marketSessionsCount < sessionsCount * requiredPOIs)
|
|
{
|
|
//
|
|
for (int i = 0; i < sessionsCount; i++)
|
|
{
|
|
//
|
|
XSession iSession = mSessions[i];
|
|
int iCount = CountMarketSessions(iSession.session);
|
|
if (iCount >= requiredPOIs)
|
|
{
|
|
continue;
|
|
}
|
|
|
|
//
|
|
datetime zTimeGMT = GetUTCTime(zBar.time);
|
|
string zTimeString = GetTimeString(zTimeGMT);
|
|
|
|
//
|
|
bool isStarted = iSession.start == zTimeString;
|
|
bool isEnded = iSession.end == zTimeString;
|
|
|
|
//
|
|
// Detect Sessions Based on Time ...
|
|
// Since All Session Close Times Related to Current Date and
|
|
// in Required POIs we Moving Back from Current Date ...
|
|
if (isEnded && iCount < requiredPOIs)
|
|
{
|
|
//
|
|
// Check Market Session Doesnt Exists by End Time ...
|
|
int iIDX = HasMarketSessionByEndTime(
|
|
iSession.session,
|
|
zBar.time //
|
|
);
|
|
if (!IsValidIndex(iIDX))
|
|
{
|
|
//
|
|
XMarketSession iMarketSession;
|
|
iMarketSession.session = iSession.session;
|
|
iMarketSession.to = zBar.time;
|
|
|
|
//
|
|
int iSessionWorkingHoure = SessionOpenHours();
|
|
int iSessionWorkingSeconds = iSessionWorkingHoure * 60 * 60;
|
|
iMarketSession.from = (datetime)((int)zBar.time - iSessionWorkingSeconds);
|
|
|
|
//
|
|
AddRef(
|
|
iMarketSession,
|
|
mMarketSessions //
|
|
);
|
|
|
|
//
|
|
marketSessionsCount = ArraySize(mMarketSessions);
|
|
}
|
|
}
|
|
|
|
//
|
|
}
|
|
}
|
|
|
|
//
|
|
// Swning Highs and Lows ...
|
|
|
|
//
|
|
// Swing Highs ...
|
|
int swingHighsCount = ArraySize(mSwingHighs);
|
|
if (swingHighsCount < requiredPOIs)
|
|
{
|
|
//
|
|
bool isSwingHigh = cBar.IsSimpleSwingHigh(SwingHighThreshold());
|
|
if (isSwingHigh)
|
|
{
|
|
//
|
|
AddRef(
|
|
cBar,
|
|
mSwingHighs //
|
|
);
|
|
|
|
//
|
|
swingHighsCount = ArraySize(mSwingHighs);
|
|
}
|
|
}
|
|
|
|
//
|
|
// Swing Lows ...
|
|
int swingLowsCount = ArraySize(mSwingLows);
|
|
if (swingLowsCount < requiredPOIs)
|
|
{
|
|
//
|
|
bool isSwingLow = cBar.IsSimpleSwingLow(SwingLowThreshold());
|
|
if (isSwingLow)
|
|
{
|
|
//
|
|
AddRef(
|
|
cBar,
|
|
mSwingLows //
|
|
);
|
|
|
|
//
|
|
swingLowsCount = ArraySize(mSwingLows);
|
|
}
|
|
}
|
|
|
|
//
|
|
// Momentum Bars ...
|
|
int momentumBarsCount = ArraySize(mMomentumBars);
|
|
if (momentumBarsCount < requiredPOIs)
|
|
{
|
|
//
|
|
bool isStrongBar = cBar.IsStrong(MomentumBarPercent());
|
|
|
|
//
|
|
// Bullish ...
|
|
bool isSharpBullish = cBar.IsSharpBullish(
|
|
MomentumBarLoopBack(),
|
|
MomentumBarSharpRatio() //
|
|
);
|
|
|
|
//
|
|
// Bearish ...
|
|
bool isSharpBearish = cBar.IsSharpBearish(
|
|
MomentumBarLoopBack(),
|
|
MomentumBarSharpRatio() //
|
|
);
|
|
|
|
//
|
|
bool isMomentumBar =
|
|
isStrongBar &&
|
|
(isSharpBearish ||
|
|
isSharpBullish);
|
|
if (isMomentumBar)
|
|
{
|
|
//
|
|
AddRef(
|
|
cBar,
|
|
mMomentumBars //
|
|
);
|
|
|
|
//
|
|
momentumBarsCount = ArraySize(mMomentumBars);
|
|
}
|
|
}
|
|
|
|
//
|
|
// Rejection Bars ...
|
|
int rejectionBarsCount = ArraySize(mRejectionBars);
|
|
if (rejectionBarsCount < requiredPOIs)
|
|
{
|
|
//
|
|
bool isRejectionBar =
|
|
cBar.HasStrongLowShadow(
|
|
RejectionBarPercent(),
|
|
RejectionBarLoopBack(),
|
|
RejectionBarSharpRatio() //
|
|
) ||
|
|
cBar.HasStrongHighShadow(
|
|
RejectionBarPercent(),
|
|
RejectionBarLoopBack(),
|
|
RejectionBarSharpRatio() //
|
|
);
|
|
|
|
//
|
|
if (isRejectionBar)
|
|
{
|
|
//
|
|
AddRef(
|
|
cBar,
|
|
mRejectionBars //
|
|
);
|
|
|
|
//
|
|
rejectionBarsCount = ArraySize(mRejectionBars);
|
|
}
|
|
}
|
|
|
|
//
|
|
// Support nad Resistance Zones ...
|
|
|
|
//
|
|
// Support Zones ...
|
|
int supportZonesCount = ArraySize(mSupportZones);
|
|
if (supportZonesCount < requiredPOIs)
|
|
{
|
|
//
|
|
XOHCL support;
|
|
bool hasSupport = cBar.HasSupport(
|
|
support,
|
|
SupportZonePriceType(),
|
|
SupportZoneLoopBack() //
|
|
);
|
|
|
|
//
|
|
if (hasSupport)
|
|
{
|
|
//
|
|
bool isAdded = AddSupportZone(support);
|
|
if (isAdded)
|
|
{
|
|
supportZonesCount = ArraySize(mSupportZones);
|
|
}
|
|
}
|
|
}
|
|
|
|
//
|
|
// Resistance Zones ...
|
|
int resistanceZonesCount = ArraySize(mResistanceZones);
|
|
if (resistanceZonesCount < requiredPOIs)
|
|
{
|
|
//
|
|
XOHCL resistance;
|
|
bool hasResistance = cBar.HasResistance(
|
|
resistance,
|
|
ResistanceZonePriceType(),
|
|
ResistanceZoneLoopBack() //
|
|
);
|
|
|
|
//
|
|
if (hasResistance)
|
|
{
|
|
//
|
|
bool isAdded = AddResistanceZone(resistance);
|
|
if (isAdded)
|
|
{
|
|
resistanceZonesCount = ArraySize(mResistanceZones);
|
|
}
|
|
}
|
|
}
|
|
|
|
//
|
|
// Supply and Demand Zones ...
|
|
|
|
//
|
|
// Supply Zones ...
|
|
int supplyZonesCount = ArraySize(mSupplyZones);
|
|
if (supplyZonesCount < requiredPOIs)
|
|
{
|
|
//
|
|
datetime endTime = cBar.time;
|
|
|
|
//
|
|
datetime cSupplyZoneStartTime = iTime(
|
|
Symbol(),
|
|
SupplyZonePeriod(),
|
|
supplyZonesCount + 1 //
|
|
);
|
|
datetime startTime = cSupplyZoneStartTime;
|
|
|
|
//
|
|
int cSupplyZoneStartIndex = iBarShift(
|
|
Symbol(),
|
|
Period(),
|
|
cSupplyZoneStartTime //
|
|
);
|
|
|
|
//
|
|
XOHCL swings[];
|
|
for (int i = 0; i < cSupplyZoneStartIndex; i++)
|
|
{
|
|
//
|
|
XOHCL iBar;
|
|
bool isIBarInited = iBar.Init(
|
|
Symbol(),
|
|
Period(),
|
|
i //
|
|
);
|
|
if (!isIBarInited)
|
|
{
|
|
continue;
|
|
}
|
|
|
|
//
|
|
// Check is Bar Swing or not ...
|
|
bool isSwing = iBar.IsSimpleSwingHigh();
|
|
if (!isSwing)
|
|
{
|
|
continue;
|
|
}
|
|
|
|
//
|
|
AddRef(
|
|
iBar,
|
|
swings //
|
|
);
|
|
}
|
|
|
|
//
|
|
XOHCL selectedSwing;
|
|
int swingsCount = ArraySize(swings);
|
|
if (IsValidSize(swingsCount))
|
|
{
|
|
//
|
|
for (int i = 0; i < swingsCount; i++)
|
|
{
|
|
//
|
|
XOHCL iSwing = swings[i];
|
|
if (!selectedSwing.IsValid() ||
|
|
selectedSwing.high < iSwing.high)
|
|
{
|
|
selectedSwing = iSwing;
|
|
}
|
|
}
|
|
}
|
|
|
|
//
|
|
if (selectedSwing.IsValid())
|
|
{
|
|
//
|
|
XZone zone;
|
|
bool isInited = zone.Init(
|
|
selectedSwing.high,
|
|
selectedSwing.low,
|
|
ToString(X_POI_SUPPLY_ZONE) + "_" + ToString(SupplyZonePeriod()),
|
|
startTime,
|
|
endTime //
|
|
);
|
|
if (isInited)
|
|
{
|
|
//
|
|
AddRef(
|
|
zone,
|
|
mSupplyZones //
|
|
);
|
|
|
|
//
|
|
supplyZonesCount = ArraySize(mSupplyZones);
|
|
}
|
|
}
|
|
}
|
|
|
|
//
|
|
// Demand Zones ...
|
|
int demandZonesCount = ArraySize(mDemandZones);
|
|
if (demandZonesCount < requiredPOIs)
|
|
{
|
|
//
|
|
datetime endTime = cBar.time;
|
|
|
|
//
|
|
datetime cDemandZoneStartTime = iTime(
|
|
Symbol(),
|
|
DemandZonePeriod(),
|
|
demandZonesCount + 1 //
|
|
);
|
|
datetime startTime = cDemandZoneStartTime;
|
|
|
|
//
|
|
int cDemandZoneStartIndex = iBarShift(
|
|
Symbol(),
|
|
Period(),
|
|
cDemandZoneStartTime //
|
|
);
|
|
|
|
//
|
|
XOHCL swings[];
|
|
for (int i = 0; i < cDemandZoneStartIndex; i++)
|
|
{
|
|
//
|
|
XOHCL iBar;
|
|
bool isIBarInited = iBar.Init(
|
|
Symbol(),
|
|
Period(),
|
|
i //
|
|
);
|
|
if (!isIBarInited)
|
|
{
|
|
continue;
|
|
}
|
|
|
|
//
|
|
// Check is Bar Swing or not ...
|
|
bool isSwing = iBar.IsSimpleSwingLow();
|
|
if (!isSwing)
|
|
{
|
|
continue;
|
|
}
|
|
|
|
//
|
|
AddRef(
|
|
iBar,
|
|
swings //
|
|
);
|
|
}
|
|
|
|
//
|
|
XOHCL selectedSwing;
|
|
int swingsCount = ArraySize(swings);
|
|
if (IsValidSize(swingsCount))
|
|
{
|
|
//
|
|
for (int i = 0; i < swingsCount; i++)
|
|
{
|
|
//
|
|
XOHCL iSwing = swings[i];
|
|
if (!selectedSwing.IsValid() ||
|
|
selectedSwing.low > iSwing.low)
|
|
{
|
|
selectedSwing = iSwing;
|
|
}
|
|
}
|
|
}
|
|
|
|
//
|
|
if (selectedSwing.IsValid())
|
|
{
|
|
//
|
|
XZone zone;
|
|
bool isInited = zone.Init(
|
|
selectedSwing.high,
|
|
selectedSwing.low,
|
|
ToString(X_POI_DEMAND_ZONE) + "_" + ToString(SupplyZonePeriod()),
|
|
startTime,
|
|
endTime //
|
|
);
|
|
if (isInited)
|
|
{
|
|
//
|
|
AddRef(
|
|
zone,
|
|
mDemandZones //
|
|
);
|
|
|
|
//
|
|
demandZonesCount = ArraySize(mDemandZones);
|
|
}
|
|
}
|
|
}
|
|
|
|
//
|
|
// Detect Required Conditions for Loop ...
|
|
//
|
|
|
|
//
|
|
// Market Sessions Requirements ...
|
|
bool isNeedMoreMarketSessions = (!IsValidSize(sessionsCount)
|
|
? true
|
|
: marketSessionsCount < (sessionsCount * requiredPOIs));
|
|
canContinue =
|
|
//
|
|
// Trade Days ...
|
|
daysCount < requiredPOIs ||
|
|
//
|
|
// Market Sessions ...
|
|
isNeedMoreMarketSessions ||
|
|
//
|
|
// Swing High and Low (s) ...
|
|
swingHighsCount < requiredPOIs ||
|
|
swingLowsCount < requiredPOIs ||
|
|
//
|
|
// Momentum Bars ...
|
|
momentumBarsCount < requiredPOIs ||
|
|
//
|
|
// Rejection Bars ...
|
|
rejectionBarsCount < requiredPOIs ||
|
|
//
|
|
// Support and Resistance Zones ...
|
|
supportZonesCount < requiredPOIs ||
|
|
resistanceZonesCount < requiredPOIs ||
|
|
//
|
|
// Supply and Demand Zones ...
|
|
supplyZonesCount < requiredPOIs ||
|
|
demandZonesCount < requiredPOIs
|
|
//
|
|
;
|
|
if (canContinue)
|
|
{
|
|
barIndex++;
|
|
}
|
|
}
|
|
|
|
//
|
|
int errorArr[];
|
|
if (canContinue)
|
|
{
|
|
//
|
|
int t = errorArr[5];
|
|
}
|
|
|
|
//
|
|
// Complete Calculations ...
|
|
|
|
//
|
|
// Reverse Trading Days ...
|
|
XTradeDay tmpDays[];
|
|
Copy(
|
|
mTradingDays,
|
|
tmpDays //
|
|
);
|
|
Clean(mTradingDays);
|
|
ArrayReverse(tmpDays);
|
|
Copy(
|
|
tmpDays,
|
|
mTradingDays //
|
|
);
|
|
Clean(tmpDays);
|
|
|
|
//
|
|
// Reverse Market Sessions ...
|
|
XMarketSession tmpSessions[];
|
|
Copy(
|
|
mMarketSessions,
|
|
tmpSessions //
|
|
);
|
|
Clean(mMarketSessions);
|
|
ArrayReverse(tmpSessions);
|
|
Copy(
|
|
tmpSessions,
|
|
mMarketSessions //
|
|
);
|
|
|
|
//
|
|
XOHCL tmpBars[];
|
|
|
|
//
|
|
// Reverse Swing Highs ...
|
|
Copy(
|
|
mSwingHighs,
|
|
tmpBars //
|
|
);
|
|
Clean(mSwingHighs);
|
|
ArrayReverse(tmpBars);
|
|
Copy(
|
|
tmpBars,
|
|
mSwingHighs //
|
|
);
|
|
Clean(tmpBars);
|
|
|
|
//
|
|
// Reverse Swing Lows ...
|
|
Copy(
|
|
mSwingLows,
|
|
tmpBars //
|
|
);
|
|
Clean(mSwingLows);
|
|
ArrayReverse(tmpBars);
|
|
Copy(
|
|
tmpBars,
|
|
mSwingLows //
|
|
);
|
|
Clean(tmpBars);
|
|
|
|
//
|
|
// Reverse Momentum Bars ...
|
|
Copy(
|
|
mMomentumBars,
|
|
tmpBars //
|
|
);
|
|
Clean(mMomentumBars);
|
|
ArrayReverse(tmpBars);
|
|
Copy(
|
|
tmpBars,
|
|
mMomentumBars //
|
|
);
|
|
Clean(tmpBars);
|
|
|
|
//
|
|
// Reverse Rejection Bars ...
|
|
Copy(
|
|
mRejectionBars,
|
|
tmpBars //
|
|
);
|
|
Clean(mRejectionBars);
|
|
ArrayReverse(tmpBars);
|
|
Copy(
|
|
tmpBars,
|
|
mRejectionBars //
|
|
);
|
|
Clean(tmpBars);
|
|
|
|
//
|
|
// Reverse Support Zones ...
|
|
Copy(
|
|
mSupportZones,
|
|
tmpBars //
|
|
);
|
|
Clean(mSupportZones);
|
|
ArrayReverse(tmpBars);
|
|
Copy(
|
|
tmpBars,
|
|
mSupportZones //
|
|
);
|
|
Clean(tmpBars);
|
|
|
|
//
|
|
// Reverse Resistance Zones ...
|
|
Copy(
|
|
mResistanceZones,
|
|
tmpBars //
|
|
);
|
|
Clean(mResistanceZones);
|
|
ArrayReverse(tmpBars);
|
|
Copy(
|
|
tmpBars,
|
|
mResistanceZones //
|
|
);
|
|
Clean(tmpBars);
|
|
|
|
//
|
|
XZone tmpZones[];
|
|
|
|
//
|
|
// Supply and Demand Zones ...
|
|
|
|
//
|
|
Copy(
|
|
mSupplyZones,
|
|
tmpZones //
|
|
);
|
|
Clean(mSupplyZones);
|
|
ArrayReverse(tmpZones);
|
|
Copy(
|
|
tmpZones,
|
|
mSupplyZones //
|
|
);
|
|
Clean(tmpZones);
|
|
|
|
//
|
|
Copy(
|
|
mDemandZones,
|
|
tmpZones //
|
|
);
|
|
Clean(mDemandZones);
|
|
ArrayReverse(tmpZones);
|
|
Copy(
|
|
tmpZones,
|
|
mDemandZones //
|
|
);
|
|
Clean(tmpZones);
|
|
|
|
//
|
|
// ...
|
|
|
|
//
|
|
Unlock();
|
|
DrawPOIs();
|
|
}
|
|
|
|
//
|
|
// Destroy POIs ...
|
|
|
|
/**
|
|
* Destroy All POI(s) ...
|
|
*/
|
|
void DestroyPOIs()
|
|
{
|
|
//
|
|
DestroyTradingDays();
|
|
|
|
//
|
|
DestroyMarketSessions();
|
|
|
|
//
|
|
DestroySwingHighs();
|
|
DestroySwingLows();
|
|
|
|
//
|
|
DestroyMomentumBars();
|
|
|
|
//
|
|
DestroyRejectionBars();
|
|
|
|
//
|
|
DestroySupportZones();
|
|
DestroyResistanceZones();
|
|
|
|
//
|
|
DestroySupplyZones();
|
|
DestroyDemandZones();
|
|
}
|
|
|
|
/**
|
|
* Destroy Trading Days ...
|
|
*/
|
|
void DestroyTradingDays()
|
|
{
|
|
Clean(mTradingDays);
|
|
}
|
|
|
|
/**
|
|
* Destroy Swing Highs ...
|
|
*/
|
|
void DestroySwingHighs()
|
|
{
|
|
Clean(mSwingHighs);
|
|
}
|
|
|
|
/**
|
|
* Destroy Swing Lows ...
|
|
*/
|
|
void DestroySwingLows()
|
|
{
|
|
Clean(mSwingLows);
|
|
}
|
|
|
|
/**
|
|
* Destroy Momentum Bars ...
|
|
*/
|
|
void DestroyMomentumBars()
|
|
{
|
|
Clean(mMomentumBars);
|
|
}
|
|
|
|
/**
|
|
* Destroy Rejection Bars ...
|
|
*/
|
|
void DestroyRejectionBars()
|
|
{
|
|
Clean(mRejectionBars);
|
|
}
|
|
|
|
/**
|
|
* Destroy Market Sessions ...
|
|
*/
|
|
void DestroyMarketSessions()
|
|
{
|
|
Clean(mMarketSessions);
|
|
}
|
|
|
|
/**
|
|
* Destroy Support Zones ...
|
|
*/
|
|
void DestroySupportZones()
|
|
{
|
|
Clean(mSupportZones);
|
|
}
|
|
|
|
/**
|
|
* Destroy Resistance Zones ...
|
|
*/
|
|
void DestroyResistanceZones()
|
|
{
|
|
Clean(mResistanceZones);
|
|
}
|
|
|
|
/**
|
|
* Destroy Supply Zones ...
|
|
*/
|
|
void DestroySupplyZones()
|
|
{
|
|
Clean(mSupplyZones);
|
|
}
|
|
|
|
/**
|
|
* Destroy Demand Zones ...
|
|
*/
|
|
void DestroyDemandZones()
|
|
{
|
|
Clean(mDemandZones);
|
|
}
|
|
|
|
//
|
|
// Draw Actions ...
|
|
|
|
/**
|
|
* Draw All POI(s) ...
|
|
*/
|
|
void DrawPOIs()
|
|
{
|
|
//
|
|
DrawTradingDays();
|
|
|
|
//
|
|
DrawMarketSessions();
|
|
|
|
//
|
|
DrawSwingHighs();
|
|
DrawSwingLows();
|
|
|
|
//
|
|
DrawMomentumBars();
|
|
|
|
//
|
|
DrawRejectionBars();
|
|
|
|
//
|
|
DrawSupportZones();
|
|
DrawResistanceZones();
|
|
|
|
//
|
|
DrawSupplyZones();
|
|
DrawDemandZones();
|
|
}
|
|
|
|
/**
|
|
* Draw Trading Days ...
|
|
*/
|
|
void DrawTradingDays()
|
|
{
|
|
//
|
|
bool allow = AllowDrawTradingDays();
|
|
if (!allow)
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
int count = ArraySize(mTradingDays);
|
|
if (!IsValidSize(count))
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
//
|
|
XTradeDay iDay = mTradingDays[i];
|
|
|
|
//
|
|
string iName = iDay.GetTag();
|
|
int iIDX = HasObject(
|
|
iName,
|
|
mTradingDayObjects //
|
|
);
|
|
if (IsValidIndex(iIDX))
|
|
{
|
|
continue;
|
|
}
|
|
|
|
//
|
|
CreateTradingDayObject(iDay, iName);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Draw Swing Highs ...
|
|
*/
|
|
void DrawSwingHighs()
|
|
{
|
|
//
|
|
bool allow = AllowDrawSwingHighs();
|
|
if (!allow)
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
int count = ArraySize(mSwingHighs);
|
|
if (!IsValidSize(count))
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
//
|
|
XOHCL iSwing = mSwingHighs[i];
|
|
|
|
//
|
|
string iName = iSwing.GetTag(ToString(X_POI_SWING_HIGH));
|
|
int iIDX = HasObject(
|
|
iName,
|
|
mSwingHighObjects //
|
|
);
|
|
if (IsValidIndex(iIDX))
|
|
{
|
|
continue;
|
|
}
|
|
|
|
//
|
|
CreateSwingHighObject(iSwing, iName);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Draw Swing Lows ...
|
|
*/
|
|
void DrawSwingLows()
|
|
{
|
|
//
|
|
bool allow = AllowDrawSwingLows();
|
|
if (!allow)
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
int count = ArraySize(mSwingLows);
|
|
if (!IsValidSize(count))
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
//
|
|
XOHCL iSwing = mSwingLows[i];
|
|
|
|
//
|
|
string iName = iSwing.GetTag(ToString(X_POI_SWING_LOW));
|
|
int iIDX = HasObject(
|
|
iName,
|
|
mSwingLowObjects //
|
|
);
|
|
if (IsValidIndex(iIDX))
|
|
{
|
|
continue;
|
|
}
|
|
|
|
//
|
|
CreateSwingLowObject(iSwing, iName);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Draw Momentum Bars ...
|
|
*/
|
|
void DrawMomentumBars()
|
|
{
|
|
//
|
|
bool allow = AllowDrawMomentumBars();
|
|
if (!allow)
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
int count = ArraySize(mMomentumBars);
|
|
if (!IsValidSize(count))
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
//
|
|
XOHCL iBar = mMomentumBars[i];
|
|
|
|
//
|
|
string iName = iBar.GetTag(ToString(X_POI_MOMENTUM_BAR));
|
|
int iIDX = HasObject(
|
|
iName,
|
|
mMomentumBarObjects //
|
|
);
|
|
if (IsValidIndex(iIDX))
|
|
{
|
|
continue;
|
|
}
|
|
|
|
//
|
|
CreateMomentumBarObject(iBar, iName);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Draw Rejection Bars ...
|
|
*/
|
|
void DrawRejectionBars()
|
|
{
|
|
//
|
|
bool allow = AllowDrawRejectionBars();
|
|
if (!allow)
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
int count = ArraySize(mRejectionBars);
|
|
if (!IsValidSize(count))
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
//
|
|
XOHCL iBar = mRejectionBars[i];
|
|
|
|
//
|
|
string iName = iBar.GetTag(ToString(X_POI_REJECTION_BAR));
|
|
int iIDX = HasObject(
|
|
iName,
|
|
mRejectionBarObjects //
|
|
);
|
|
if (IsValidIndex(iIDX))
|
|
{
|
|
continue;
|
|
}
|
|
|
|
//
|
|
CreateRejectionBarObject(iBar, iName);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Draw Market Sessions ...
|
|
*/
|
|
void DrawMarketSessions()
|
|
{
|
|
//
|
|
bool allow = AllowDrawMarketSessions();
|
|
if (!allow)
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
int count = ArraySize(mMarketSessions);
|
|
if (!IsValidSize(count))
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
//
|
|
XMarketSession iMarketSession = mMarketSessions[i];
|
|
|
|
//
|
|
string iName = iMarketSession.GetTag();
|
|
int iIDX = HasObject(
|
|
iName,
|
|
mMarketSessionObjects //
|
|
);
|
|
if (IsValidIndex(iIDX))
|
|
{
|
|
continue;
|
|
}
|
|
|
|
//
|
|
CreateMarketSessionObject(iMarketSession, iName);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Draw Support Zones ...
|
|
*/
|
|
void DrawSupportZones()
|
|
{
|
|
//
|
|
bool allow = AllowDrawSupportZones();
|
|
if (!allow)
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
int count = ArraySize(mSupportZones);
|
|
if (!IsValidSize(count))
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
//
|
|
XOHCL iSupportZone = mSupportZones[i];
|
|
|
|
//
|
|
string iName = iSupportZone.GetTag(ToString(X_POI_SUPPORT));
|
|
int iIDX = HasObject(
|
|
iName,
|
|
mSupportZoneObjects //
|
|
);
|
|
if (IsValidIndex(iIDX))
|
|
{
|
|
continue;
|
|
}
|
|
|
|
//
|
|
CreateSupportZoneObject(iSupportZone, iName);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Draw Resistance Zones ...
|
|
*/
|
|
void DrawResistanceZones()
|
|
{
|
|
//
|
|
bool allow = AllowDrawResistanceZones();
|
|
if (!allow)
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
int count = ArraySize(mResistanceZones);
|
|
if (!IsValidSize(count))
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
//
|
|
XOHCL iResistanceZone = mResistanceZones[i];
|
|
|
|
//
|
|
string iName = iResistanceZone.GetTag(ToString(X_POI_RESISTANCE));
|
|
int iIDX = HasObject(
|
|
iName,
|
|
mResistanceZoneObjects //
|
|
);
|
|
if (IsValidIndex(iIDX))
|
|
{
|
|
continue;
|
|
}
|
|
|
|
//
|
|
CreateResistanceZoneObject(iResistanceZone, iName);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Draw Supply Zones ...
|
|
*/
|
|
void DrawSupplyZones()
|
|
{
|
|
//
|
|
bool allow = AllowDrawSupplyZones();
|
|
if (!allow)
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
int count = ArraySize(mSupplyZones);
|
|
if (!IsValidSize(count))
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
//
|
|
XZone iSupplyZone = mSupplyZones[i];
|
|
|
|
//
|
|
string iName = iSupplyZone.GetTag();
|
|
int iIDX = HasObject(
|
|
iName,
|
|
mSupplyZoneObjects //
|
|
);
|
|
if (IsValidIndex(iIDX))
|
|
{
|
|
continue;
|
|
}
|
|
|
|
//
|
|
CreateSupplyZoneObject(iSupplyZone, iName);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Draw Demand Zones ...
|
|
*/
|
|
void DrawDemandZones()
|
|
{
|
|
//
|
|
bool allow = AllowDrawDemandZones();
|
|
if (!allow)
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
int count = ArraySize(mDemandZones);
|
|
if (!IsValidSize(count))
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
//
|
|
XZone iDemandZone = mDemandZones[i];
|
|
|
|
//
|
|
string iName = iDemandZone.GetTag();
|
|
int iIDX = HasObject(
|
|
iName,
|
|
mDemandZoneObjects //
|
|
);
|
|
if (IsValidIndex(iIDX))
|
|
{
|
|
continue;
|
|
}
|
|
|
|
//
|
|
CreateDemandZoneObject(iDemandZone, iName);
|
|
}
|
|
}
|
|
|
|
//
|
|
|
|
/**
|
|
* Clean All Drawn Objects ...
|
|
*/
|
|
void DestroyObjects()
|
|
{
|
|
//
|
|
DestroySwingLowObjects();
|
|
DestroySwingHighObjects();
|
|
DestroySupplyZoneObjects();
|
|
DestroyDemandZoneObjects();
|
|
DestroyMomentumBarObjects();
|
|
DestroySupportZoneObjects();
|
|
DestroyRejectionBarObjects();
|
|
DestroyMarketSessionObjects();
|
|
DestroyResistanceZoneObjects();
|
|
DestroyTradingTradingDayObjects();
|
|
}
|
|
|
|
/**
|
|
* Clean Swing Highs Drawn Objects ...
|
|
*/
|
|
void DestroySwingHighObjects()
|
|
{
|
|
mSwingHighObjects.Clear();
|
|
}
|
|
|
|
/**
|
|
* Clean Swing Lows Drawn Objects ...
|
|
*/
|
|
void DestroySwingLowObjects()
|
|
{
|
|
mSwingLowObjects.Clear();
|
|
}
|
|
|
|
/**
|
|
* Clean Momentum Bars Drawn Objects ...
|
|
*/
|
|
void DestroyMomentumBarObjects()
|
|
{
|
|
mMomentumBarObjects.Clear();
|
|
}
|
|
|
|
/**
|
|
* Clean Rejection Bars Drawn Objects ...
|
|
*/
|
|
void DestroyRejectionBarObjects()
|
|
{
|
|
mRejectionBarObjects.Clear();
|
|
}
|
|
|
|
/**
|
|
* Clean Trading Day Drawn Objects ...
|
|
*/
|
|
void DestroyTradingTradingDayObjects()
|
|
{
|
|
mTradingDayObjects.Clear();
|
|
}
|
|
|
|
/**
|
|
* Destroy Market Sessions Drawn Objects ...
|
|
*/
|
|
void DestroyMarketSessionObjects()
|
|
{
|
|
mMarketSessionObjects.Clear();
|
|
}
|
|
|
|
/**
|
|
* Destroy Support Zone Drawn Objects ...
|
|
*/
|
|
void DestroySupportZoneObjects()
|
|
{
|
|
mSupportZoneObjects.Clear();
|
|
}
|
|
|
|
/**
|
|
* Destroy Resistance Zone Drawn Objects ...
|
|
*/
|
|
void DestroyResistanceZoneObjects()
|
|
{
|
|
mResistanceZoneObjects.Clear();
|
|
}
|
|
|
|
/**
|
|
* Destroy Supply Zone Drawn Objects ...
|
|
*/
|
|
void DestroySupplyZoneObjects()
|
|
{
|
|
mSupplyZoneObjects.Clear();
|
|
}
|
|
|
|
/**
|
|
* Destroy Demand Zone Drawn Objects ...
|
|
*/
|
|
void DestroyDemandZoneObjects()
|
|
{
|
|
mDemandZoneObjects.Clear();
|
|
}
|
|
|
|
//
|
|
// ...
|
|
|
|
/**
|
|
* Detect an Object Exists in Array or not ...
|
|
*
|
|
* @param name: String ...
|
|
* @param array: CArrayObj instance ...
|
|
*
|
|
* @return ( int ): index of Object ...
|
|
*/
|
|
int HasObject(
|
|
string name,
|
|
CArrayObj &array //
|
|
)
|
|
{
|
|
//
|
|
int result = -1;
|
|
|
|
//
|
|
if (!IsValid(name))
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
int count = array.Total();
|
|
if (!IsValidSize(count))
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
//
|
|
CChartObject iObj = array.At(i);
|
|
|
|
//
|
|
if (iObj.Name() == name)
|
|
{
|
|
//
|
|
result = i;
|
|
break;
|
|
}
|
|
}
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Event Handler Notifiers ...
|
|
|
|
//
|
|
// Trading Days ...
|
|
|
|
/**
|
|
* Notify New Trading Day Event Handlers ...
|
|
*
|
|
* @param event: ENUM_XPOI_EVENTS member ...
|
|
*/
|
|
void NotifyTradingDayEventListeners(
|
|
ENUM_XPOI_EVENTS event //
|
|
)
|
|
{
|
|
//
|
|
int count = ArraySize(mTradingDayEventListeners);
|
|
if (!IsValidSize(count))
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
//
|
|
TXPOIEventHandler iListener = mTradingDayEventListeners[i];
|
|
iListener(event);
|
|
}
|
|
}
|
|
|
|
//
|
|
// Market Sessions ...
|
|
|
|
/**
|
|
* Notify New Market Session Event Handlers ...
|
|
*
|
|
* @param session: ENUM_XSESSION member ...
|
|
* @param event: ENUM_XPOI_EVENTS member ...
|
|
*/
|
|
void NotifyMarketSessionEventListeners(
|
|
ENUM_XSESSION session,
|
|
ENUM_XPOI_EVENTS event //
|
|
)
|
|
{
|
|
//
|
|
int count = ArraySize(mMarketSessionEventListeners);
|
|
if (!IsValidSize(count))
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
//
|
|
TXSessionEventHandler iListener = mMarketSessionEventListeners[i];
|
|
iListener(session, event);
|
|
}
|
|
}
|
|
|
|
//
|
|
// Swings ...
|
|
|
|
//
|
|
// Swing Highs ...
|
|
|
|
/**
|
|
* Notify New Swing High Point Event Handlers ...
|
|
*
|
|
* @param event: ENUM_XPOI_EVENTS member ...
|
|
* @param bar: XOHCL instance ...
|
|
*/
|
|
void NotifySwingHighEventListeners(
|
|
ENUM_XPOI_EVENTS event,
|
|
XOHCL &bar //
|
|
)
|
|
{
|
|
//
|
|
if (!bar.IsValid())
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
int count = ArraySize(mSwingHighEventListeners);
|
|
if (!IsValidSize(count))
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
//
|
|
TXOHCLEventHandler iListener = mSwingHighEventListeners[i];
|
|
iListener(event, bar);
|
|
}
|
|
}
|
|
|
|
//
|
|
// Swing Lows ...
|
|
|
|
/**
|
|
* Notify New Swing Low Point Event Handlers ...
|
|
*
|
|
* @param event: ENUM_XPOI_EVENTS member ...
|
|
* @param bar: XOHCL instance ...
|
|
*/
|
|
void NotifySwingLowEventListeners(
|
|
ENUM_XPOI_EVENTS event,
|
|
XOHCL &bar //
|
|
)
|
|
{
|
|
//
|
|
if (!bar.IsValid())
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
int count = ArraySize(mSwingLowEventListeners);
|
|
if (!IsValidSize(count))
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
//
|
|
TXOHCLEventHandler iListener = mSwingLowEventListeners[i];
|
|
iListener(event, bar);
|
|
}
|
|
}
|
|
|
|
//
|
|
// Momentum Bars ...
|
|
|
|
/**
|
|
* Notify New Momentum Bar Event Handlers ...
|
|
*
|
|
* @param event: ENUM_XPOI_EVENTS member ...
|
|
* @param bar: XOHCL instance ...
|
|
*/
|
|
void NotifyMomentumBarEventListeners(
|
|
ENUM_XPOI_EVENTS event,
|
|
XOHCL &bar //
|
|
)
|
|
{
|
|
//
|
|
if (!bar.IsValid())
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
int count = ArraySize(mMomentumBarEventListeners);
|
|
if (!IsValidSize(count))
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
//
|
|
TXOHCLEventHandler iListener = mMomentumBarEventListeners[i];
|
|
iListener(event, bar);
|
|
}
|
|
}
|
|
|
|
//
|
|
// Rejection Bars ...
|
|
|
|
/**
|
|
* Notify New Rejection Bar Event Handlers ...
|
|
*
|
|
* @param event: ENUM_XPOI_EVENTS member ...
|
|
* @param bar: XOHCL instance ...
|
|
*/
|
|
void NotifyRejectionBarEventListeners(
|
|
ENUM_XPOI_EVENTS event,
|
|
XOHCL &bar //
|
|
)
|
|
{
|
|
//
|
|
if (!bar.IsValid())
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
int count = ArraySize(mRejectionBarEventListeners);
|
|
if (!IsValidSize(count))
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
//
|
|
TXOHCLEventHandler iListener = mRejectionBarEventListeners[i];
|
|
iListener(event, bar);
|
|
}
|
|
}
|
|
|
|
//
|
|
// Support and Resistance Zones ...
|
|
|
|
//
|
|
// Support Zones ...
|
|
|
|
/**
|
|
* Notify New Support Zone Event Handlers ...
|
|
*
|
|
* @param event: ENUM_XPOI_EVENTS member ...
|
|
* @param bar: XOHCL instance ...
|
|
*/
|
|
void NotifySupportZoneEventListeners(
|
|
ENUM_XPOI_EVENTS event,
|
|
XOHCL &bar //
|
|
)
|
|
{
|
|
//
|
|
if (!bar.IsValid())
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
int count = ArraySize(mSupportZoneEventListeners);
|
|
if (!IsValidSize(count))
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
//
|
|
TXOHCLEventHandler iListener = mSupportZoneEventListeners[i];
|
|
iListener(event, bar);
|
|
}
|
|
}
|
|
|
|
//
|
|
// Resistance Zones ...
|
|
|
|
/**
|
|
* Notify New Resistance Zone Event Handlers ...
|
|
*
|
|
* @param event: ENUM_XPOI_EVENTS member ...
|
|
* @param bar: XOHCL instance ...
|
|
*/
|
|
void NotifyResistanceZoneEventListeners(
|
|
ENUM_XPOI_EVENTS event,
|
|
XOHCL &bar //
|
|
)
|
|
{
|
|
//
|
|
if (!bar.IsValid())
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
int count = ArraySize(mResistanceZoneEventListeners);
|
|
if (!IsValidSize(count))
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
//
|
|
TXOHCLEventHandler iListener = mResistanceZoneEventListeners[i];
|
|
iListener(event, bar);
|
|
}
|
|
}
|
|
|
|
//
|
|
// Supply and Demand Zones ...
|
|
|
|
//
|
|
// Supply Zones ...
|
|
|
|
/**
|
|
* Notify New Supply Zone Event Handlers ...
|
|
*
|
|
* @param event: ENUM_XPOI_EVENTS member ...
|
|
* @param bar: XZone instance ...
|
|
*/
|
|
void NotifySupplyZoneEventListeners(
|
|
ENUM_XPOI_EVENTS event,
|
|
XZone &zone //
|
|
)
|
|
{
|
|
//
|
|
if (!zone.IsValid())
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
int count = ArraySize(mSupplyZoneEventListeners);
|
|
if (!IsValidSize(count))
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
//
|
|
TXZoneEventHandler iListener = mSupplyZoneEventListeners[i];
|
|
iListener(event, zone);
|
|
}
|
|
}
|
|
|
|
//
|
|
// Demand Zones ...
|
|
|
|
/**
|
|
* Notify New Demand Zone Event Handlers ...
|
|
*
|
|
* @param event: ENUM_XPOI_EVENTS member ...
|
|
* @param bar: XZone instance ...
|
|
*/
|
|
void NotifyDemandZoneEventListeners(
|
|
ENUM_XPOI_EVENTS event,
|
|
XZone &zone //
|
|
)
|
|
{
|
|
//
|
|
if (!zone.IsValid())
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
int count = ArraySize(mDemandZoneEventListeners);
|
|
if (!IsValidSize(count))
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
//
|
|
TXZoneEventHandler iListener = mDemandZoneEventListeners[i];
|
|
iListener(event, zone);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Destroy all Registered Event Listeners ...
|
|
*/
|
|
void DestroyEventListeners()
|
|
{
|
|
//
|
|
Clean(mSwingLowEventListeners);
|
|
Clean(mSwingHighEventListeners);
|
|
Clean(mTradingDayEventListeners);
|
|
Clean(mSupplyZoneEventListeners);
|
|
Clean(mDemandZoneEventListeners);
|
|
Clean(mMomentumBarEventListeners);
|
|
Clean(mSupportZoneEventListeners);
|
|
Clean(mRejectionBarEventListeners);
|
|
Clean(mMarketSessionEventListeners);
|
|
Clean(mResistanceZoneEventListeners);
|
|
}
|
|
|
|
//
|
|
// ...
|
|
//
|
|
|
|
//
|
|
// Session ...
|
|
|
|
/**
|
|
* Find Specific Session Index ...
|
|
*
|
|
* @param session: ENUM_XSESSION member ...
|
|
*
|
|
* @return ( int )
|
|
*/
|
|
int FindSession(ENUM_XSESSION session)
|
|
{
|
|
//
|
|
int result = -1;
|
|
|
|
//
|
|
int count = ArraySize(mSessions);
|
|
if (!IsValidSize(count))
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
//
|
|
XSession iSession = mSessions[i];
|
|
|
|
//
|
|
if (iSession.session == session)
|
|
{
|
|
//
|
|
result = i;
|
|
break;
|
|
}
|
|
}
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* Destroy Sessions ...
|
|
*/
|
|
void DestroySessions()
|
|
{
|
|
Clean(mSessions);
|
|
}
|
|
|
|
/**
|
|
* Find Specified Trade Day based on Start Time ...
|
|
*
|
|
* @param start: DateTime ...
|
|
*
|
|
* @return ( int )
|
|
*/
|
|
int HasTradeDay(datetime start)
|
|
{
|
|
//
|
|
int result = -1;
|
|
|
|
//
|
|
if (!IsValid(start))
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
int count = ArraySize(mTradingDays);
|
|
if (!IsValidSize(count))
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
//
|
|
XTradeDay iDay = mTradingDays[i];
|
|
|
|
//
|
|
if (iDay.from == start)
|
|
{
|
|
//
|
|
result = i;
|
|
break;
|
|
}
|
|
}
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* Find Specified Trade Day based on End Time ...
|
|
*
|
|
* @param start: DateTime ...
|
|
*
|
|
* @return ( int )
|
|
*/
|
|
int HasTradeDayBayEndTime(datetime end)
|
|
{
|
|
//
|
|
int result = -1;
|
|
|
|
//
|
|
if (!IsValid(end))
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
int count = ArraySize(mTradingDays);
|
|
if (!IsValidSize(count))
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
//
|
|
XTradeDay iDay = mTradingDays[i];
|
|
|
|
//
|
|
if (iDay.to == end)
|
|
{
|
|
//
|
|
result = i;
|
|
break;
|
|
}
|
|
}
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
|
|
/**
|
|
* Find Market Session by Providing Start Time ...
|
|
*
|
|
* @param session: ENUM_XSESSION member ...
|
|
* @param start: DateTime ...
|
|
*
|
|
* @return ( int )
|
|
*/
|
|
int HasMarketSessionByStartTime(
|
|
ENUM_XSESSION session,
|
|
datetime start //
|
|
)
|
|
{
|
|
//
|
|
int result = -1;
|
|
|
|
//
|
|
if (!IsValid(start))
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
int count = ArraySize(mMarketSessions);
|
|
if (!IsValidSize(count))
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
//
|
|
XMarketSession iMarketSession = mMarketSessions[i];
|
|
|
|
//
|
|
if (iMarketSession.session == session &&
|
|
iMarketSession.from == start)
|
|
{
|
|
//
|
|
result = i;
|
|
break;
|
|
}
|
|
}
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* Find Market Session by Providing Start Time ...
|
|
*
|
|
* @param session: ENUM_XSESSION member ...
|
|
* @param end: DateTime ...
|
|
*
|
|
* @return ( int )
|
|
*/
|
|
int HasMarketSessionByEndTime(
|
|
ENUM_XSESSION session,
|
|
datetime end //
|
|
)
|
|
{
|
|
//
|
|
int result = -1;
|
|
|
|
//
|
|
if (!IsValid(end))
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
int count = ArraySize(mMarketSessions);
|
|
if (!IsValidSize(count))
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
//
|
|
XMarketSession iMarketSession = mMarketSessions[i];
|
|
|
|
//
|
|
if (iMarketSession.session == session &&
|
|
iMarketSession.to == end)
|
|
{
|
|
//
|
|
result = i;
|
|
break;
|
|
}
|
|
}
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* Count Specified Market Sessions ...
|
|
*
|
|
* @param session: ENUM_XSESSION member ...
|
|
*
|
|
* @return ( int )
|
|
*/
|
|
int CountMarketSessions(ENUM_XSESSION session)
|
|
{
|
|
//
|
|
int result = 0;
|
|
|
|
//
|
|
int count = ArraySize(mMarketSessions);
|
|
if (!IsValidSize(count))
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
//
|
|
XMarketSession iMarketSession = mMarketSessions[i];
|
|
|
|
//
|
|
if (iMarketSession.session == session)
|
|
{
|
|
result++;
|
|
}
|
|
}
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
|
|
/**
|
|
* Add Specific Support Zone if it's Not Exists ...
|
|
*
|
|
* @param support: XOHCL instance ...
|
|
*/
|
|
bool AddSupportZone(XOHCL &support)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
result = support.IsValid();
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
int idx = FindSupportZoneIndex(support);
|
|
result = !IsValidIndex(idx);
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
int before = ArraySize(mSupportZones);
|
|
int after = AddRef(
|
|
support,
|
|
mSupportZones //
|
|
);
|
|
|
|
//
|
|
result = before == after - 1;
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* Find Specific Support Zone Index ...
|
|
*
|
|
* @param support: XOHCL instance ...
|
|
*
|
|
* @return ( int )
|
|
*/
|
|
int FindSupportZoneIndex(XOHCL &support)
|
|
{
|
|
//
|
|
int result = -1;
|
|
|
|
//
|
|
if (!support.IsValid())
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
int count = ArraySize(mSupportZones);
|
|
if (!IsValidSize(count))
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
//
|
|
XOHCL iSupport = mSupportZones[i];
|
|
|
|
//
|
|
if (iSupport.low == support.low &&
|
|
iSupport.GetDown() == support.GetDown())
|
|
{
|
|
//
|
|
result = i;
|
|
break;
|
|
}
|
|
}
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* Add Specific Resistance Zone if it's Not Exists ...
|
|
*
|
|
* @param resistance: XOHCL instance ...
|
|
*/
|
|
bool AddResistanceZone(XOHCL &resistance)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
result = resistance.IsValid();
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
int idx = FindResistanceZoneIndex(resistance);
|
|
result = !IsValidIndex(idx);
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
int before = ArraySize(mResistanceZones);
|
|
int after = AddRef(
|
|
resistance,
|
|
mResistanceZones //
|
|
);
|
|
|
|
//
|
|
result = before == after - 1;
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* Find Specific Resistance Zone Index ...
|
|
*
|
|
* @param resistance: XOHCL instance ...
|
|
*
|
|
* @return ( int )
|
|
*/
|
|
int FindResistanceZoneIndex(XOHCL &resistance)
|
|
{
|
|
//
|
|
int result = -1;
|
|
|
|
//
|
|
if (!resistance.IsValid())
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
int count = ArraySize(mResistanceZones);
|
|
if (!IsValidSize(count))
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
//
|
|
XOHCL iResistance = mResistanceZones[i];
|
|
|
|
//
|
|
if (iResistance.high == resistance.high &&
|
|
iResistance.GetUp() == resistance.GetUp())
|
|
{
|
|
//
|
|
result = i;
|
|
break;
|
|
}
|
|
}
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
|
|
/**
|
|
* Find Specified Zone Index ...
|
|
*
|
|
* @param zone: XZone instance
|
|
* @param list: XZone Collection ...
|
|
*
|
|
* @return ( int )
|
|
*/
|
|
int FindZoneIndex(
|
|
XZone &zone,
|
|
XZone &list[] //
|
|
)
|
|
{
|
|
//
|
|
int result = -1;
|
|
|
|
//
|
|
int count = ArraySize(list);
|
|
if (!IsValidSize(count))
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
//
|
|
XZone iZone = list[i];
|
|
|
|
//
|
|
if (iZone.upper == zone.upper &&
|
|
iZone.lower == zone.lower)
|
|
{
|
|
//
|
|
result = i;
|
|
break;
|
|
}
|
|
}
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
private:
|
|
//
|
|
|
|
//
|
|
// Props ...
|
|
|
|
//
|
|
bool mLock; // Lock State ...
|
|
string mSymbol; // Market Symbol ...
|
|
ENUM_TIMEFRAMES mPeriod; // Market Period ...
|
|
long mChartID; // Chart ID ...
|
|
int mWindow; // Window ID ...
|
|
int mMaxNumberOfPOIs; // Max Allowed Number of POI(s) which Can Holds ...
|
|
int mMaxNumberOfRequiredPOIs; // Max Allowed Number of POI(s) which Must Find at Initializion Time ...
|
|
|
|
//
|
|
XBarTracker mBarTracker; // Market Bar Tracker ...
|
|
|
|
//
|
|
bool mAllowDrawTradingDays; // Draw Trading Days ...
|
|
color mTradingDaysStartColor; // Trading Days Start Color ...
|
|
ENUM_LINE_STYLE mTradingDaysStartStyle; // Trading Days Start Style ...
|
|
color mTradingDaysEndColor; // Trading Days End Color ...
|
|
ENUM_LINE_STYLE mTradingDaysEndStyle; // Trading Days End Style ...
|
|
XTradeDay mTradingDays[]; // Trading Days ...
|
|
CArrayObj mTradingDayObjects; // Trading Day Chart Objects ...
|
|
TXPOIEventHandler mTradingDayEventListeners[]; // Trading Day Event Listeners ...
|
|
|
|
/**
|
|
* Create an Object to Represent Trading Day on Chart ...
|
|
*
|
|
* @param day: XTradeDay instance ...
|
|
* @param name: String ...
|
|
*/
|
|
void CreateTradingDayObject(
|
|
XTradeDay &day,
|
|
string name //
|
|
)
|
|
{
|
|
//
|
|
if (!day.IsValid() ||
|
|
!IsValid(name))
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
XCTardeDayObject *iObj;
|
|
iObj = new XCTardeDayObject();
|
|
bool isCreated = iObj.CreateByDay(
|
|
ChartID(),
|
|
name,
|
|
Window(),
|
|
day //
|
|
);
|
|
if (!isCreated)
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
iObj.FromColor(TradingDaysStartColor());
|
|
iObj.FromStyle(TradingDaysStartStyle());
|
|
|
|
//
|
|
iObj.ToColor(TradingDaysEndColor());
|
|
iObj.ToStyle(TradingDaysEndStyle());
|
|
|
|
//
|
|
mTradingDayObjects.Add(iObj);
|
|
}
|
|
|
|
//
|
|
// Configure Sessions ...
|
|
bool mAllowDrawMarketSessions; // Draw Market Sessions ...
|
|
int mSessionOpenHours; // How many Hours a Session is Open
|
|
XSession mSessions[]; // Forex Sessions
|
|
XMarketSession mMarketSessions[]; // Founded Market Sessions ...
|
|
CArrayObj mMarketSessionObjects; // Founded Market Session Chart Ojects ...
|
|
TXSessionEventHandler mMarketSessionEventListeners[]; // Market Sessions Event Listeners ...
|
|
|
|
/**
|
|
* Create an Object to Represent Market Session on Chart ...
|
|
*
|
|
* @param session: XMarketSession instance ...
|
|
* @param name: String ...
|
|
*/
|
|
void CreateMarketSessionObject(
|
|
XMarketSession &session,
|
|
string name //
|
|
)
|
|
{
|
|
//
|
|
if (!session.IsValid() ||
|
|
!IsValid(name))
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
// Find XSession Instance ...
|
|
int sessionIDX = FindSession(session.session);
|
|
if (!IsValidIndex(sessionIDX) ||
|
|
!mSessions[sessionIDX].allowDraw)
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
XCMarketSessionObject *iObj;
|
|
iObj = new XCMarketSessionObject();
|
|
bool isCreated = iObj.CreateByMarketSession(
|
|
ChartID(),
|
|
name,
|
|
Window(),
|
|
session //
|
|
);
|
|
if (!isCreated)
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
iObj.FromColor(mSessions[sessionIDX].startColor);
|
|
iObj.FromStyle(mSessions[sessionIDX].startStyle);
|
|
|
|
//
|
|
iObj.ToColor(mSessions[sessionIDX].endColor);
|
|
iObj.ToStyle(mSessions[sessionIDX].endStyle);
|
|
|
|
//
|
|
mMarketSessionObjects.Add(iObj);
|
|
}
|
|
|
|
//
|
|
// POI Holders ...
|
|
|
|
//
|
|
// Swing Highs ...
|
|
|
|
bool mAllowDrawSwingHighs; // Draw Swing Highs ...
|
|
char mSwingHighArrowCode; // Swing High Arrow Code ...
|
|
color mSwingHighColor; // Swing High Color ...
|
|
int mSwingHighWidth; // Swing High Width ...
|
|
double mSwingHighThreshold; // Threshold Required for Swing High Detection ...
|
|
XOHCL mSwingHighs[]; // Swing Highs ...
|
|
CArrayObj mSwingHighObjects; // Swing High Chart Objects ...
|
|
TXOHCLEventHandler mSwingHighEventListeners[]; // Swing High Event Listeners ...
|
|
|
|
/**
|
|
* Create an Object to Represent Swing High on Chart ...
|
|
*
|
|
* @param bar: XOHCL instance ...
|
|
* @param name: String ...
|
|
*/
|
|
void CreateSwingHighObject(
|
|
XOHCL &bar,
|
|
string name //
|
|
)
|
|
{
|
|
//
|
|
if (!bar.IsValid() ||
|
|
!IsValid(name))
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
CChartObjectArrow *iObj;
|
|
iObj = new CChartObjectArrow();
|
|
bool isCreated = iObj.Create(
|
|
ChartID(),
|
|
name,
|
|
Window(),
|
|
bar.time,
|
|
bar.high,
|
|
SwingHighArrowCode() //
|
|
);
|
|
if (!isCreated)
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
// Configure Object ...
|
|
iObj.Width(SwingHighWidth());
|
|
iObj.Color(SwingHighColor());
|
|
iObj.Anchor(ANCHOR_BOTTOM);
|
|
|
|
//
|
|
mSwingHighObjects.Add(iObj);
|
|
}
|
|
|
|
//
|
|
// Swing Lows ...
|
|
|
|
bool mAllowDrawSwingLows; // Draw Swing Lows ...
|
|
char mSwingLowArrowCode; // Swing Low Arrow Code ...
|
|
color mSwingLowColor; // Swing Low Color ...
|
|
int mSwingLowWidth; // Swing Low Width ...
|
|
double mSwingLowThreshold; // Threshold Required for Swing Low Detection ...
|
|
XOHCL mSwingLows[]; // Swing Lows ...
|
|
CArrayObj mSwingLowObjects; // Swing Low Chart Objects ...
|
|
TXOHCLEventHandler mSwingLowEventListeners[]; // Swing Low Event Listeners ...
|
|
|
|
/**
|
|
* Create an Object to Represent Swing Low on Chart ...
|
|
*
|
|
* @param bar: XOHCL instance ...
|
|
* @param name: String ...
|
|
*/
|
|
void CreateSwingLowObject(
|
|
XOHCL &bar,
|
|
string name //
|
|
)
|
|
{
|
|
//
|
|
if (!bar.IsValid() ||
|
|
!IsValid(name))
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
CChartObjectArrow *iObj;
|
|
iObj = new CChartObjectArrow();
|
|
bool isCreated = iObj.Create(
|
|
ChartID(),
|
|
name,
|
|
Window(),
|
|
bar.time,
|
|
bar.low,
|
|
SwingLowArrowCode() //
|
|
);
|
|
if (!isCreated)
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
// Configure Object ...
|
|
iObj.Width(SwingLowWidth());
|
|
iObj.Color(SwingLowColor());
|
|
iObj.Anchor(ANCHOR_TOP);
|
|
|
|
//
|
|
mSwingLowObjects.Add(iObj);
|
|
}
|
|
|
|
//
|
|
// Momentum Bar ...
|
|
|
|
bool mAllowDrawMomentumBars; // Draw Momentum Bars ...
|
|
int mMomentumBarPercent; // Momentum Bar Percent ...
|
|
double mMomentumBarSharpRatio; // Momentum Bar Sharp Ratio ...
|
|
int mMomentumBarLoopBack; // Momentum Bar Loopback ...
|
|
int mMomentumBarWidth; // Momentum Bar Width ...
|
|
char mMomentumBarBullishArrowCode; // Bullish Momentum Bar Arrow Code ...
|
|
char mMomentumBarBearishArrowCode; // Bullish Momentum Bar Color ...
|
|
color mMomentumBarBullishColor; // Bearish Momentum Bar Arrow Code ...
|
|
color mMomentumBarBearishColor; // Bearish Momentum Bar Color ...
|
|
XOHCL mMomentumBars[]; // Momentum Bars ...
|
|
CArrayObj mMomentumBarObjects; // Momentm Bar Chart Objects ...
|
|
TXOHCLEventHandler mMomentumBarEventListeners[]; // Momentum Bars Event Listeners ...
|
|
|
|
/**
|
|
* Create an Object to Represent Momentum Bar on Chart ...
|
|
*
|
|
* @param bar: XOHCL instance ...
|
|
* @param name: String ...
|
|
*/
|
|
void CreateMomentumBarObject(
|
|
XOHCL &bar,
|
|
string name //
|
|
)
|
|
{
|
|
//
|
|
if (!bar.IsValid() ||
|
|
!IsValid(name))
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
bool isBullish = bar.IsBullish();
|
|
double price =
|
|
isBullish
|
|
? bar.low
|
|
: bar.high;
|
|
char arrowCode =
|
|
isBullish
|
|
? MomentumBarBullishArrowCode()
|
|
: MomentumBarBearishArrowCode();
|
|
color clr =
|
|
isBullish
|
|
? MomentumBarBullishColor()
|
|
: MomentumBarBearishColor();
|
|
ENUM_ARROW_ANCHOR anchor =
|
|
isBullish
|
|
? ANCHOR_TOP
|
|
: ANCHOR_BOTTOM;
|
|
|
|
//
|
|
CChartObjectArrow *iObj;
|
|
iObj = new CChartObjectArrow();
|
|
bool isCreated = iObj.Create(
|
|
ChartID(),
|
|
name,
|
|
Window(),
|
|
bar.time,
|
|
price,
|
|
arrowCode //
|
|
);
|
|
if (!isCreated)
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
// Configure Object ...
|
|
iObj.Width(MomentumBarWidth());
|
|
iObj.Color(clr);
|
|
iObj.Anchor(anchor);
|
|
|
|
//
|
|
mMomentumBarObjects.Add(iObj);
|
|
}
|
|
|
|
//
|
|
// Rejection Bar ....
|
|
bool mAllowDrawRejectionBars; // Draw Rejection Bars ...
|
|
int mRejectionBarPercent; // Rejection Bar Percent ...
|
|
double mRejectionBarSharpRatio; // Rejection Bar Sharp Ratio ...
|
|
int mRejectionBarLoopBack; // Rejection Bar Loopback ...
|
|
int mRejectionBarWidth; // Rejection Bar Width ...
|
|
char mRejectionBarBullishArrowCode; // Bullish Rejection Bar Arrow Code ...
|
|
char mRejectionBarBearishArrowCode; // Bullish Rejection Bar Color ...
|
|
color mRejectionBarBullishColor; // Bearish Rejection Bar Arrow Code ...
|
|
color mRejectionBarBearishColor; // Bearish Rejection Bar Color ...
|
|
XOHCL mRejectionBars[]; // Rejection Bars ...
|
|
CArrayObj mRejectionBarObjects; // Rejection Bar Chart Objects ...
|
|
TXOHCLEventHandler mRejectionBarEventListeners[]; // Rejection Bars Event Listeners ...
|
|
|
|
/**
|
|
* Create an Object to Represent Rejection Bar on Chart ...
|
|
*
|
|
* @param bar: XOHCL instance ...
|
|
* @param name: String ...
|
|
*/
|
|
void CreateRejectionBarObject(
|
|
XOHCL &bar,
|
|
string name //
|
|
)
|
|
{
|
|
//
|
|
if (!bar.IsValid() ||
|
|
!IsValid(name))
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
bool isBullish = bar.GetLowShadow() > bar.GetHighShadow();
|
|
double price =
|
|
isBullish
|
|
? bar.low
|
|
: bar.high;
|
|
char arrowCode =
|
|
isBullish
|
|
? RejectionBarBullishArrowCode()
|
|
: RejectionBarBearishArrowCode();
|
|
color clr =
|
|
isBullish
|
|
? RejectionBarBullishColor()
|
|
: RejectionBarBearishColor();
|
|
ENUM_ARROW_ANCHOR anchor =
|
|
isBullish
|
|
? ANCHOR_TOP
|
|
: ANCHOR_BOTTOM;
|
|
|
|
//
|
|
CChartObjectArrow *iObj;
|
|
iObj = new CChartObjectArrow();
|
|
bool isCreated = iObj.Create(
|
|
ChartID(),
|
|
name,
|
|
Window(),
|
|
bar.time,
|
|
price,
|
|
arrowCode //
|
|
);
|
|
if (!isCreated)
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
// Configure Object ...
|
|
iObj.Width(RejectionBarWidth());
|
|
iObj.Color(clr);
|
|
iObj.Anchor(anchor);
|
|
|
|
//
|
|
mRejectionBarObjects.Add(iObj);
|
|
}
|
|
|
|
//
|
|
// Support Zone ...
|
|
bool mAllowDrawSupportZones; // Draw Support Zone ...
|
|
int mSupportZoneLoopBack; // Support Zone Loopback ...
|
|
int mSupportZoneWidth; // Support Zone Width ...
|
|
color mSupportZoneColor; // Support Zone Color ...
|
|
ENUM_LINE_STYLE mSupportZoneStyle; // Support Zone Style ...
|
|
ENUM_X_PRICE mSupportZonePriceType; // Support Zone Price Type ...
|
|
XOHCL mSupportZones[]; // Support Zones ...
|
|
CArrayObj mSupportZoneObjects; // Support Zone Chart Objects ...
|
|
TXOHCLEventHandler mSupportZoneEventListeners[]; // Support Zone Event Listeners ...
|
|
|
|
/**
|
|
* Create an Object to Represent Support Zones on Chart ...
|
|
|
|
* @param bar: XOHCL instance ...
|
|
* @param name: String ...
|
|
*/
|
|
void CreateSupportZoneObject(
|
|
XOHCL &bar,
|
|
string name //
|
|
)
|
|
{
|
|
//
|
|
if (!bar.IsValid() ||
|
|
!IsValid(name))
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
datetime cBarTime = TimeCurrent();
|
|
if (bar.Index() > 0)
|
|
{
|
|
//
|
|
cBarTime = iTime(
|
|
Symbol(),
|
|
Period(),
|
|
bar.Index() - 10 //
|
|
);
|
|
}
|
|
|
|
//
|
|
XCSupportZoneObject *iObj;
|
|
iObj = new XCSupportZoneObject();
|
|
bool isCreated = iObj.CreateBySupport(
|
|
ChartID(),
|
|
name,
|
|
Window(),
|
|
bar,
|
|
cBarTime,
|
|
true // Force Draw Rect ...
|
|
);
|
|
if (!isCreated)
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
// Configure Object ...
|
|
iObj.ZoneColor(SupportZoneColor());
|
|
iObj.ZoneStyle(SupportZoneStyle());
|
|
iObj.ZoneWidth(SupportZoneWidth());
|
|
|
|
//
|
|
mSupportZoneObjects.Add(iObj);
|
|
}
|
|
|
|
//
|
|
// Resistance Zone ...
|
|
bool mAllowDrawResistanceZones; // Draw Resistance Zone ...
|
|
int mResistanceZoneLoopBack; // Resistance Zone Loopback ...
|
|
int mResistanceZoneWidth; // Resistance Zone Width ...
|
|
color mResistanceZoneColor; // Resistance Zone Color ...
|
|
ENUM_LINE_STYLE mResistanceZoneStyle; // Resistance Zone Style ...
|
|
ENUM_X_PRICE mResistanceZonePriceType; // Resistance Zone Price Type ...
|
|
XOHCL mResistanceZones[]; // Resistance Zones ...
|
|
CArrayObj mResistanceZoneObjects; // Resistance Zone Chart Objects ...
|
|
TXOHCLEventHandler mResistanceZoneEventListeners[]; // Resistance Zone Event Listeners ...
|
|
|
|
/**
|
|
* Create an Object to Represent Resistance Zones on Chart ...
|
|
|
|
* @param bar: XOHCL instance ...
|
|
* @param name: String ...
|
|
*/
|
|
void CreateResistanceZoneObject(
|
|
XOHCL &bar,
|
|
string name //
|
|
)
|
|
{
|
|
//
|
|
if (!bar.IsValid() ||
|
|
!IsValid(name))
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
datetime cBarTime = TimeCurrent();
|
|
if (bar.Index() > 0)
|
|
{
|
|
//
|
|
cBarTime = iTime(
|
|
Symbol(),
|
|
Period(),
|
|
bar.Index() - 10 //
|
|
);
|
|
}
|
|
|
|
//
|
|
XCResistanceZoneObject *iObj;
|
|
iObj = new XCResistanceZoneObject();
|
|
bool isCreated = iObj.CreateByResistance(
|
|
ChartID(),
|
|
name,
|
|
Window(),
|
|
bar,
|
|
cBarTime,
|
|
true // Force Draw Rect ...
|
|
);
|
|
if (!isCreated)
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
// Configure Object ...
|
|
iObj.ZoneColor(ResistanceZoneColor());
|
|
iObj.ZoneStyle(ResistanceZoneStyle());
|
|
iObj.ZoneWidth(ResistanceZoneWidth());
|
|
|
|
//
|
|
mResistanceZoneObjects.Add(iObj);
|
|
}
|
|
|
|
//
|
|
// Supply Zone ...
|
|
bool mAllowDrawSupplyZones; // Draw Supply Zone ...
|
|
int mSupplyZoneWidth; // Supply Zone Width ...
|
|
color mSupplyZoneColor; // Supply Zone Color ...
|
|
ENUM_LINE_STYLE mSupplyZoneStyle; // Supply Zone Style ...
|
|
ENUM_TIMEFRAMES mSupplyZonePeriod; // Supply Zone Detection Period ...
|
|
XZone mSupplyZones[]; // Supply Zones ...
|
|
CArrayObj mSupplyZoneObjects; // Supply Zone Chart Objects ...
|
|
TXZoneEventHandler mSupplyZoneEventListeners[]; // Supply Zone Event Listeners ...
|
|
|
|
/**
|
|
* Create an Object to Represent Supply Zones on Chart ...
|
|
|
|
* @param bar: XZone instance ...
|
|
* @param name: String ...
|
|
*/
|
|
void CreateSupplyZoneObject(
|
|
XZone &zone,
|
|
string name //
|
|
)
|
|
{
|
|
//
|
|
if (!zone.IsValid() ||
|
|
!IsValid(name))
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
XCSupplyZoneObject *iObj;
|
|
iObj = new XCSupplyZoneObject();
|
|
bool isCreated = iObj.CreateByZone(
|
|
ChartID(),
|
|
name,
|
|
Window(),
|
|
zone,
|
|
NULL, // Object Prefix ...
|
|
true // Force Draw Rect ...
|
|
);
|
|
if (!isCreated)
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
// Configure Object ...
|
|
iObj.ZoneColor(SupplyZoneColor());
|
|
iObj.ZoneStyle(SupplyZoneStyle());
|
|
iObj.ZoneWidth(SupplyZoneWidth());
|
|
|
|
//
|
|
mSupplyZoneObjects.Add(iObj);
|
|
}
|
|
|
|
//
|
|
// Demand Zone ...
|
|
bool mAllowDrawDemandZones; // Draw Demand Zone ...
|
|
int mDemandZoneWidth; // Demand Zone Width ...
|
|
color mDemandZoneColor; // Demand Zone Color ...
|
|
ENUM_LINE_STYLE mDemandZoneStyle; // Demand Zone Style ...
|
|
ENUM_TIMEFRAMES mDemandZonePeriod; // Demand Zone Detection Period ...
|
|
XZone mDemandZones[]; // Demand Zones ...
|
|
CArrayObj mDemandZoneObjects; // Demand Zone Chart Objects ...
|
|
TXZoneEventHandler mDemandZoneEventListeners[]; // Demand Zone Event Listeners ...
|
|
|
|
/**
|
|
* Create an Object to Represent Demand Zones on Chart ...
|
|
|
|
* @param bar: XZone instance ...
|
|
* @param name: String ...
|
|
*/
|
|
void CreateDemandZoneObject(
|
|
XZone &zone,
|
|
string name //
|
|
)
|
|
{
|
|
//
|
|
if (!zone.IsValid() ||
|
|
!IsValid(name))
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
XCDemandZoneObject *iObj;
|
|
iObj = new XCDemandZoneObject();
|
|
bool isCreated = iObj.CreateByZone(
|
|
ChartID(),
|
|
name,
|
|
Window(),
|
|
zone,
|
|
NULL, // Object Prefix ...
|
|
true // Force Draw Rect ...
|
|
);
|
|
if (!isCreated)
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
// Configure Object ...
|
|
iObj.ZoneColor(DemandZoneColor());
|
|
iObj.ZoneStyle(DemandZoneStyle());
|
|
iObj.ZoneWidth(DemandZoneWidth());
|
|
|
|
//
|
|
mDemandZoneObjects.Add(iObj);
|
|
}
|
|
|
|
//
|
|
};
|
|
|
|
// |