2193 lines
40 KiB
Plaintext
2193 lines
40 KiB
Plaintext
///////////////////////////////////////////////////////
|
|
//
|
|
// SaherElm IT Center MQL5 Tools Library
|
|
// --------------------------------------
|
|
// Name: XToolsLib
|
|
// Description: provide all commonly used Tools ...
|
|
//
|
|
//
|
|
// 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 "../Libraries/x-saherelm.draw.lib.mq5"
|
|
#include "../Libraries/x-saherelm.common.lib.mq5"
|
|
|
|
//
|
|
// Definitions ...
|
|
string XTLSHammerToken = "XHammer";
|
|
string XTLSSupportToken = "XSupport";
|
|
string XTLSSwingLowToken = "XSwingLow";
|
|
string XTLSSwingHighToken = "XSwingHigh";
|
|
string XTLSResistanceToken = "XResistance";
|
|
string XTLSBullishFVGToken = "XBullishFVG";
|
|
string XTLSBearishFVGToken = "XBearishFVG";
|
|
string XTLSMorningStarToken = "XMorningStar";
|
|
string XTLSEveningStarToken = "XEveningStar";
|
|
string XTLSShootingStarToken = "XShootingStar";
|
|
string XTLSBullishTrendToken = "XBullishTrend";
|
|
string XTLSBearishTrendToken = "XBearishTrend";
|
|
string XTLSBullishEngulfingToken = "XBullishEngulfing";
|
|
string XTLSBearishEngulfingToken = "XBearishEngulfing";
|
|
string XTLSBullishOrderBlockToken = "XBullishOrderBlock";
|
|
string XTLSBearishOrderBlockToken = "XBearishOrderBlock";
|
|
|
|
//
|
|
// Helper Tools ...
|
|
|
|
//
|
|
bool HasBullishPattern(
|
|
XOHCL &bar,
|
|
int loopback = 0,
|
|
int verifications = 1,
|
|
bool checkHammer = true,
|
|
bool checkMorningStar = true,
|
|
bool checkBullishMarubozu = true,
|
|
bool checkBullishEngulfing = true //
|
|
)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
result = bar.IsValid();
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
if (verifications <= 0)
|
|
{
|
|
verifications = 1;
|
|
}
|
|
|
|
//
|
|
int founded = 0;
|
|
|
|
//
|
|
int idx = bar.Index();
|
|
for (int i = idx; i <= idx + loopback; i++)
|
|
{
|
|
//
|
|
XOHCL iBar;
|
|
result = iBar.Init(
|
|
bar.symbol,
|
|
bar.period,
|
|
i //
|
|
);
|
|
if (!result)
|
|
{
|
|
break;
|
|
}
|
|
|
|
//
|
|
bool isHammer =
|
|
!checkHammer
|
|
? false
|
|
: iBar.IsHammer();
|
|
if (isHammer)
|
|
{
|
|
founded++;
|
|
}
|
|
|
|
//
|
|
bool isMorningStar =
|
|
!checkMorningStar
|
|
? false
|
|
: iBar.IsMorningStar();
|
|
if (isMorningStar)
|
|
{
|
|
founded++;
|
|
}
|
|
|
|
//
|
|
bool isBullishMarubozu =
|
|
!checkBullishMarubozu
|
|
? false
|
|
: iBar.IsBullishMarubozu();
|
|
if (isBullishMarubozu)
|
|
{
|
|
founded++;
|
|
}
|
|
|
|
//
|
|
bool isBullishEngulfing =
|
|
!checkBullishEngulfing
|
|
? false
|
|
: iBar.IsBullishEngulfing();
|
|
if (isBullishEngulfing)
|
|
{
|
|
founded++;
|
|
}
|
|
|
|
//
|
|
}
|
|
|
|
//
|
|
result =
|
|
result &&
|
|
founded >= verifications;
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
bool HasBearishPattern(
|
|
XOHCL &bar,
|
|
int loopback = 0,
|
|
int verifications = 1,
|
|
bool checkShootingStar = true,
|
|
bool checkEveningStar = true,
|
|
bool checkBearishMarubozu = true,
|
|
bool checkBearishEngulfing = true //
|
|
)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
result = bar.IsValid();
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
if (verifications <= 0)
|
|
{
|
|
verifications = 1;
|
|
}
|
|
|
|
//
|
|
int founded = 0;
|
|
|
|
//
|
|
int idx = bar.Index();
|
|
for (int i = idx - 1; i <= idx + loopback; i++)
|
|
{
|
|
//
|
|
XOHCL iBar;
|
|
result = iBar.Init(
|
|
bar.symbol,
|
|
bar.period,
|
|
i //
|
|
);
|
|
if (!result)
|
|
{
|
|
break;
|
|
}
|
|
|
|
//
|
|
bool isShootingStar =
|
|
!checkShootingStar
|
|
? false
|
|
: iBar.IsShootingStar();
|
|
if (isShootingStar)
|
|
{
|
|
founded++;
|
|
}
|
|
|
|
//
|
|
bool isEveningStar =
|
|
!checkEveningStar
|
|
? false
|
|
: iBar.IsEveningStar();
|
|
if (isEveningStar)
|
|
{
|
|
founded++;
|
|
}
|
|
|
|
//
|
|
bool isBearishMarubozu =
|
|
!checkBearishMarubozu
|
|
? false
|
|
: iBar.IsBearishMarubozu();
|
|
if (isBearishMarubozu)
|
|
{
|
|
founded++;
|
|
}
|
|
|
|
//
|
|
bool isBearishEngulfing =
|
|
!checkBearishEngulfing
|
|
? false
|
|
: iBar.IsBearishEngulfing();
|
|
if (isBearishEngulfing)
|
|
{
|
|
founded++;
|
|
}
|
|
|
|
//
|
|
}
|
|
|
|
//
|
|
result =
|
|
result &&
|
|
founded >= verifications;
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
bool IsSupportBreaked(
|
|
XOHCL &bar, // Support Bar
|
|
bool _verifyPressure = true, // Verify Candlestick Patterns for Prove Pressure
|
|
bool checkShootingStar = true, // Check Shooting Star Pattern for Pressure Verifications
|
|
bool checkEveningStar = true, // Check Evening Star Pattern for Pressure Verifications
|
|
bool checkBearishEngulfingStar = true, // Check Bearish Engulfing Pattern for Pressure Verifications
|
|
double _threshold = 0, // Upper and Lower threshold of Pivot
|
|
double _breakVerificationPoint = 15, // Price Distance for Verify Pivot Break
|
|
int _loopback = 3 // Verification Loopback
|
|
)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
if (_breakVerificationPoint < 0)
|
|
{
|
|
_breakVerificationPoint = 15;
|
|
}
|
|
|
|
//
|
|
result = bar.IsValid();
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
double points = GetPoints(bar.symbol);
|
|
|
|
//
|
|
double threshold = 0;
|
|
if (_threshold > 0)
|
|
{
|
|
threshold = _threshold * points;
|
|
}
|
|
|
|
//
|
|
double price = GetBid(bar.symbol);
|
|
|
|
//
|
|
// Check Price is Below of Support High ...
|
|
result = price < bar.high + threshold;
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Check Break Verification ...
|
|
if (_breakVerificationPoint > 0)
|
|
{
|
|
//
|
|
result = (bar.high + threshold) - price >= _breakVerificationPoint * points;
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
}
|
|
|
|
//
|
|
if (_verifyPressure && _loopback > 0)
|
|
{
|
|
//
|
|
// Verify Pressure by Candlestick Patterns ...
|
|
// We need last 3 Candle ...
|
|
|
|
//
|
|
for (int i = 0; i < _loopback; i++)
|
|
{
|
|
//
|
|
XOHCL iBar;
|
|
result = iBar.Init(
|
|
bar.symbol,
|
|
bar.period,
|
|
i //
|
|
);
|
|
if (!result)
|
|
{
|
|
break;
|
|
}
|
|
|
|
//
|
|
// Shooting Star ...
|
|
bool isShootingStar = !checkShootingStar
|
|
? false
|
|
: iBar.IsShootingStar();
|
|
if (isShootingStar)
|
|
{
|
|
//
|
|
DrawShootingStar(
|
|
iBar,
|
|
ChartID() //
|
|
);
|
|
}
|
|
|
|
//
|
|
// Evening Star ...
|
|
bool isEveningStar = !checkEveningStar
|
|
? false
|
|
: iBar.IsEveningStar();
|
|
if (isEveningStar)
|
|
{
|
|
//
|
|
DrawEveningStar(
|
|
iBar,
|
|
ChartID() //
|
|
);
|
|
}
|
|
|
|
//
|
|
// BearishEngulfing ...
|
|
bool isBearishEngulfing = !checkBearishEngulfingStar
|
|
? false
|
|
: iBar.IsBearishEngulfing();
|
|
if (isBearishEngulfing)
|
|
{
|
|
//
|
|
DrawBearishEngulfing(
|
|
iBar,
|
|
ChartID() //
|
|
);
|
|
}
|
|
|
|
//
|
|
result =
|
|
//
|
|
isShootingStar
|
|
//
|
|
||
|
|
//
|
|
isEveningStar
|
|
//
|
|
||
|
|
//
|
|
isBearishEngulfing
|
|
//
|
|
;
|
|
if (result)
|
|
{
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
bool IsSupportRejected(
|
|
XOHCL &bar, // Support Bar
|
|
bool _verifyPressure = true, // Verify Candlestick Patterns for Prove Pressure
|
|
bool checkHammer = true, // Check Hammer Pattern for Pressure Verifications
|
|
bool checkMorningStar = true, // Check Morning Star Pattern for Pressure Verifications
|
|
bool checkBullishEngulfing = true, // Check Bullish Engulfing Pattern for Pressure Verifications
|
|
double _threshold = 0, // Upper and Lower threshold of Pivot
|
|
double _breakVerificationPoint = 15, // Price Distance for Verify Pivot Break
|
|
int _loopback = 3 // Verification Loopback
|
|
)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
if (_breakVerificationPoint < 0)
|
|
{
|
|
_breakVerificationPoint = 15;
|
|
}
|
|
|
|
//
|
|
result = bar.IsValid();
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
double points = GetPoints(bar.symbol);
|
|
|
|
//
|
|
double threshold = 0;
|
|
if (_threshold > 0)
|
|
{
|
|
threshold = _threshold * points;
|
|
}
|
|
|
|
//
|
|
double price = GetBid(bar.symbol);
|
|
|
|
//
|
|
XOHCL cBar;
|
|
result = cBar.Init(
|
|
bar.symbol,
|
|
bar.period,
|
|
0 //
|
|
);
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
double ll2 = cBar.FindLowest(
|
|
2,
|
|
MODE_LOW //
|
|
);
|
|
|
|
//
|
|
// Check Price is Below of Support High ...
|
|
result =
|
|
//
|
|
price > bar.high + threshold &&
|
|
(
|
|
//
|
|
ll2 < bar.high
|
|
//
|
|
||
|
|
//
|
|
ll2 < bar.high - threshold
|
|
//
|
|
||
|
|
//
|
|
(threshold > 0 && MathAbs(ll2 - price) > 0 && MathAbs(ll2 - price) <= threshold)
|
|
//
|
|
)
|
|
//
|
|
;
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Check Break Verification ...
|
|
if (_breakVerificationPoint > 0)
|
|
{
|
|
//
|
|
result = MathAbs((bar.high + threshold) - price) >= _breakVerificationPoint * points;
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
}
|
|
|
|
//
|
|
if (_verifyPressure && _loopback > 0)
|
|
{
|
|
//
|
|
// Verify Pressure by Candlestick Patterns ...
|
|
// We need last 3 Candle ...
|
|
|
|
//
|
|
for (int i = 0; i < _loopback; i++)
|
|
{
|
|
//
|
|
XOHCL iBar;
|
|
result = iBar.Init(
|
|
bar.symbol,
|
|
bar.period,
|
|
i //
|
|
);
|
|
if (!result)
|
|
{
|
|
break;
|
|
}
|
|
|
|
//
|
|
// Hammer ...
|
|
bool isHammer = !checkHammer
|
|
? false
|
|
: iBar.IsHammer();
|
|
if (isHammer)
|
|
{
|
|
//
|
|
DrawHammer(
|
|
iBar,
|
|
ChartID() //
|
|
);
|
|
}
|
|
|
|
//
|
|
// Morning Star ...
|
|
bool isMorningStar = !checkMorningStar
|
|
? false
|
|
: iBar.IsMorningStar();
|
|
if (isMorningStar)
|
|
{
|
|
//
|
|
DrawMorningStar(
|
|
iBar,
|
|
ChartID() //
|
|
);
|
|
}
|
|
|
|
//
|
|
// BullishEngulfing ...
|
|
bool isBullishEngulfing = !checkBullishEngulfing
|
|
? false
|
|
: iBar.IsBullishEngulfing();
|
|
if (isBullishEngulfing)
|
|
{
|
|
//
|
|
DrawBullishEngulfing(
|
|
iBar,
|
|
ChartID() //
|
|
);
|
|
}
|
|
|
|
//
|
|
result =
|
|
//
|
|
isHammer
|
|
//
|
|
||
|
|
//
|
|
isMorningStar
|
|
//
|
|
||
|
|
//
|
|
isBullishEngulfing
|
|
//
|
|
;
|
|
if (result)
|
|
{
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
bool IsResistanceBreaked(
|
|
XOHCL &bar, // Resistance Bar
|
|
bool _verifyPressure = true, // Verify Candlestick Patterns for Prove Pressure
|
|
bool checkHammer = true, // Check Hammer Pattern for Pressure Verifications
|
|
bool checkMorningStar = true, // Check Morning Star Pattern for Pressure Verifications
|
|
bool checkBullishEngulfing = true, // Check Bullish Engulfing Pattern for Pressure Verifications
|
|
double _threshold = 0, // Upper and Lower threshold of Pivot
|
|
double _breakVerificationPoint = 15, // Price Distance for Verify Pivot Break
|
|
int _loopback = 3 // Verification Loopback
|
|
)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
if (_breakVerificationPoint < 0)
|
|
{
|
|
_breakVerificationPoint = 15;
|
|
}
|
|
|
|
//
|
|
result = bar.IsValid();
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
double points = GetPoints(bar.symbol);
|
|
|
|
//
|
|
double threshold = 0;
|
|
if (_threshold > 0)
|
|
{
|
|
threshold = _threshold * points;
|
|
}
|
|
|
|
//
|
|
double price = GetBid(bar.symbol);
|
|
|
|
//
|
|
// Check Price is Below of Support High ...
|
|
result = price > bar.low - threshold;
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Check Break Verification ...
|
|
if (_breakVerificationPoint > 0)
|
|
{
|
|
//
|
|
result = price - (bar.low - threshold) >= _breakVerificationPoint * points;
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
}
|
|
|
|
//
|
|
if (_verifyPressure && _loopback > 0)
|
|
{
|
|
//
|
|
// Verify Pressure by Candlestick Patterns ...
|
|
// We need last 3 Candle ...
|
|
|
|
//
|
|
for (int i = 0; i < _loopback; i++)
|
|
{
|
|
//
|
|
XOHCL iBar;
|
|
result = iBar.Init(
|
|
bar.symbol,
|
|
bar.period,
|
|
i //
|
|
);
|
|
if (!result)
|
|
{
|
|
break;
|
|
}
|
|
|
|
//
|
|
// Hammer ...
|
|
bool isHammer = !checkHammer
|
|
? false
|
|
: iBar.IsHammer();
|
|
if (isHammer)
|
|
{
|
|
//
|
|
DrawHammer(
|
|
iBar,
|
|
ChartID() //
|
|
);
|
|
}
|
|
|
|
//
|
|
// Morning Star ...
|
|
bool isMorningStar = !checkMorningStar
|
|
? false
|
|
: iBar.IsMorningStar();
|
|
if (isMorningStar)
|
|
{
|
|
//
|
|
DrawMorningStar(
|
|
iBar,
|
|
ChartID() //
|
|
);
|
|
}
|
|
|
|
//
|
|
// BullishEngulfing ...
|
|
bool isBullishEngulfing = !checkBullishEngulfing
|
|
? false
|
|
: iBar.IsBullishEngulfing();
|
|
if (isBullishEngulfing)
|
|
{
|
|
//
|
|
DrawBullishEngulfing(
|
|
iBar,
|
|
ChartID() //
|
|
);
|
|
}
|
|
|
|
//
|
|
result =
|
|
//
|
|
isHammer
|
|
//
|
|
||
|
|
//
|
|
isMorningStar
|
|
//
|
|
||
|
|
//
|
|
isBullishEngulfing
|
|
//
|
|
;
|
|
if (result)
|
|
{
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
bool IsResistanceRejected(
|
|
XOHCL &bar, // Resistance Bar
|
|
bool _verifyPressure = true, // Verify Candlestick Patterns for Prove Pressure
|
|
bool checkShootingStar = true, // Check Shooting Star Pattern for Pressure Verifications
|
|
bool checkEveningStar = true, // Check Evening Star Pattern for Pressure Verifications
|
|
bool checkBearishEngulfingStar = true, // Check Bearish Engulfing Pattern for Pressure Verifications
|
|
double _threshold = 0, // Upper and Lower threshold of Pivot
|
|
double _breakVerificationPoint = 15, // Price Distance for Verify Pivot Break
|
|
int _loopback = 3 // Verification Loopback
|
|
)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
if (_breakVerificationPoint < 0)
|
|
{
|
|
_breakVerificationPoint = 15;
|
|
}
|
|
|
|
//
|
|
result = bar.IsValid();
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
double points = GetPoints(bar.symbol);
|
|
|
|
//
|
|
double threshold = 0;
|
|
if (_threshold > 0)
|
|
{
|
|
threshold = _threshold * points;
|
|
}
|
|
|
|
//
|
|
double price = GetBid(bar.symbol);
|
|
|
|
//
|
|
XOHCL cBar;
|
|
result = cBar.Init(
|
|
bar.symbol,
|
|
bar.period,
|
|
0 //
|
|
);
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
double hh2 = cBar.FindHighest(
|
|
2,
|
|
MODE_HIGH //
|
|
);
|
|
|
|
//
|
|
// Check Price is Below of Support High ...
|
|
result =
|
|
//
|
|
price < bar.low - threshold &&
|
|
(
|
|
//
|
|
hh2 > bar.low
|
|
//
|
|
||
|
|
//
|
|
hh2 > bar.low - threshold
|
|
//
|
|
||
|
|
//
|
|
(threshold > 0 && MathAbs(hh2 - price) > 0 && MathAbs(hh2 - price) <= threshold))
|
|
//
|
|
;
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Check Break Verification ...
|
|
if (_breakVerificationPoint > 0)
|
|
{
|
|
//
|
|
result = MathAbs((bar.low - threshold) - price) >= _breakVerificationPoint * points;
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
}
|
|
|
|
//
|
|
if (_verifyPressure && _loopback > 0)
|
|
{
|
|
//
|
|
// Verify Pressure by Candlestick Patterns ...
|
|
// We need last 3 Candle ...
|
|
|
|
//
|
|
for (int i = 0; i < _loopback; i++)
|
|
{
|
|
//
|
|
XOHCL iBar;
|
|
result = iBar.Init(
|
|
bar.symbol,
|
|
bar.period,
|
|
i //
|
|
);
|
|
if (!result)
|
|
{
|
|
break;
|
|
}
|
|
|
|
//
|
|
// Shooting Star ...
|
|
bool isShootingStar = !checkShootingStar
|
|
? false
|
|
: iBar.IsShootingStar();
|
|
if (isShootingStar)
|
|
{
|
|
//
|
|
DrawShootingStar(
|
|
iBar,
|
|
ChartID() //
|
|
);
|
|
}
|
|
|
|
//
|
|
// Evening Star ...
|
|
bool isEveningStar = !checkEveningStar
|
|
? false
|
|
: iBar.IsEveningStar();
|
|
if (isEveningStar)
|
|
{
|
|
//
|
|
DrawEveningStar(
|
|
iBar,
|
|
ChartID() //
|
|
);
|
|
}
|
|
|
|
//
|
|
// BearishEngulfing ...
|
|
bool isBearishEngulfing = !checkBearishEngulfingStar
|
|
? false
|
|
: iBar.IsBearishEngulfing();
|
|
if (isBearishEngulfing)
|
|
{
|
|
//
|
|
DrawBearishEngulfing(
|
|
iBar,
|
|
ChartID() //
|
|
);
|
|
}
|
|
|
|
//
|
|
result =
|
|
//
|
|
isShootingStar
|
|
//
|
|
||
|
|
//
|
|
isEveningStar
|
|
//
|
|
||
|
|
//
|
|
isBearishEngulfing
|
|
//
|
|
;
|
|
if (result)
|
|
{
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Drawing Tools ...
|
|
|
|
//
|
|
// Hammer ...
|
|
|
|
//
|
|
string GetHammerTag(XOHCL &bar)
|
|
{
|
|
return XTLSHammerToken + "-" + GetBarTimeTag(bar);
|
|
}
|
|
|
|
//
|
|
bool DrawHammer(
|
|
XOHCL &bar,
|
|
long chartID,
|
|
color clr = clrAqua,
|
|
uint width = 1,
|
|
uchar arrow = 233 //
|
|
)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
string name = GetHammerTag(bar);
|
|
|
|
//
|
|
result = DrawArrow(
|
|
chartID,
|
|
name,
|
|
0,
|
|
bar.time,
|
|
bar.low,
|
|
arrow,
|
|
ANCHOR_TOP,
|
|
clr,
|
|
STYLE_SOLID,
|
|
width //
|
|
);
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
void RemoveHammer(XOHCL &bar)
|
|
{
|
|
RemoveDraws(GetHammerTag(bar));
|
|
}
|
|
|
|
//
|
|
// Shooting Star ...
|
|
|
|
//
|
|
string GetShootingStarTag(XOHCL &bar)
|
|
{
|
|
return XTLSShootingStarToken + "-" + GetBarTimeTag(bar);
|
|
}
|
|
|
|
//
|
|
bool DrawShootingStar(
|
|
XOHCL &bar,
|
|
long chartID,
|
|
color clr = clrMagenta,
|
|
uint width = 1,
|
|
uchar arrow = 234 //
|
|
)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
string name = GetShootingStarTag(bar);
|
|
|
|
//
|
|
result = DrawArrow(
|
|
chartID,
|
|
name,
|
|
0,
|
|
bar.time,
|
|
bar.high,
|
|
arrow,
|
|
ANCHOR_BOTTOM,
|
|
clr,
|
|
STYLE_SOLID,
|
|
width //
|
|
);
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
void RemoveShootingStar(XOHCL &bar)
|
|
{
|
|
RemoveDraws(GetShootingStarTag(bar));
|
|
}
|
|
|
|
//
|
|
// Bullish Engulfing ...
|
|
|
|
//
|
|
string GetBullishEngulfingTag(XOHCL &bar)
|
|
{
|
|
return XTLSBullishEngulfingToken + "-" + GetBarTimeTag(bar);
|
|
}
|
|
|
|
//
|
|
bool DrawBullishEngulfing(
|
|
XOHCL &bar,
|
|
long chartID,
|
|
color clr = clrAqua,
|
|
bool fill = false,
|
|
uint width = 1,
|
|
ENUM_LINE_STYLE style = STYLE_SOLID //
|
|
)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
XOHCL pBar;
|
|
result = bar.GetPreviousBar(pBar);
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
string name = GetBullishEngulfingTag(bar);
|
|
|
|
//
|
|
DrawRectangle(
|
|
chartID,
|
|
name,
|
|
0,
|
|
pBar.time,
|
|
pBar.low,
|
|
bar.time,
|
|
bar.high,
|
|
clr,
|
|
style,
|
|
width,
|
|
fill //
|
|
);
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
void RemoveBullishEngulfing(XOHCL &bar)
|
|
{
|
|
RemoveDraws(GetBullishEngulfingTag(bar));
|
|
}
|
|
|
|
//
|
|
// Bearish Engulfing ...
|
|
|
|
//
|
|
string GetBearishEngulfingTag(XOHCL &bar)
|
|
{
|
|
return XTLSBearishEngulfingToken + "-" + GetBarTimeTag(bar);
|
|
}
|
|
|
|
//
|
|
bool DrawBearishEngulfing(
|
|
XOHCL &bar,
|
|
long chartID,
|
|
color clr = clrMagenta,
|
|
bool fill = false,
|
|
uint width = 1,
|
|
ENUM_LINE_STYLE style = STYLE_SOLID //
|
|
)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
XOHCL pBar;
|
|
result = bar.GetPreviousBar(pBar);
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
string name = GetBearishEngulfingTag(bar);
|
|
|
|
//
|
|
DrawRectangle(
|
|
chartID,
|
|
name,
|
|
0,
|
|
pBar.time,
|
|
pBar.low,
|
|
bar.time,
|
|
bar.high,
|
|
clr,
|
|
style,
|
|
width,
|
|
fill //
|
|
);
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
void RemoveBearishEngulfing(XOHCL &bar)
|
|
{
|
|
RemoveDraws(GetBearishEngulfingTag(bar));
|
|
}
|
|
|
|
//
|
|
// Morning Star ...
|
|
|
|
//
|
|
string GetMorningStarTag(XOHCL &bar)
|
|
{
|
|
return XTLSMorningStarToken + "-" + GetBarTimeTag(bar);
|
|
}
|
|
|
|
//
|
|
bool DrawMorningStar(
|
|
XOHCL &bar,
|
|
long chartID,
|
|
color clr = clrAqua,
|
|
uint width = 1,
|
|
uchar arrow = 233 //
|
|
)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
string name = GetMorningStarTag(bar);
|
|
|
|
//
|
|
result = DrawArrow(
|
|
chartID,
|
|
name,
|
|
0,
|
|
bar.time,
|
|
bar.low,
|
|
arrow,
|
|
ANCHOR_TOP,
|
|
clr,
|
|
STYLE_SOLID,
|
|
width //
|
|
);
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
void RemoveMorningStar(XOHCL &bar)
|
|
{
|
|
RemoveDraws(GetMorningStarTag(bar));
|
|
}
|
|
|
|
//
|
|
// Evening Star ...
|
|
|
|
//
|
|
string GetEveningStarTag(XOHCL &bar)
|
|
{
|
|
return XTLSEveningStarToken + "-" + GetBarTimeTag(bar);
|
|
}
|
|
|
|
//
|
|
bool DrawEveningStar(
|
|
XOHCL &bar,
|
|
long chartID,
|
|
color clr = clrMagenta,
|
|
uint width = 1,
|
|
uchar arrow = 234 //
|
|
)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
string name = GetEveningStarTag(bar);
|
|
|
|
//
|
|
result = DrawArrow(
|
|
chartID,
|
|
name,
|
|
0,
|
|
bar.time,
|
|
bar.high,
|
|
arrow,
|
|
ANCHOR_BOTTOM,
|
|
clr,
|
|
STYLE_SOLID,
|
|
width //
|
|
);
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
void RemoveEveningStar(XOHCL &bar)
|
|
{
|
|
RemoveDraws(GetEveningStarTag(bar));
|
|
}
|
|
|
|
//
|
|
// Swing High ...
|
|
|
|
//
|
|
string GetSwingHighTag(XOHCL &bar)
|
|
{
|
|
return XTLSSwingHighToken + "-" + GetBarTimeTag(bar);
|
|
}
|
|
|
|
//
|
|
bool DrawSwingHigh(
|
|
XOHCL &bar,
|
|
long chartID,
|
|
color clr = clrMagenta,
|
|
uint width = 1,
|
|
uchar arrow = 108 //
|
|
)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
string name = GetSwingHighTag(bar);
|
|
|
|
//
|
|
result = DrawArrow(
|
|
chartID,
|
|
name,
|
|
0,
|
|
bar.time,
|
|
bar.high,
|
|
arrow,
|
|
ANCHOR_BOTTOM,
|
|
clr,
|
|
STYLE_SOLID,
|
|
width //
|
|
);
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
void RemoveSwingHigh(XOHCL &bar)
|
|
{
|
|
RemoveDraws(GetSwingHighTag(bar));
|
|
}
|
|
|
|
//
|
|
// Swing Low ...
|
|
|
|
//
|
|
string GetSwingLowTag(XOHCL &bar)
|
|
{
|
|
return XTLSSwingLowToken + "-" + GetBarTimeTag(bar);
|
|
}
|
|
|
|
//
|
|
bool DrawSwingLow(
|
|
XOHCL &bar,
|
|
long chartID,
|
|
color clr = clrAqua,
|
|
uint width = 1,
|
|
uchar arrow = 108 //
|
|
)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
string name = GetSwingLowTag(bar);
|
|
|
|
//
|
|
result = DrawArrow(
|
|
chartID,
|
|
name,
|
|
0,
|
|
bar.time,
|
|
bar.low,
|
|
arrow,
|
|
ANCHOR_TOP,
|
|
clr,
|
|
STYLE_SOLID,
|
|
width //
|
|
);
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
void RemoveSwingLow(XOHCL &bar)
|
|
{
|
|
RemoveDraws(GetSwingLowTag(bar));
|
|
}
|
|
|
|
//
|
|
// Bullish FVG ...
|
|
|
|
//
|
|
string GetBullishFVGTag(XOHCL &bar)
|
|
{
|
|
return XTLSBullishFVGToken + "-" + GetBarTimeTag(bar);
|
|
}
|
|
|
|
//
|
|
bool DrawBullishFVG(
|
|
XOHCL &bar,
|
|
double upper,
|
|
double lower,
|
|
long chartID,
|
|
color clr = clrAqua,
|
|
bool fill = false,
|
|
uint width = 1,
|
|
ENUM_LINE_STYLE style = STYLE_SOLID //
|
|
)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
XOHCL pBar;
|
|
result = bar.GetPreviousBar(pBar);
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
XOHCL ppBar;
|
|
result = pBar.GetPreviousBar(ppBar);
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
string name = GetBullishFVGTag(bar);
|
|
|
|
//
|
|
DrawRectangle(
|
|
chartID,
|
|
name,
|
|
0,
|
|
ppBar.time,
|
|
lower,
|
|
bar.time,
|
|
upper,
|
|
clr,
|
|
style,
|
|
width,
|
|
fill //
|
|
);
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
void RemoveBullishFVG(XOHCL &bar)
|
|
{
|
|
RemoveDraws(GetBullishFVGTag(bar));
|
|
}
|
|
|
|
//
|
|
// Bearish FVG ...
|
|
|
|
//
|
|
string GetBearishFVGTag(XOHCL &bar)
|
|
{
|
|
return XTLSBearishFVGToken + "-" + GetBarTimeTag(bar);
|
|
}
|
|
|
|
//
|
|
bool DrawBearishFVG(
|
|
XOHCL &bar,
|
|
double upper,
|
|
double lower,
|
|
long chartID,
|
|
color clr = clrMagenta,
|
|
bool fill = false,
|
|
uint width = 1,
|
|
ENUM_LINE_STYLE style = STYLE_SOLID //
|
|
)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
XOHCL pBar;
|
|
result = bar.GetPreviousBar(pBar);
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
XOHCL ppBar;
|
|
result = pBar.GetPreviousBar(ppBar);
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
string name = GetBearishFVGTag(bar);
|
|
|
|
//
|
|
DrawRectangle(
|
|
chartID,
|
|
name,
|
|
0,
|
|
ppBar.time,
|
|
upper,
|
|
bar.time,
|
|
lower,
|
|
clr,
|
|
style,
|
|
width,
|
|
fill //
|
|
);
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
void RemoveBearishFVG(XOHCL &bar)
|
|
{
|
|
RemoveDraws(GetBearishFVGTag(bar));
|
|
}
|
|
|
|
//
|
|
// Bullish Order Block ...
|
|
|
|
//
|
|
string GetBullishOrderBlockTag(XOHCL &bar)
|
|
{
|
|
return XTLSBullishOrderBlockToken + "-" + GetBarTimeTag(bar);
|
|
}
|
|
|
|
//
|
|
bool DrawBullishOrderBlock(
|
|
XOHCL &bar,
|
|
long chartID,
|
|
bool ray = true,
|
|
color clr = clrAqua,
|
|
ENUM_LINE_STYLE style = STYLE_DOT,
|
|
uint width = 1 //
|
|
)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
string name = GetBullishOrderBlockTag(bar);
|
|
datetime cTime = TimeCurrent();
|
|
|
|
//
|
|
// Draw Upper Line ...
|
|
result = DrawTrendLine(
|
|
chartID,
|
|
name + "-Upper",
|
|
0,
|
|
bar.time,
|
|
bar.high,
|
|
cTime,
|
|
bar.high,
|
|
clr,
|
|
style,
|
|
width,
|
|
false,
|
|
false,
|
|
ray //
|
|
);
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Draw Lower Line ...
|
|
result = DrawTrendLine(
|
|
chartID,
|
|
name + "-Lower",
|
|
0,
|
|
bar.time,
|
|
bar.low,
|
|
cTime,
|
|
bar.low,
|
|
clr,
|
|
style,
|
|
width,
|
|
false,
|
|
false,
|
|
ray //
|
|
);
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
void RemoveBullishOrderBlock(XOHCL &bar)
|
|
{
|
|
RemoveDraws(GetBullishOrderBlockTag(bar));
|
|
}
|
|
|
|
//
|
|
// Bearish Order Block ...
|
|
|
|
//
|
|
string GetBearishOrderBlockTag(XOHCL &bar)
|
|
{
|
|
return XTLSBearishOrderBlockToken + "-" + GetBarTimeTag(bar);
|
|
}
|
|
|
|
//
|
|
bool DrawBearishOrderBlock(
|
|
XOHCL &bar,
|
|
long chartID,
|
|
bool ray = true,
|
|
color clr = clrMagenta,
|
|
ENUM_LINE_STYLE style = STYLE_DOT,
|
|
uint width = 1 //
|
|
)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
string name = GetBearishOrderBlockTag(bar);
|
|
datetime cTime = TimeCurrent();
|
|
|
|
//
|
|
// Draw Upper Line ...
|
|
result = DrawTrendLine(
|
|
chartID,
|
|
name + "-Upper",
|
|
0,
|
|
bar.time,
|
|
bar.high,
|
|
cTime,
|
|
bar.high,
|
|
clr,
|
|
style,
|
|
width,
|
|
false,
|
|
false,
|
|
ray //
|
|
);
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Draw Lower Line ...
|
|
result = DrawTrendLine(
|
|
chartID,
|
|
name + "-Lower",
|
|
0,
|
|
bar.time,
|
|
bar.low,
|
|
cTime,
|
|
bar.low,
|
|
clr,
|
|
style,
|
|
width,
|
|
false,
|
|
false,
|
|
ray //
|
|
);
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
void RemoveBearishOrderBlock(XOHCL &bar)
|
|
{
|
|
RemoveDraws(GetBearishOrderBlockTag(bar));
|
|
}
|
|
|
|
//
|
|
// Support ...
|
|
|
|
//
|
|
string GetSupportTag(XOHCL &bar)
|
|
{
|
|
return XTLSSupportToken + "-" + GetBarTimeTag(bar);
|
|
}
|
|
|
|
//
|
|
bool DrawSupport(
|
|
XOHCL &bar,
|
|
long chartID,
|
|
double _threshold = 0,
|
|
bool ray = true,
|
|
color clr = clrGreen,
|
|
ENUM_LINE_STYLE style = STYLE_DASH,
|
|
uint width = 1,
|
|
color thresholdColor = clrAqua //
|
|
)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
datetime time2 = TimeCurrent();
|
|
|
|
//
|
|
string name = GetSupportTag(bar);
|
|
|
|
//
|
|
result = DrawTrendLine(
|
|
chartID,
|
|
name,
|
|
0,
|
|
bar.time,
|
|
bar.high,
|
|
time2,
|
|
bar.high,
|
|
clr,
|
|
style,
|
|
width,
|
|
false,
|
|
false,
|
|
ray //
|
|
);
|
|
|
|
//
|
|
if (result && _threshold > 0)
|
|
{
|
|
//
|
|
double threshold = GetPoints(bar.symbol) * _threshold;
|
|
|
|
//
|
|
string upThresholdName = name + "UP";
|
|
string downThresholdName = name + "DOWN";
|
|
|
|
//
|
|
result = DrawTrendLine(
|
|
chartID,
|
|
upThresholdName,
|
|
0,
|
|
bar.time,
|
|
bar.high + threshold,
|
|
time2,
|
|
bar.high + threshold,
|
|
thresholdColor,
|
|
style,
|
|
width,
|
|
false,
|
|
false,
|
|
ray //
|
|
);
|
|
|
|
//
|
|
if (result)
|
|
{
|
|
|
|
//
|
|
result = DrawTrendLine(
|
|
chartID,
|
|
downThresholdName,
|
|
0,
|
|
bar.time,
|
|
bar.high - threshold,
|
|
time2,
|
|
bar.high - threshold,
|
|
thresholdColor,
|
|
style,
|
|
width,
|
|
false,
|
|
false,
|
|
ray //
|
|
);
|
|
}
|
|
}
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
void RemoveSupport(XOHCL &bar)
|
|
{
|
|
RemoveDraws(GetSupportTag(bar));
|
|
}
|
|
|
|
//
|
|
// Support ...
|
|
|
|
//
|
|
string GetResistanceTag(XOHCL &bar)
|
|
{
|
|
return XTLSResistanceToken + "-" + GetBarTimeTag(bar);
|
|
}
|
|
|
|
//
|
|
bool DrawResistance(
|
|
XOHCL &bar,
|
|
long chartID,
|
|
double _threshold = 0,
|
|
bool ray = true,
|
|
color clr = clrRed,
|
|
ENUM_LINE_STYLE style = STYLE_DASH,
|
|
uint width = 1,
|
|
color thresholdColor = clrMagenta //
|
|
)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
datetime time2 = TimeCurrent();
|
|
|
|
//
|
|
string name = GetResistanceTag(bar);
|
|
|
|
//
|
|
result = DrawTrendLine(
|
|
chartID,
|
|
name,
|
|
0,
|
|
bar.time,
|
|
bar.low,
|
|
time2,
|
|
bar.low,
|
|
clr,
|
|
style,
|
|
width,
|
|
false,
|
|
false,
|
|
ray //
|
|
);
|
|
|
|
//
|
|
if (result && _threshold > 0)
|
|
{
|
|
//
|
|
double threshold = GetPoints(bar.symbol) * _threshold;
|
|
|
|
//
|
|
string upThresholdName = name + "UP";
|
|
string downThresholdName = name + "DOWN";
|
|
|
|
//
|
|
result = DrawTrendLine(
|
|
chartID,
|
|
upThresholdName,
|
|
0,
|
|
bar.time,
|
|
bar.low + threshold,
|
|
time2,
|
|
bar.low + threshold,
|
|
thresholdColor,
|
|
style,
|
|
width,
|
|
false,
|
|
false,
|
|
ray //
|
|
);
|
|
|
|
//
|
|
if (result)
|
|
{
|
|
|
|
//
|
|
result = DrawTrendLine(
|
|
chartID,
|
|
downThresholdName,
|
|
0,
|
|
bar.time,
|
|
bar.low - threshold,
|
|
time2,
|
|
bar.low - threshold,
|
|
thresholdColor,
|
|
style,
|
|
width,
|
|
false,
|
|
false,
|
|
ray //
|
|
);
|
|
}
|
|
}
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
void RemoveResistance(XOHCL &bar)
|
|
{
|
|
RemoveDraws(GetResistanceTag(bar));
|
|
}
|
|
|
|
//
|
|
// Bullish Trend ...
|
|
|
|
//
|
|
string GetBullishTrendTag(XOHCL &bar)
|
|
{
|
|
return XTLSBullishTrendToken + "-" + GetBarTimeTag(bar);
|
|
}
|
|
|
|
//
|
|
bool DrawBullishTrend(
|
|
XOHCL &bar,
|
|
XOHCL &highSwingBars[],
|
|
XOHCL &lowSwingBars[],
|
|
long chartID,
|
|
bool ray = true,
|
|
bool drawSwings = true,
|
|
color clr = clrAqua,
|
|
ENUM_LINE_STYLE style = STYLE_DOT,
|
|
uint width = 1,
|
|
uchar swingHighArrow = 108,
|
|
color swingHighColor = clrAqua,
|
|
uchar swingLowArrow = 108,
|
|
color swingLowColor = clrMagenta //
|
|
)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
string name = GetBullishTrendTag(bar);
|
|
|
|
//
|
|
XOHCL first;
|
|
XOHCL last;
|
|
|
|
//
|
|
// Draw Upper Trend Line ...
|
|
first = highSwingBars[ArraySize(highSwingBars) - 1];
|
|
last = highSwingBars[0];
|
|
|
|
//
|
|
result = DrawTrendLine(
|
|
chartID,
|
|
name + "-Upper",
|
|
0,
|
|
first.time,
|
|
first.high,
|
|
last.time,
|
|
last.high,
|
|
clr,
|
|
style,
|
|
width,
|
|
false,
|
|
false,
|
|
ray //
|
|
);
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Draw Lower Trend Line ...
|
|
first = lowSwingBars[ArraySize(lowSwingBars) - 1];
|
|
last = lowSwingBars[0];
|
|
|
|
//
|
|
result = DrawTrendLine(
|
|
chartID,
|
|
name + "-Lower",
|
|
0,
|
|
first.time,
|
|
first.high,
|
|
last.time,
|
|
last.high,
|
|
clr,
|
|
style,
|
|
width,
|
|
false,
|
|
false,
|
|
ray //
|
|
);
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
if (result && drawSwings)
|
|
{
|
|
//
|
|
// High Swings ...
|
|
for (int i = 0; i < ArraySize(highSwingBars); i++)
|
|
{
|
|
//
|
|
XOHCL iBar = highSwingBars[i];
|
|
|
|
//
|
|
result = DrawArrow(
|
|
chartID,
|
|
name + "-SwingHigh-" + ToString(i),
|
|
0,
|
|
iBar.time,
|
|
iBar.high,
|
|
swingHighArrow,
|
|
ANCHOR_BOTTOM,
|
|
swingHighColor,
|
|
STYLE_SOLID,
|
|
width //
|
|
);
|
|
if (!result)
|
|
{
|
|
break;
|
|
}
|
|
}
|
|
|
|
//
|
|
// Low Swings ...
|
|
for (int i = 0; i < ArraySize(lowSwingBars); i++)
|
|
{
|
|
//
|
|
XOHCL iBar = lowSwingBars[i];
|
|
|
|
//
|
|
result = DrawArrow(
|
|
chartID,
|
|
name + "-SwingLow-" + ToString(i),
|
|
0,
|
|
iBar.time,
|
|
iBar.low,
|
|
swingLowArrow,
|
|
ANCHOR_TOP,
|
|
swingLowColor,
|
|
STYLE_SOLID,
|
|
width //
|
|
);
|
|
if (!result)
|
|
{
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
void RemoveBullishTrend(XOHCL &bar)
|
|
{
|
|
RemoveDraws(GetBullishTrendTag(bar));
|
|
}
|
|
|
|
//
|
|
// Bearish Trend ...
|
|
|
|
//
|
|
string GetBearishTrendTag(XOHCL &bar)
|
|
{
|
|
return XTLSBearishTrendToken + "-" + GetBarTimeTag(bar);
|
|
}
|
|
|
|
//
|
|
bool DrawBearishTrend(
|
|
XOHCL &bar,
|
|
XOHCL &highSwingBars[],
|
|
XOHCL &lowSwingBars[],
|
|
long chartID,
|
|
bool ray = true,
|
|
bool drawSwings = true,
|
|
color clr = clrMagenta,
|
|
ENUM_LINE_STYLE style = STYLE_DOT,
|
|
uint width = 1,
|
|
uchar swingHighArrow = 108,
|
|
color swingHighColor = clrMagenta,
|
|
uchar swingLowArrow = 108,
|
|
color swingLowColor = clrAqua //
|
|
)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
string name = GetBearishTrendTag(bar);
|
|
|
|
//
|
|
XOHCL first;
|
|
XOHCL last;
|
|
|
|
//
|
|
// Draw Upper Trend Line ...
|
|
first = highSwingBars[ArraySize(highSwingBars) - 1];
|
|
last = highSwingBars[0];
|
|
|
|
//
|
|
result = DrawTrendLine(
|
|
chartID,
|
|
name + "-Upper",
|
|
0,
|
|
first.time,
|
|
first.high,
|
|
last.time,
|
|
last.high,
|
|
clr,
|
|
style,
|
|
width,
|
|
false,
|
|
false,
|
|
ray //
|
|
);
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Draw Lower Trend Line ...
|
|
first = lowSwingBars[ArraySize(lowSwingBars) - 1];
|
|
last = lowSwingBars[0];
|
|
|
|
//
|
|
result = DrawTrendLine(
|
|
chartID,
|
|
name + "-Lower",
|
|
0,
|
|
first.time,
|
|
first.high,
|
|
last.time,
|
|
last.high,
|
|
clr,
|
|
style,
|
|
width,
|
|
false,
|
|
false,
|
|
ray //
|
|
);
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
if (result && drawSwings)
|
|
{
|
|
//
|
|
// High Swings ...
|
|
for (int i = 0; i < ArraySize(highSwingBars); i++)
|
|
{
|
|
//
|
|
XOHCL iBar = highSwingBars[i];
|
|
|
|
//
|
|
result = DrawArrow(
|
|
chartID,
|
|
name + "-SwingHigh-" + ToString(i),
|
|
0,
|
|
iBar.time,
|
|
iBar.high,
|
|
swingHighArrow,
|
|
ANCHOR_BOTTOM,
|
|
swingHighColor,
|
|
STYLE_SOLID,
|
|
width //
|
|
);
|
|
if (!result)
|
|
{
|
|
break;
|
|
}
|
|
}
|
|
|
|
//
|
|
// Low Swings ...
|
|
for (int i = 0; i < ArraySize(lowSwingBars); i++)
|
|
{
|
|
//
|
|
XOHCL iBar = lowSwingBars[i];
|
|
|
|
//
|
|
result = DrawArrow(
|
|
chartID,
|
|
name + "-SwingLow-" + ToString(i),
|
|
0,
|
|
iBar.time,
|
|
iBar.low,
|
|
swingLowArrow,
|
|
ANCHOR_TOP,
|
|
swingLowColor,
|
|
STYLE_SOLID,
|
|
width //
|
|
);
|
|
if (!result)
|
|
{
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
void RemoveBearishTrend(XOHCL &bar)
|
|
{
|
|
RemoveDraws(GetBearishTrendTag(bar));
|
|
}
|
|
|
|
//
|
|
void RemoveAllToolsDraws()
|
|
{
|
|
//
|
|
RemoveDraws(XTLSHammerToken);
|
|
RemoveDraws(XTLSSupportToken);
|
|
RemoveDraws(XTLSSwingLowToken);
|
|
RemoveDraws(XTLSSwingHighToken);
|
|
RemoveDraws(XTLSBullishFVGToken);
|
|
RemoveDraws(XTLSBearishFVGToken);
|
|
RemoveDraws(XTLSResistanceToken);
|
|
RemoveDraws(XTLSMorningStarToken);
|
|
RemoveDraws(XTLSEveningStarToken);
|
|
RemoveDraws(XTLSShootingStarToken);
|
|
RemoveDraws(XTLSBullishTrendToken);
|
|
RemoveDraws(XTLSBearishTrendToken);
|
|
RemoveDraws(XTLSBullishEngulfingToken);
|
|
RemoveDraws(XTLSBearishEngulfingToken);
|
|
RemoveDraws(XTLSBullishOrderBlockToken);
|
|
RemoveDraws(XTLSBearishOrderBlockToken);
|
|
}
|
|
|
|
//
|
|
//
|
|
//
|
|
|
|
//
|
|
string GetBarTimeTag(XOHCL &bar)
|
|
{
|
|
//
|
|
string result = NULL;
|
|
|
|
//
|
|
result =
|
|
//
|
|
ToString((int)bar.time)
|
|
//
|
|
;
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
string GeShootingStarTag(XOHCL &bar)
|
|
{
|
|
return "ShootingStar-" + GetBarTimeTag(bar);
|
|
}
|
|
|
|
//
|
|
// string GeShootingStarTag(XOHCL &bar)
|
|
// {
|
|
// return "ShootingStar-" + GetBarTimeTag(bar);
|
|
// }
|
|
|
|
// |