last works ...
adding some tools to ch helper classes ...
This commit is contained in:
@@ -2107,6 +2107,55 @@ public:
|
|||||||
.ByTicket(ticket);
|
.ByTicket(ticket);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
double GetPositionCommission(
|
||||||
|
ulong ticket // Specified Ticket
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
double result = 0;
|
||||||
|
|
||||||
|
//
|
||||||
|
XPosition position;
|
||||||
|
bool hasPosition = GetPosition(
|
||||||
|
ticket,
|
||||||
|
position //
|
||||||
|
);
|
||||||
|
if (!hasPosition)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
XDeal deals[];
|
||||||
|
int dealsCount = GetDeals(
|
||||||
|
deals,
|
||||||
|
position.symbol,
|
||||||
|
position.provider,
|
||||||
|
position.period,
|
||||||
|
NULL,
|
||||||
|
DEAL_ENTRY_IN //
|
||||||
|
);
|
||||||
|
if (IsValidSize(dealsCount))
|
||||||
|
{
|
||||||
|
//
|
||||||
|
for (int i = 0; i < dealsCount; i++)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
XDeal iDeal = deals[i];
|
||||||
|
if (iDeal.positionId == ticket)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
result = iDeal.commission;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Retrieve Positions ...
|
// Retrieve Positions ...
|
||||||
int GetPositions(
|
int GetPositions(
|
||||||
@@ -4198,6 +4247,18 @@ public:
|
|||||||
mAllowHedging = value;
|
mAllowHedging = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
bool OnlyHedgeSupportedPositions()
|
||||||
|
{
|
||||||
|
return mOnlyHedgeSupportedPositions;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
void OnlyHedgeSupportedPositions(bool value)
|
||||||
|
{
|
||||||
|
mOnlyHedgeSupportedPositions = value;
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
double HedgeVolumeFactor()
|
double HedgeVolumeFactor()
|
||||||
{
|
{
|
||||||
@@ -4456,7 +4517,9 @@ public:
|
|||||||
{
|
{
|
||||||
//
|
//
|
||||||
// Check Values Validation ...
|
// Check Values Validation ...
|
||||||
if (count > 1 &&
|
if ((count > 1 ||
|
||||||
|
(count == 1 &&
|
||||||
|
mOnlyHedgeSupportedPositions)) &&
|
||||||
mHedgeVolumeFactor > 0 &&
|
mHedgeVolumeFactor > 0 &&
|
||||||
mHedgeMinProfitPerVolumeFactor > 0)
|
mHedgeMinProfitPerVolumeFactor > 0)
|
||||||
{
|
{
|
||||||
@@ -4492,12 +4555,17 @@ public:
|
|||||||
//
|
//
|
||||||
string msg = ToString(positionsCount) + " Closed Due Hedge Action in: " + ToString(profits) + " ...";
|
string msg = ToString(positionsCount) + " Closed Due Hedge Action in: " + ToString(profits) + " ...";
|
||||||
Alert(msg);
|
Alert(msg);
|
||||||
|
|
||||||
|
//
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
|
||||||
//
|
//
|
||||||
// Do Force Closing ...
|
// Do Force Closing ...
|
||||||
|
|
||||||
@@ -4529,6 +4597,17 @@ public:
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Allow Trail Only for Positions Which
|
||||||
|
// doesnt Have Any Support ...
|
||||||
|
bool iHasSupport = mTrader.HasSupport(
|
||||||
|
ticket //
|
||||||
|
);
|
||||||
|
if (iHasSupport)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Trail ...
|
// Trail ...
|
||||||
if (mData[i].allowTrailStop)
|
if (mData[i].allowTrailStop)
|
||||||
@@ -4562,8 +4641,8 @@ public:
|
|||||||
// Calculate new Level SL ...
|
// Calculate new Level SL ...
|
||||||
double sl =
|
double sl =
|
||||||
isLong
|
isLong
|
||||||
? iPosition.entry + (trailStepInPoints * points)
|
? iPosition.entry + (mData[i].trailLevel * (trailStepInPoints * points))
|
||||||
: iPosition.entry - (trailStepInPoints * points);
|
: iPosition.entry - (mData[i].trailLevel * (trailStepInPoints * points));
|
||||||
sl = NormalizePrice(
|
sl = NormalizePrice(
|
||||||
sl,
|
sl,
|
||||||
symbol //
|
symbol //
|
||||||
@@ -4704,6 +4783,30 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Validate Signal For Execution ...
|
||||||
|
bool CanExecute(XSignal &signal)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
bool result = false;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Validate Signal ...
|
||||||
|
result = signal.IsValid();
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// TODO:
|
||||||
|
// Here we can apply Same type or Opposit Type
|
||||||
|
// Signals behaviour ...
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Protected ...
|
// Protected ...
|
||||||
protected:
|
protected:
|
||||||
@@ -4729,6 +4832,7 @@ protected:
|
|||||||
//
|
//
|
||||||
// Hedging ...
|
// Hedging ...
|
||||||
bool mAllowHedging; // Hedge Trades
|
bool mAllowHedging; // Hedge Trades
|
||||||
|
bool mOnlyHedgeSupportedPositions; // Only Hedge Supported Positions
|
||||||
double mHedgeVolumeFactor; // Hedging Volume Factor
|
double mHedgeVolumeFactor; // Hedging Volume Factor
|
||||||
double mHedgeMinProfitPerVolumeFactor; // Hedging Min Required Profit Per Volume Factor
|
double mHedgeMinProfitPerVolumeFactor; // Hedging Min Required Profit Per Volume Factor
|
||||||
|
|
||||||
|
|||||||
@@ -43,8 +43,8 @@ double eaAllowLong = true; // Allow Long Positions
|
|||||||
double eaAllowShort = true; // Allow Short Positions
|
double eaAllowShort = true; // Allow Short Positions
|
||||||
|
|
||||||
//
|
//
|
||||||
int eaMaxAllowedLongs = 1; // Max Allowed Long Positions
|
int eaMaxAllowedLongs = 0; // Max Allowed Long Positions
|
||||||
int eaMaxAllowedShorts = 1; // Max Allowed Short Positions
|
int eaMaxAllowedShorts = 0; // Max Allowed Short Positions
|
||||||
|
|
||||||
//
|
//
|
||||||
input double eaTPPoint = 200; // Static TP Point
|
input double eaTPPoint = 200; // Static TP Point
|
||||||
@@ -250,13 +250,14 @@ bool InitialEA()
|
|||||||
// Configure Hedging ...
|
// Configure Hedging ...
|
||||||
eaTradeHandler.AllowHedging(false);
|
eaTradeHandler.AllowHedging(false);
|
||||||
eaTradeHandler.HedgeVolumeFactor(eaVolume);
|
eaTradeHandler.HedgeVolumeFactor(eaVolume);
|
||||||
eaTradeHandler.HedgeMinProfitPerVolumeFactor(0.2);
|
eaTradeHandler.OnlyHedgeSupportedPositions(false);
|
||||||
|
eaTradeHandler.HedgeMinProfitPerVolumeFactor(0.3);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Configure Trailing ...
|
// Configure Trailing ...
|
||||||
eaTradeHandler.AllowTrailStops(false);
|
eaTradeHandler.AllowTrailStops(false);
|
||||||
eaTradeHandler.TrailStepInPoint(25);
|
eaTradeHandler.TrailStepInPoint(10);
|
||||||
eaTradeHandler.TrailStartInPoint(50);
|
eaTradeHandler.TrailStartInPoint(20);
|
||||||
eaTradeHandler.IgnoreTPOnTrail(true);
|
eaTradeHandler.IgnoreTPOnTrail(true);
|
||||||
eaTradeHandler.TrailBasedOnProfit(true);
|
eaTradeHandler.TrailBasedOnProfit(true);
|
||||||
|
|
||||||
@@ -267,7 +268,7 @@ bool InitialEA()
|
|||||||
bool drawAreas = false;
|
bool drawAreas = false;
|
||||||
|
|
||||||
//
|
//
|
||||||
bool useEURUSD = true;
|
bool useEURUSD = false;
|
||||||
bool useUSDCHF = false;
|
bool useUSDCHF = false;
|
||||||
bool useUSDJPY = false;
|
bool useUSDJPY = false;
|
||||||
bool useGBPUSD = false;
|
bool useGBPUSD = false;
|
||||||
@@ -276,7 +277,7 @@ bool InitialEA()
|
|||||||
//
|
//
|
||||||
bool useXTest = false;
|
bool useXTest = false;
|
||||||
bool useXDTD = false;
|
bool useXDTD = false;
|
||||||
bool useXCHKM = true;
|
bool useXCHKM = false;
|
||||||
|
|
||||||
//
|
//
|
||||||
// EURUSD ...
|
// EURUSD ...
|
||||||
@@ -382,30 +383,30 @@ bool InitialEA()
|
|||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// XSCXDTDStrategy *xTDTStrategy;
|
XSCXCHKMStrategy *xchmStrategy;
|
||||||
// xTDTStrategy = new XSCXDTDStrategy(
|
xchmStrategy = new XSCXCHKMStrategy(
|
||||||
// _Symbol,
|
_Symbol,
|
||||||
// _Period,
|
_Period,
|
||||||
// eaVolume,
|
eaVolume,
|
||||||
// eaR2R, // R2R ...
|
eaR2R, // R2R ...
|
||||||
// eaSlippage,
|
eaSlippage,
|
||||||
// eaMagicNumber,
|
eaMagicNumber,
|
||||||
// true, // Ignore Signal Execution
|
true, // Ignore Signal Execution
|
||||||
// true, // Use TP SL Point
|
false, // Use TP SL Point
|
||||||
// false, // Use Max
|
false, // Use Max
|
||||||
// eaTPPoint, // TP
|
eaTPPoint, // TP
|
||||||
// eaSLPoint, // SL
|
eaSLPoint, // SL
|
||||||
// eaIgnoreTP,
|
eaIgnoreTP,
|
||||||
// eaIgnoreSL,
|
false, // eaIgnoreSL,
|
||||||
// eaAllowLong,
|
eaAllowLong,
|
||||||
// eaAllowShort,
|
eaAllowShort,
|
||||||
// eaMaxAllowedLongs, // Max Longs
|
eaMaxAllowedLongs, // Max Longs
|
||||||
// eaMaxAllowedShorts // Max Shorts
|
eaMaxAllowedShorts // Max Shorts
|
||||||
// );
|
);
|
||||||
// xTDTStrategy.SetAlertLogAlerts(true);
|
xchmStrategy.SetAlertLogAlerts(true);
|
||||||
// xTDTStrategy.SetAlertEnableAlerts(true);
|
xchmStrategy.SetAlertEnableAlerts(true);
|
||||||
// xTDTStrategy.AddSignalEventHandler(OnSignalRecieved);
|
xchmStrategy.AddSignalEventHandler(OnSignalRecieved);
|
||||||
// RegisterStrategy(xTDTStrategy);
|
RegisterStrategy(xchmStrategy);
|
||||||
|
|
||||||
//
|
//
|
||||||
return result;
|
return result;
|
||||||
@@ -470,6 +471,7 @@ void HandleTradeState()
|
|||||||
void OnSignalRecieved(XSignal &signal)
|
void OnSignalRecieved(XSignal &signal)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
|
// Check Max Allowed ...
|
||||||
if (eaMaxAllowedLongs > 0 || eaMaxAllowedShorts > 0)
|
if (eaMaxAllowedLongs > 0 || eaMaxAllowedShorts > 0)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
@@ -493,6 +495,14 @@ void OnSignalRecieved(XSignal &signal)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Check Signal Can Execute or not ...
|
||||||
|
bool canExecute = eaTradeHandler.CanExecute(signal);
|
||||||
|
if (!canExecute)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
ENUM_X_SIGNAL_EXECUTION_RESULT state;
|
ENUM_X_SIGNAL_EXECUTION_RESULT state;
|
||||||
bool isExecuted = eaTrader.ExecuteSignal(
|
bool isExecuted = eaTrader.ExecuteSignal(
|
||||||
|
|||||||
@@ -98,11 +98,12 @@ struct XCHHKInputs
|
|||||||
|
|
||||||
//
|
//
|
||||||
// Presentation ...
|
// Presentation ...
|
||||||
bool showCurrent; // Show Current Cycle
|
bool ignoreShadows; // Ignore Bar Shadows
|
||||||
bool showShort; // Show Short Cycle
|
bool showCurrent; // Show Current Cycle
|
||||||
bool showMedium; // Show Medium Cycle
|
bool showShort; // Show Short Cycle
|
||||||
bool showLong; // Show Long Cycle
|
bool showMedium; // Show Medium Cycle
|
||||||
bool showHind; // Show Hind Cycle
|
bool showLong; // Show Long Cycle
|
||||||
|
bool showHind; // Show Hind Cycle
|
||||||
|
|
||||||
//
|
//
|
||||||
// Constructor(s) ...
|
// Constructor(s) ...
|
||||||
@@ -133,6 +134,7 @@ struct XCHHKInputs
|
|||||||
hcPeriod = NULL;
|
hcPeriod = NULL;
|
||||||
|
|
||||||
//
|
//
|
||||||
|
ignoreShadows = false;
|
||||||
showCurrent = false;
|
showCurrent = false;
|
||||||
showShort = false;
|
showShort = false;
|
||||||
showMedium = false;
|
showMedium = false;
|
||||||
@@ -158,6 +160,7 @@ struct XCHHKInputs
|
|||||||
hcPeriod = NULL;
|
hcPeriod = NULL;
|
||||||
|
|
||||||
//
|
//
|
||||||
|
ignoreShadows = false;
|
||||||
showCurrent = true;
|
showCurrent = true;
|
||||||
showShort = true;
|
showShort = true;
|
||||||
showMedium = true;
|
showMedium = true;
|
||||||
@@ -790,6 +793,7 @@ public:
|
|||||||
//
|
//
|
||||||
// Presentation ...
|
// Presentation ...
|
||||||
"",
|
"",
|
||||||
|
mInputs.ignoreShadows,
|
||||||
mInputs.showCurrent,
|
mInputs.showCurrent,
|
||||||
mInputs.showShort,
|
mInputs.showShort,
|
||||||
mInputs.showMedium,
|
mInputs.showMedium,
|
||||||
@@ -2453,6 +2457,863 @@ public:
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Tools ...
|
||||||
|
|
||||||
|
//
|
||||||
|
double GetCyclesMaxHigh(
|
||||||
|
int barIndex, // Bar Index
|
||||||
|
ENUM_X_MARKET_CYCLES &cycles[] // Cycles
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
double result = 0;
|
||||||
|
|
||||||
|
//
|
||||||
|
int cyclesCount = ArraySize(cycles);
|
||||||
|
if (!IsValidSize(cyclesCount))
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
double values[];
|
||||||
|
for (int i = 0; i < cyclesCount; i++)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
XOHCL iBar;
|
||||||
|
bool isBarInited = false;
|
||||||
|
|
||||||
|
//
|
||||||
|
switch (cycles[i])
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// CURRENT ...
|
||||||
|
case X_MARKET_CYCLE_UNKNOWN:
|
||||||
|
//
|
||||||
|
isBarInited = CAsOHCL(
|
||||||
|
iBar,
|
||||||
|
barIndex //
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
|
||||||
|
//
|
||||||
|
// SHORT ...
|
||||||
|
case X_MARKET_CYCLE_SHORT:
|
||||||
|
//
|
||||||
|
isBarInited = SAsOHCL(
|
||||||
|
iBar,
|
||||||
|
barIndex //
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
|
||||||
|
//
|
||||||
|
// MEDIUM ...
|
||||||
|
case X_MARKET_CYCLE_MEDIUM:
|
||||||
|
//
|
||||||
|
isBarInited = MAsOHCL(
|
||||||
|
iBar,
|
||||||
|
barIndex //
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
|
||||||
|
//
|
||||||
|
// LONG ...
|
||||||
|
case X_MARKET_CYCLE_LONG:
|
||||||
|
//
|
||||||
|
isBarInited = LAsOHCL(
|
||||||
|
iBar,
|
||||||
|
barIndex //
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
|
||||||
|
//
|
||||||
|
// HIND ...
|
||||||
|
case X_MARKET_CYCLE_HIND:
|
||||||
|
//
|
||||||
|
isBarInited = HAsOHCL(
|
||||||
|
iBar,
|
||||||
|
barIndex //
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
if (isBarInited)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
Add(
|
||||||
|
iBar.high,
|
||||||
|
values //
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
result = GetMax(values);
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
double GetCyclesMinHigh(
|
||||||
|
int barIndex, // Bar Index
|
||||||
|
ENUM_X_MARKET_CYCLES &cycles[] // Cycles
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
double result = 0;
|
||||||
|
|
||||||
|
//
|
||||||
|
int cyclesCount = ArraySize(cycles);
|
||||||
|
if (!IsValidSize(cyclesCount))
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
double values[];
|
||||||
|
for (int i = 0; i < cyclesCount; i++)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
XOHCL iBar;
|
||||||
|
bool isBarInited = false;
|
||||||
|
|
||||||
|
//
|
||||||
|
switch (cycles[i])
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// CURRENT ...
|
||||||
|
case X_MARKET_CYCLE_UNKNOWN:
|
||||||
|
//
|
||||||
|
isBarInited = CAsOHCL(
|
||||||
|
iBar,
|
||||||
|
barIndex //
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
|
||||||
|
//
|
||||||
|
// SHORT ...
|
||||||
|
case X_MARKET_CYCLE_SHORT:
|
||||||
|
//
|
||||||
|
isBarInited = SAsOHCL(
|
||||||
|
iBar,
|
||||||
|
barIndex //
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
|
||||||
|
//
|
||||||
|
// MEDIUM ...
|
||||||
|
case X_MARKET_CYCLE_MEDIUM:
|
||||||
|
//
|
||||||
|
isBarInited = MAsOHCL(
|
||||||
|
iBar,
|
||||||
|
barIndex //
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
|
||||||
|
//
|
||||||
|
// LONG ...
|
||||||
|
case X_MARKET_CYCLE_LONG:
|
||||||
|
//
|
||||||
|
isBarInited = LAsOHCL(
|
||||||
|
iBar,
|
||||||
|
barIndex //
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
|
||||||
|
//
|
||||||
|
// HIND ...
|
||||||
|
case X_MARKET_CYCLE_HIND:
|
||||||
|
//
|
||||||
|
isBarInited = HAsOHCL(
|
||||||
|
iBar,
|
||||||
|
barIndex //
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
if (isBarInited)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
Add(
|
||||||
|
iBar.high,
|
||||||
|
values //
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
result = GetMin(values);
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
double GetCyclesMaxLow(
|
||||||
|
int barIndex, // Bar Index
|
||||||
|
ENUM_X_MARKET_CYCLES &cycles[] // Cycles
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
double result = 0;
|
||||||
|
|
||||||
|
//
|
||||||
|
int cyclesCount = ArraySize(cycles);
|
||||||
|
if (!IsValidSize(cyclesCount))
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
double values[];
|
||||||
|
for (int i = 0; i < cyclesCount; i++)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
XOHCL iBar;
|
||||||
|
bool isBarInited = false;
|
||||||
|
|
||||||
|
//
|
||||||
|
switch (cycles[i])
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// CURRENT ...
|
||||||
|
case X_MARKET_CYCLE_UNKNOWN:
|
||||||
|
//
|
||||||
|
isBarInited = CAsOHCL(
|
||||||
|
iBar,
|
||||||
|
barIndex //
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
|
||||||
|
//
|
||||||
|
// SHORT ...
|
||||||
|
case X_MARKET_CYCLE_SHORT:
|
||||||
|
//
|
||||||
|
isBarInited = SAsOHCL(
|
||||||
|
iBar,
|
||||||
|
barIndex //
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
|
||||||
|
//
|
||||||
|
// MEDIUM ...
|
||||||
|
case X_MARKET_CYCLE_MEDIUM:
|
||||||
|
//
|
||||||
|
isBarInited = MAsOHCL(
|
||||||
|
iBar,
|
||||||
|
barIndex //
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
|
||||||
|
//
|
||||||
|
// LONG ...
|
||||||
|
case X_MARKET_CYCLE_LONG:
|
||||||
|
//
|
||||||
|
isBarInited = LAsOHCL(
|
||||||
|
iBar,
|
||||||
|
barIndex //
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
|
||||||
|
//
|
||||||
|
// HIND ...
|
||||||
|
case X_MARKET_CYCLE_HIND:
|
||||||
|
//
|
||||||
|
isBarInited = HAsOHCL(
|
||||||
|
iBar,
|
||||||
|
barIndex //
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
if (isBarInited)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
Add(
|
||||||
|
iBar.low,
|
||||||
|
values //
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
result = GetMax(values);
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
double GetCyclesMinLow(
|
||||||
|
int barIndex, // Bar Index
|
||||||
|
ENUM_X_MARKET_CYCLES &cycles[] // Cycles
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
double result = 0;
|
||||||
|
|
||||||
|
//
|
||||||
|
int cyclesCount = ArraySize(cycles);
|
||||||
|
if (!IsValidSize(cyclesCount))
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
double values[];
|
||||||
|
for (int i = 0; i < cyclesCount; i++)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
XOHCL iBar;
|
||||||
|
bool isBarInited = false;
|
||||||
|
|
||||||
|
//
|
||||||
|
switch (cycles[i])
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// CURRENT ...
|
||||||
|
case X_MARKET_CYCLE_UNKNOWN:
|
||||||
|
//
|
||||||
|
isBarInited = CAsOHCL(
|
||||||
|
iBar,
|
||||||
|
barIndex //
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
|
||||||
|
//
|
||||||
|
// SHORT ...
|
||||||
|
case X_MARKET_CYCLE_SHORT:
|
||||||
|
//
|
||||||
|
isBarInited = SAsOHCL(
|
||||||
|
iBar,
|
||||||
|
barIndex //
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
|
||||||
|
//
|
||||||
|
// MEDIUM ...
|
||||||
|
case X_MARKET_CYCLE_MEDIUM:
|
||||||
|
//
|
||||||
|
isBarInited = MAsOHCL(
|
||||||
|
iBar,
|
||||||
|
barIndex //
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
|
||||||
|
//
|
||||||
|
// LONG ...
|
||||||
|
case X_MARKET_CYCLE_LONG:
|
||||||
|
//
|
||||||
|
isBarInited = LAsOHCL(
|
||||||
|
iBar,
|
||||||
|
barIndex //
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
|
||||||
|
//
|
||||||
|
// HIND ...
|
||||||
|
case X_MARKET_CYCLE_HIND:
|
||||||
|
//
|
||||||
|
isBarInited = HAsOHCL(
|
||||||
|
iBar,
|
||||||
|
barIndex //
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
if (isBarInited)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
Add(
|
||||||
|
iBar.low,
|
||||||
|
values //
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
result = GetMin(values);
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Calculate Bullish Power ...
|
||||||
|
double GetBullishPower(
|
||||||
|
int barIndex // Bar Index
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
double result = 0;
|
||||||
|
|
||||||
|
//
|
||||||
|
XOHCL cBar;
|
||||||
|
bool isInited = CAsOHCL(
|
||||||
|
cBar,
|
||||||
|
barIndex //
|
||||||
|
);
|
||||||
|
if (!isInited)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
if (cBar.IsBullish())
|
||||||
|
{
|
||||||
|
result += cBar.GetBody();
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
XOHCL sBar;
|
||||||
|
isInited = SAsOHCL(
|
||||||
|
sBar,
|
||||||
|
barIndex //
|
||||||
|
);
|
||||||
|
if (!isInited)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
if (sBar.IsBullish())
|
||||||
|
{
|
||||||
|
result += sBar.GetBody();
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
XOHCL mBar;
|
||||||
|
isInited = MAsOHCL(
|
||||||
|
mBar,
|
||||||
|
barIndex //
|
||||||
|
);
|
||||||
|
if (!isInited)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
if (mBar.IsBullish())
|
||||||
|
{
|
||||||
|
result += mBar.GetBody();
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
XOHCL lBar;
|
||||||
|
isInited = LAsOHCL(
|
||||||
|
lBar,
|
||||||
|
barIndex //
|
||||||
|
);
|
||||||
|
if (!isInited)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
if (lBar.IsBullish())
|
||||||
|
{
|
||||||
|
result += lBar.GetBody();
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
XOHCL hBar;
|
||||||
|
isInited = HAsOHCL(
|
||||||
|
hBar,
|
||||||
|
barIndex //
|
||||||
|
);
|
||||||
|
if (!isInited)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
if (hBar.IsBullish())
|
||||||
|
{
|
||||||
|
result += hBar.GetBody();
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Calculate Bearish Power ...
|
||||||
|
double GetBearishPower(
|
||||||
|
int barIndex // Bar Index
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
double result = 0;
|
||||||
|
|
||||||
|
//
|
||||||
|
XOHCL cBar;
|
||||||
|
bool isInited = CAsOHCL(
|
||||||
|
cBar,
|
||||||
|
barIndex //
|
||||||
|
);
|
||||||
|
if (!isInited)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
if (cBar.IsBearish())
|
||||||
|
{
|
||||||
|
result += cBar.GetBody();
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
XOHCL sBar;
|
||||||
|
isInited = SAsOHCL(
|
||||||
|
sBar,
|
||||||
|
barIndex //
|
||||||
|
);
|
||||||
|
if (!isInited)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
if (sBar.IsBearish())
|
||||||
|
{
|
||||||
|
result += sBar.GetBody();
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
XOHCL mBar;
|
||||||
|
isInited = MAsOHCL(
|
||||||
|
mBar,
|
||||||
|
barIndex //
|
||||||
|
);
|
||||||
|
if (!isInited)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
if (mBar.IsBearish())
|
||||||
|
{
|
||||||
|
result += mBar.GetBody();
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
XOHCL lBar;
|
||||||
|
isInited = LAsOHCL(
|
||||||
|
lBar,
|
||||||
|
barIndex //
|
||||||
|
);
|
||||||
|
if (!isInited)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
if (lBar.IsBearish())
|
||||||
|
{
|
||||||
|
result += lBar.GetBody();
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
XOHCL hBar;
|
||||||
|
isInited = HAsOHCL(
|
||||||
|
hBar,
|
||||||
|
barIndex //
|
||||||
|
);
|
||||||
|
if (!isInited)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
if (hBar.IsBearish())
|
||||||
|
{
|
||||||
|
result += hBar.GetBody();
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Check Bullish Power is Up ...
|
||||||
|
bool HasBullishPower(
|
||||||
|
int barIndex // Bar Index
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
bool result = false;
|
||||||
|
|
||||||
|
//
|
||||||
|
double bullishPower = GetBullishPower(barIndex);
|
||||||
|
double bearishPower = GetBearishPower(barIndex);
|
||||||
|
|
||||||
|
//
|
||||||
|
result =
|
||||||
|
//
|
||||||
|
bearishPower >= 0 &&
|
||||||
|
bullishPower > bearishPower
|
||||||
|
//
|
||||||
|
;
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Check Bearish Power is Up ...
|
||||||
|
bool HasBearishPower(
|
||||||
|
int barIndex // Bar Index
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
bool result = false;
|
||||||
|
|
||||||
|
//
|
||||||
|
double bullishPower = GetBullishPower(barIndex);
|
||||||
|
double bearishPower = GetBearishPower(barIndex);
|
||||||
|
|
||||||
|
//
|
||||||
|
result =
|
||||||
|
//
|
||||||
|
bullishPower >= 0 &&
|
||||||
|
bearishPower > bullishPower
|
||||||
|
//
|
||||||
|
;
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Check Bullish Power Increasing ...
|
||||||
|
bool IsBullishPowerIncreasing(
|
||||||
|
int barIndex, // Bar Index
|
||||||
|
int loopback = 5 // Loopback
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
bool result = false;
|
||||||
|
|
||||||
|
//
|
||||||
|
if (loopback <= 0)
|
||||||
|
{
|
||||||
|
loopback = 5;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
double firstPower = GetBullishPower(barIndex);
|
||||||
|
double lastPower = firstPower;
|
||||||
|
for (int i = barIndex + 1; i < barIndex + loopback; i++)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
double iPower = GetBullishPower(i);
|
||||||
|
|
||||||
|
//
|
||||||
|
result =
|
||||||
|
//
|
||||||
|
iPower > 0 &&
|
||||||
|
firstPower > 0 &&
|
||||||
|
lastPower > iPower
|
||||||
|
//
|
||||||
|
;
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
lastPower = iPower;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
if (result)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
result =
|
||||||
|
//
|
||||||
|
firstPower > lastPower
|
||||||
|
//
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Check Bullish Power Decreasing ...
|
||||||
|
bool IsBullishPowerDecreasing(
|
||||||
|
int barIndex, // Bar Index
|
||||||
|
int loopback = 5 // Loopback
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
bool result = false;
|
||||||
|
|
||||||
|
//
|
||||||
|
if (loopback <= 0)
|
||||||
|
{
|
||||||
|
loopback = 5;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
double firstPower = GetBullishPower(barIndex);
|
||||||
|
double lastPower = firstPower;
|
||||||
|
for (int i = barIndex + 1; i < barIndex + loopback; i++)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
double iPower = GetBullishPower(i);
|
||||||
|
|
||||||
|
//
|
||||||
|
result =
|
||||||
|
//
|
||||||
|
iPower > 0 &&
|
||||||
|
firstPower > 0 &&
|
||||||
|
lastPower < iPower
|
||||||
|
//
|
||||||
|
;
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
lastPower = iPower;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
if (result)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
result =
|
||||||
|
//
|
||||||
|
firstPower < lastPower
|
||||||
|
//
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Check Bearish Power Increasing ...
|
||||||
|
bool IsBearishPowerIncreasing(
|
||||||
|
int barIndex, // Bar Index
|
||||||
|
int loopback = 5 // Loopback
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
bool result = false;
|
||||||
|
|
||||||
|
//
|
||||||
|
if (loopback <= 0)
|
||||||
|
{
|
||||||
|
loopback = 5;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
double firstPower = GetBearishPower(barIndex);
|
||||||
|
double lastPower = firstPower;
|
||||||
|
for (int i = barIndex + 1; i < barIndex + loopback; i++)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
double iPower = GetBearishPower(i);
|
||||||
|
|
||||||
|
//
|
||||||
|
result =
|
||||||
|
//
|
||||||
|
iPower > 0 &&
|
||||||
|
firstPower > 0 &&
|
||||||
|
lastPower > iPower
|
||||||
|
//
|
||||||
|
;
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
lastPower = iPower;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
if (result)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
result =
|
||||||
|
//
|
||||||
|
firstPower > lastPower
|
||||||
|
//
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Check Bearish Power Decreasing ...
|
||||||
|
bool IsBearishPowerDecreasing(
|
||||||
|
int barIndex, // Bar Index
|
||||||
|
int loopback = 5 // Loopback
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
bool result = false;
|
||||||
|
|
||||||
|
//
|
||||||
|
if (loopback <= 0)
|
||||||
|
{
|
||||||
|
loopback = 5;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
double firstPower = GetBearishPower(barIndex);
|
||||||
|
double lastPower = firstPower;
|
||||||
|
for (int i = barIndex + 1; i < barIndex + loopback; i++)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
double iPower = GetBearishPower(i);
|
||||||
|
|
||||||
|
//
|
||||||
|
result =
|
||||||
|
//
|
||||||
|
iPower > 0 &&
|
||||||
|
firstPower > 0 &&
|
||||||
|
lastPower < iPower
|
||||||
|
//
|
||||||
|
;
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
lastPower = iPower;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
if (result)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
result =
|
||||||
|
//
|
||||||
|
firstPower < lastPower
|
||||||
|
//
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Conditions ...
|
// Conditions ...
|
||||||
|
|
||||||
@@ -2569,9 +3430,9 @@ public:
|
|||||||
|
|
||||||
//
|
//
|
||||||
bool isCSwitchedToBullish = isCBullish &&
|
bool isCSwitchedToBullish = isCBullish &&
|
||||||
!isCBullishPrev;
|
!isCBullishPrev;
|
||||||
bool isCSwitchedToBearish = isCBearish &&
|
bool isCSwitchedToBearish = isCBearish &&
|
||||||
!isCBearishPrev;
|
!isCBearishPrev;
|
||||||
|
|
||||||
//
|
//
|
||||||
bool isCloseOverCHigh = cBar.close > conditions.cBars[cIndex].high;
|
bool isCloseOverCHigh = cBar.close > conditions.cBars[cIndex].high;
|
||||||
@@ -2600,9 +3461,9 @@ public:
|
|||||||
|
|
||||||
//
|
//
|
||||||
bool isSSwitchedToBullish = isSBullish &&
|
bool isSSwitchedToBullish = isSBullish &&
|
||||||
!isSBullishPrev;
|
!isSBullishPrev;
|
||||||
bool isSSwitchedToBearish = isSBearish &&
|
bool isSSwitchedToBearish = isSBearish &&
|
||||||
!isSBearishPrev;
|
!isSBearishPrev;
|
||||||
|
|
||||||
//
|
//
|
||||||
bool isCloseOverSHigh = cBar.close > conditions.sBars[cIndex].high;
|
bool isCloseOverSHigh = cBar.close > conditions.sBars[cIndex].high;
|
||||||
@@ -2631,9 +3492,9 @@ public:
|
|||||||
|
|
||||||
//
|
//
|
||||||
bool isMSwitchedToBullish = isMBullish &&
|
bool isMSwitchedToBullish = isMBullish &&
|
||||||
!isMBullishPrev;
|
!isMBullishPrev;
|
||||||
bool isMSwitchedToBearish = isMBearish &&
|
bool isMSwitchedToBearish = isMBearish &&
|
||||||
!isMBearishPrev;
|
!isMBearishPrev;
|
||||||
|
|
||||||
//
|
//
|
||||||
bool isCloseOverMHigh = cBar.close > conditions.mBars[cIndex].high;
|
bool isCloseOverMHigh = cBar.close > conditions.mBars[cIndex].high;
|
||||||
@@ -2662,9 +3523,9 @@ public:
|
|||||||
|
|
||||||
//
|
//
|
||||||
bool isLSwitchedToBullish = isLBullish &&
|
bool isLSwitchedToBullish = isLBullish &&
|
||||||
!isLBullishPrev;
|
!isLBullishPrev;
|
||||||
bool isLSwitchedToBearish = isLBearish &&
|
bool isLSwitchedToBearish = isLBearish &&
|
||||||
!isLBearishPrev;
|
!isLBearishPrev;
|
||||||
|
|
||||||
//
|
//
|
||||||
bool isCloseOverLHigh = cBar.close > conditions.lBars[cIndex].high;
|
bool isCloseOverLHigh = cBar.close > conditions.lBars[cIndex].high;
|
||||||
@@ -2693,9 +3554,9 @@ public:
|
|||||||
|
|
||||||
//
|
//
|
||||||
bool isHSwitchedToBullish = isHBullish &&
|
bool isHSwitchedToBullish = isHBullish &&
|
||||||
!isHBullishPrev;
|
!isHBullishPrev;
|
||||||
bool isHSwitchedToBearish = isHBearish &&
|
bool isHSwitchedToBearish = isHBearish &&
|
||||||
!isHBearishPrev;
|
!isHBearishPrev;
|
||||||
|
|
||||||
//
|
//
|
||||||
bool isCloseOverHHigh = cBar.close > conditions.hBars[cIndex].high;
|
bool isCloseOverHHigh = cBar.close > conditions.hBars[cIndex].high;
|
||||||
|
|||||||
@@ -1585,6 +1585,794 @@ public:
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Tools ...
|
||||||
|
|
||||||
|
//
|
||||||
|
double GetCyclesMaxFast(
|
||||||
|
int barIndex, // Bar Index
|
||||||
|
ENUM_X_MARKET_CYCLES &cycles[] // Cycles
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
double result = 0;
|
||||||
|
|
||||||
|
//
|
||||||
|
int cyclesCount = ArraySize(cycles);
|
||||||
|
if (!IsValidSize(cyclesCount))
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
double values[];
|
||||||
|
for (int i = 0; i < cyclesCount; i++)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
double iValue = 0;
|
||||||
|
|
||||||
|
//
|
||||||
|
switch (cycles[i])
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// CURRENT ...
|
||||||
|
case X_MARKET_CYCLE_UNKNOWN:
|
||||||
|
//
|
||||||
|
iValue = GetCFast(barIndex);
|
||||||
|
break;
|
||||||
|
|
||||||
|
//
|
||||||
|
// SHORT ...
|
||||||
|
case X_MARKET_CYCLE_SHORT:
|
||||||
|
//
|
||||||
|
iValue = GetSFast(barIndex);
|
||||||
|
break;
|
||||||
|
|
||||||
|
//
|
||||||
|
// MEDIUM ...
|
||||||
|
case X_MARKET_CYCLE_MEDIUM:
|
||||||
|
//
|
||||||
|
iValue = GetMFast(barIndex);
|
||||||
|
break;
|
||||||
|
|
||||||
|
//
|
||||||
|
// LONG ...
|
||||||
|
case X_MARKET_CYCLE_LONG:
|
||||||
|
//
|
||||||
|
iValue = GetLFast(barIndex);
|
||||||
|
break;
|
||||||
|
|
||||||
|
//
|
||||||
|
// HIND ...
|
||||||
|
case X_MARKET_CYCLE_HIND:
|
||||||
|
//
|
||||||
|
iValue = GetHFast(barIndex);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
if (iValue > 0)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
Add(
|
||||||
|
iValue,
|
||||||
|
values //
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
result = GetMax(values);
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
double GetCyclesMinFast(
|
||||||
|
int barIndex, // Bar Index
|
||||||
|
ENUM_X_MARKET_CYCLES &cycles[] // Cycles
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
double result = 0;
|
||||||
|
|
||||||
|
//
|
||||||
|
int cyclesCount = ArraySize(cycles);
|
||||||
|
if (!IsValidSize(cyclesCount))
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
double values[];
|
||||||
|
for (int i = 0; i < cyclesCount; i++)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
double iValue = 0;
|
||||||
|
|
||||||
|
//
|
||||||
|
switch (cycles[i])
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// CURRENT ...
|
||||||
|
case X_MARKET_CYCLE_UNKNOWN:
|
||||||
|
//
|
||||||
|
iValue = GetCFast(barIndex);
|
||||||
|
break;
|
||||||
|
|
||||||
|
//
|
||||||
|
// SHORT ...
|
||||||
|
case X_MARKET_CYCLE_SHORT:
|
||||||
|
//
|
||||||
|
iValue = GetSFast(barIndex);
|
||||||
|
break;
|
||||||
|
|
||||||
|
//
|
||||||
|
// MEDIUM ...
|
||||||
|
case X_MARKET_CYCLE_MEDIUM:
|
||||||
|
//
|
||||||
|
iValue = GetMFast(barIndex);
|
||||||
|
break;
|
||||||
|
|
||||||
|
//
|
||||||
|
// LONG ...
|
||||||
|
case X_MARKET_CYCLE_LONG:
|
||||||
|
//
|
||||||
|
iValue = GetLFast(barIndex);
|
||||||
|
break;
|
||||||
|
|
||||||
|
//
|
||||||
|
// HIND ...
|
||||||
|
case X_MARKET_CYCLE_HIND:
|
||||||
|
//
|
||||||
|
iValue = GetHFast(barIndex);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
if (iValue > 0)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
Add(
|
||||||
|
iValue,
|
||||||
|
values //
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
result = GetMin(values);
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
double GetCyclesMaxSlow(
|
||||||
|
int barIndex, // Bar Index
|
||||||
|
ENUM_X_MARKET_CYCLES &cycles[] // Cycles
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
double result = 0;
|
||||||
|
|
||||||
|
//
|
||||||
|
int cyclesCount = ArraySize(cycles);
|
||||||
|
if (!IsValidSize(cyclesCount))
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
double values[];
|
||||||
|
for (int i = 0; i < cyclesCount; i++)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
double iValue = 0;
|
||||||
|
|
||||||
|
//
|
||||||
|
switch (cycles[i])
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// CURRENT ...
|
||||||
|
case X_MARKET_CYCLE_UNKNOWN:
|
||||||
|
//
|
||||||
|
iValue = GetCSlow(barIndex);
|
||||||
|
break;
|
||||||
|
|
||||||
|
//
|
||||||
|
// SHORT ...
|
||||||
|
case X_MARKET_CYCLE_SHORT:
|
||||||
|
//
|
||||||
|
iValue = GetSSlow(barIndex);
|
||||||
|
break;
|
||||||
|
|
||||||
|
//
|
||||||
|
// MEDIUM ...
|
||||||
|
case X_MARKET_CYCLE_MEDIUM:
|
||||||
|
//
|
||||||
|
iValue = GetMSlow(barIndex);
|
||||||
|
break;
|
||||||
|
|
||||||
|
//
|
||||||
|
// LONG ...
|
||||||
|
case X_MARKET_CYCLE_LONG:
|
||||||
|
//
|
||||||
|
iValue = GetLSlow(barIndex);
|
||||||
|
break;
|
||||||
|
|
||||||
|
//
|
||||||
|
// HIND ...
|
||||||
|
case X_MARKET_CYCLE_HIND:
|
||||||
|
//
|
||||||
|
iValue = GetHSlow(barIndex);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
if (iValue > 0)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
Add(
|
||||||
|
iValue,
|
||||||
|
values //
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
result = GetMax(values);
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
double GetCyclesMinSlow(
|
||||||
|
int barIndex, // Bar Index
|
||||||
|
ENUM_X_MARKET_CYCLES &cycles[] // Cycles
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
double result = 0;
|
||||||
|
|
||||||
|
//
|
||||||
|
int cyclesCount = ArraySize(cycles);
|
||||||
|
if (!IsValidSize(cyclesCount))
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
double values[];
|
||||||
|
for (int i = 0; i < cyclesCount; i++)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
double iValue = 0;
|
||||||
|
|
||||||
|
//
|
||||||
|
switch (cycles[i])
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// CURRENT ...
|
||||||
|
case X_MARKET_CYCLE_UNKNOWN:
|
||||||
|
//
|
||||||
|
iValue = GetCSlow(barIndex);
|
||||||
|
break;
|
||||||
|
|
||||||
|
//
|
||||||
|
// SHORT ...
|
||||||
|
case X_MARKET_CYCLE_SHORT:
|
||||||
|
//
|
||||||
|
iValue = GetSSlow(barIndex);
|
||||||
|
break;
|
||||||
|
|
||||||
|
//
|
||||||
|
// MEDIUM ...
|
||||||
|
case X_MARKET_CYCLE_MEDIUM:
|
||||||
|
//
|
||||||
|
iValue = GetMSlow(barIndex);
|
||||||
|
break;
|
||||||
|
|
||||||
|
//
|
||||||
|
// LONG ...
|
||||||
|
case X_MARKET_CYCLE_LONG:
|
||||||
|
//
|
||||||
|
iValue = GetLSlow(barIndex);
|
||||||
|
break;
|
||||||
|
|
||||||
|
//
|
||||||
|
// HIND ...
|
||||||
|
case X_MARKET_CYCLE_HIND:
|
||||||
|
//
|
||||||
|
iValue = GetHSlow(barIndex);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
if (iValue > 0)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
Add(
|
||||||
|
iValue,
|
||||||
|
values //
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
result = GetMin(values);
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
double GetCyclesMax(
|
||||||
|
int barIndex, // Bar Index
|
||||||
|
ENUM_X_MARKET_CYCLES &cycles[] // Cycles
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
double result = 0;
|
||||||
|
|
||||||
|
//
|
||||||
|
double maxFast = GetCyclesMaxFast(
|
||||||
|
barIndex,
|
||||||
|
cycles //
|
||||||
|
);
|
||||||
|
double maxSlow = GetCyclesMaxSlow(
|
||||||
|
barIndex,
|
||||||
|
cycles //
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
result = MathMax(maxFast, maxSlow);
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
double GetCyclesMin(
|
||||||
|
int barIndex, // Bar Index
|
||||||
|
ENUM_X_MARKET_CYCLES &cycles[] // Cycles
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
double result = 0;
|
||||||
|
|
||||||
|
//
|
||||||
|
double minFast = GetCyclesMinFast(
|
||||||
|
barIndex,
|
||||||
|
cycles //
|
||||||
|
);
|
||||||
|
double minSlow = GetCyclesMinSlow(
|
||||||
|
barIndex,
|
||||||
|
cycles //
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
result = MathMin(minFast, minSlow);
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Calculate Bullish Power ...
|
||||||
|
double GetBullishPower(
|
||||||
|
int barIndex // Bar Index
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
double result = 0;
|
||||||
|
|
||||||
|
//
|
||||||
|
double fast = 0;
|
||||||
|
double slow = 0;
|
||||||
|
double delta = 0;
|
||||||
|
|
||||||
|
//
|
||||||
|
// CURRENT ...
|
||||||
|
fast = GetCFast(barIndex);
|
||||||
|
slow = GetCSlow(barIndex);
|
||||||
|
delta = MathAbs(fast - slow);
|
||||||
|
if (fast > slow)
|
||||||
|
{
|
||||||
|
result += delta;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// SHORT ...
|
||||||
|
fast = GetSFast(barIndex);
|
||||||
|
slow = GetSSlow(barIndex);
|
||||||
|
delta = MathAbs(fast - slow);
|
||||||
|
if (fast > slow)
|
||||||
|
{
|
||||||
|
result += delta;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// MEDIUM ...
|
||||||
|
fast = GetMFast(barIndex);
|
||||||
|
slow = GetMSlow(barIndex);
|
||||||
|
delta = MathAbs(fast - slow);
|
||||||
|
if (fast > slow)
|
||||||
|
{
|
||||||
|
result += delta;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// LONG ...
|
||||||
|
fast = GetLFast(barIndex);
|
||||||
|
slow = GetLSlow(barIndex);
|
||||||
|
delta = MathAbs(fast - slow);
|
||||||
|
if (fast > slow)
|
||||||
|
{
|
||||||
|
result += delta;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// HIND ...
|
||||||
|
fast = GetHFast(barIndex);
|
||||||
|
slow = GetHSlow(barIndex);
|
||||||
|
delta = MathAbs(fast - slow);
|
||||||
|
if (fast > slow)
|
||||||
|
{
|
||||||
|
result += delta;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Calculate Bearish Power ...
|
||||||
|
double GetBearishPower(
|
||||||
|
int barIndex // Bar Index
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
double result = 0;
|
||||||
|
|
||||||
|
//
|
||||||
|
double fast = 0;
|
||||||
|
double slow = 0;
|
||||||
|
double delta = 0;
|
||||||
|
|
||||||
|
//
|
||||||
|
// CURRENT ...
|
||||||
|
fast = GetCFast(barIndex);
|
||||||
|
slow = GetCSlow(barIndex);
|
||||||
|
delta = MathAbs(slow - fast);
|
||||||
|
if (fast < slow)
|
||||||
|
{
|
||||||
|
result += delta;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// SHORT ...
|
||||||
|
fast = GetSFast(barIndex);
|
||||||
|
slow = GetSSlow(barIndex);
|
||||||
|
delta = MathAbs(slow - fast);
|
||||||
|
if (fast < slow)
|
||||||
|
{
|
||||||
|
result += delta;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// MEDIUM ...
|
||||||
|
fast = GetMFast(barIndex);
|
||||||
|
slow = GetMSlow(barIndex);
|
||||||
|
delta = MathAbs(slow - fast);
|
||||||
|
if (fast < slow)
|
||||||
|
{
|
||||||
|
result += delta;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// LONG ...
|
||||||
|
fast = GetLFast(barIndex);
|
||||||
|
slow = GetLSlow(barIndex);
|
||||||
|
delta = MathAbs(slow - fast);
|
||||||
|
if (fast < slow)
|
||||||
|
{
|
||||||
|
result += delta;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// HIND ...
|
||||||
|
fast = GetHFast(barIndex);
|
||||||
|
slow = GetHSlow(barIndex);
|
||||||
|
delta = MathAbs(slow - fast);
|
||||||
|
if (fast < slow)
|
||||||
|
{
|
||||||
|
result += delta;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Check Bullish Power is Up ...
|
||||||
|
bool HasBullishPower(
|
||||||
|
int barIndex // Bar Index
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
bool result = false;
|
||||||
|
|
||||||
|
//
|
||||||
|
double bullishPower = GetBullishPower(barIndex);
|
||||||
|
double bearishPower = GetBearishPower(barIndex);
|
||||||
|
|
||||||
|
//
|
||||||
|
result =
|
||||||
|
//
|
||||||
|
bearishPower >= 0 &&
|
||||||
|
bullishPower > bearishPower
|
||||||
|
//
|
||||||
|
;
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Check Bearish Power is Up ...
|
||||||
|
bool HasBearishPower(
|
||||||
|
int barIndex // Bar Index
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
bool result = false;
|
||||||
|
|
||||||
|
//
|
||||||
|
double bullishPower = GetBullishPower(barIndex);
|
||||||
|
double bearishPower = GetBearishPower(barIndex);
|
||||||
|
|
||||||
|
//
|
||||||
|
result =
|
||||||
|
//
|
||||||
|
bullishPower >= 0 &&
|
||||||
|
bearishPower > bullishPower
|
||||||
|
//
|
||||||
|
;
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Check Bullish Power Increasing ...
|
||||||
|
bool IsBullishPowerIncreasing(
|
||||||
|
int barIndex, // Bar Index
|
||||||
|
int loopback = 5 // Loopback
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
bool result = false;
|
||||||
|
|
||||||
|
//
|
||||||
|
if (loopback <= 0)
|
||||||
|
{
|
||||||
|
loopback = 5;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
double firstPower = GetBullishPower(barIndex);
|
||||||
|
double lastPower = firstPower;
|
||||||
|
for (int i = barIndex + 1; i < barIndex + loopback; i++)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
double iPower = GetBullishPower(i);
|
||||||
|
|
||||||
|
//
|
||||||
|
result =
|
||||||
|
//
|
||||||
|
iPower > 0 &&
|
||||||
|
firstPower > 0 &&
|
||||||
|
lastPower > iPower
|
||||||
|
//
|
||||||
|
;
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
lastPower = iPower;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
if (result)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
result =
|
||||||
|
//
|
||||||
|
firstPower > lastPower
|
||||||
|
//
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Check Bullish Power Decreasing ...
|
||||||
|
bool IsBullishPowerDecreasing(
|
||||||
|
int barIndex, // Bar Index
|
||||||
|
int loopback = 5 // Loopback
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
bool result = false;
|
||||||
|
|
||||||
|
//
|
||||||
|
if (loopback <= 0)
|
||||||
|
{
|
||||||
|
loopback = 5;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
double firstPower = GetBullishPower(barIndex);
|
||||||
|
double lastPower = firstPower;
|
||||||
|
for (int i = barIndex + 1; i < barIndex + loopback; i++)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
double iPower = GetBullishPower(i);
|
||||||
|
|
||||||
|
//
|
||||||
|
result =
|
||||||
|
//
|
||||||
|
iPower > 0 &&
|
||||||
|
firstPower > 0 &&
|
||||||
|
lastPower < iPower
|
||||||
|
//
|
||||||
|
;
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
lastPower = iPower;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
if (result)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
result =
|
||||||
|
//
|
||||||
|
firstPower < lastPower
|
||||||
|
//
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Check Bearish Power Increasing ...
|
||||||
|
bool IsBearishPowerIncreasing(
|
||||||
|
int barIndex, // Bar Index
|
||||||
|
int loopback = 5 // Loopback
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
bool result = false;
|
||||||
|
|
||||||
|
//
|
||||||
|
if (loopback <= 0)
|
||||||
|
{
|
||||||
|
loopback = 5;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
double firstPower = GetBearishPower(barIndex);
|
||||||
|
double lastPower = firstPower;
|
||||||
|
for (int i = barIndex + 1; i < barIndex + loopback; i++)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
double iPower = GetBearishPower(i);
|
||||||
|
|
||||||
|
//
|
||||||
|
result =
|
||||||
|
//
|
||||||
|
iPower > 0 &&
|
||||||
|
firstPower > 0 &&
|
||||||
|
lastPower > iPower
|
||||||
|
//
|
||||||
|
;
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
lastPower = iPower;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
if (result)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
result =
|
||||||
|
//
|
||||||
|
firstPower > lastPower
|
||||||
|
//
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Check Bearish Power Decreasing ...
|
||||||
|
bool IsBearishPowerDecreasing(
|
||||||
|
int barIndex, // Bar Index
|
||||||
|
int loopback = 5 // Loopback
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
bool result = false;
|
||||||
|
|
||||||
|
//
|
||||||
|
if (loopback <= 0)
|
||||||
|
{
|
||||||
|
loopback = 5;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
double firstPower = GetBearishPower(barIndex);
|
||||||
|
double lastPower = firstPower;
|
||||||
|
for (int i = barIndex + 1; i < barIndex + loopback; i++)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
double iPower = GetBearishPower(i);
|
||||||
|
|
||||||
|
//
|
||||||
|
result =
|
||||||
|
//
|
||||||
|
iPower > 0 &&
|
||||||
|
firstPower > 0 &&
|
||||||
|
lastPower < iPower
|
||||||
|
//
|
||||||
|
;
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
lastPower = iPower;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
if (result)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
result =
|
||||||
|
//
|
||||||
|
firstPower < lastPower
|
||||||
|
//
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Conditions ...
|
||||||
|
|
||||||
//
|
//
|
||||||
bool GetConditions(
|
bool GetConditions(
|
||||||
XCHMConditions &conditions, //
|
XCHMConditions &conditions, //
|
||||||
|
|||||||
@@ -61,12 +61,15 @@ input ENUM_TIMEFRAMES hcPeriod = NULL; // Time Period
|
|||||||
// Presentation ...
|
// Presentation ...
|
||||||
input group "Presentation";
|
input group "Presentation";
|
||||||
|
|
||||||
|
//
|
||||||
|
input bool ignoreShadows = false; // Ignore Bar Shadows
|
||||||
|
|
||||||
//
|
//
|
||||||
input bool showCurrent = true; // Show Current Cycle
|
input bool showCurrent = true; // Show Current Cycle
|
||||||
input bool showShort = true; // Show Short Cycle
|
input bool showShort = true; // Show Short Cycle
|
||||||
input bool showMedium = true; // Show Medium Cycle
|
input bool showMedium = true; // Show Medium Cycle
|
||||||
input bool showLong = true; // Show Long Cycle
|
input bool showLong = true; // Show Long Cycle
|
||||||
input bool showHind = true; // Show Hind Cycle
|
input bool showHind = true; // Show Hind Cycle
|
||||||
|
|
||||||
//
|
//
|
||||||
// Buffers ...
|
// Buffers ...
|
||||||
@@ -968,28 +971,6 @@ void CalculateCycle(
|
|||||||
open //
|
open //
|
||||||
);
|
);
|
||||||
|
|
||||||
//
|
|
||||||
// High ...
|
|
||||||
int calculatedSMHighs = ExponentialMAOnBuffer(
|
|
||||||
ratesTotal,
|
|
||||||
prevCalculated,
|
|
||||||
0,
|
|
||||||
length,
|
|
||||||
highBuffer,
|
|
||||||
high //
|
|
||||||
);
|
|
||||||
|
|
||||||
//
|
|
||||||
// Low ...
|
|
||||||
int calculatedSMLows = ExponentialMAOnBuffer(
|
|
||||||
ratesTotal,
|
|
||||||
prevCalculated,
|
|
||||||
0,
|
|
||||||
length,
|
|
||||||
lowBuffer,
|
|
||||||
low //
|
|
||||||
);
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Close ...
|
// Close ...
|
||||||
int calculatedSMCloses = ExponentialMAOnBuffer(
|
int calculatedSMCloses = ExponentialMAOnBuffer(
|
||||||
@@ -1001,6 +982,58 @@ void CalculateCycle(
|
|||||||
close //
|
close //
|
||||||
);
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
int calculatedSMLows = 0;
|
||||||
|
int calculatedSMHighs = 0;
|
||||||
|
if (!ignoreShadows)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// High ...
|
||||||
|
calculatedSMHighs = ExponentialMAOnBuffer(
|
||||||
|
ratesTotal,
|
||||||
|
prevCalculated,
|
||||||
|
0,
|
||||||
|
length,
|
||||||
|
highBuffer,
|
||||||
|
high //
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Low ...
|
||||||
|
calculatedSMLows = ExponentialMAOnBuffer(
|
||||||
|
ratesTotal,
|
||||||
|
prevCalculated,
|
||||||
|
0,
|
||||||
|
length,
|
||||||
|
lowBuffer,
|
||||||
|
low //
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// High ...
|
||||||
|
calculatedSMHighs = ExponentialMAOnBuffer(
|
||||||
|
ratesTotal,
|
||||||
|
prevCalculated,
|
||||||
|
0,
|
||||||
|
length,
|
||||||
|
openBuffer,
|
||||||
|
high //
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Low ...
|
||||||
|
calculatedSMLows = ExponentialMAOnBuffer(
|
||||||
|
ratesTotal,
|
||||||
|
prevCalculated,
|
||||||
|
0,
|
||||||
|
length,
|
||||||
|
closeBuffer,
|
||||||
|
low //
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Find Calculated Items for Colors Calculations ...
|
// Find Calculated Items for Colors Calculations ...
|
||||||
int mNumberOfItems = MathMin(calculatedSMOpens, calculatedSMHighs);
|
int mNumberOfItems = MathMin(calculatedSMOpens, calculatedSMHighs);
|
||||||
|
|||||||
@@ -1522,7 +1522,9 @@ public:
|
|||||||
hasLong =
|
hasLong =
|
||||||
//
|
//
|
||||||
hasBullishPower &&
|
hasBullishPower &&
|
||||||
|
cBar.IsBullish() &&
|
||||||
hasBullishPressure &&
|
hasBullishPressure &&
|
||||||
|
chhkConditions.isHBullish &&
|
||||||
chstrConditions.isHBullish &&
|
chstrConditions.isHBullish &&
|
||||||
cheConditions.isStrongBullish &&
|
cheConditions.isStrongBullish &&
|
||||||
cBar.low > pvConditions.fib2s[cIndex]
|
cBar.low > pvConditions.fib2s[cIndex]
|
||||||
@@ -1534,7 +1536,7 @@ public:
|
|||||||
{
|
{
|
||||||
//
|
//
|
||||||
type = POSITION_TYPE_BUY;
|
type = POSITION_TYPE_BUY;
|
||||||
sl = pvConditions.fib3s[cIndex];
|
sl = pvConditions.fib2s[cIndex];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1546,7 +1548,9 @@ public:
|
|||||||
hasShort =
|
hasShort =
|
||||||
//
|
//
|
||||||
hasBearishPower &&
|
hasBearishPower &&
|
||||||
|
cBar.IsBearish() &&
|
||||||
hasBearishPressure &&
|
hasBearishPressure &&
|
||||||
|
chhkConditions.isHBearish &&
|
||||||
chstrConditions.isHBearish &&
|
chstrConditions.isHBearish &&
|
||||||
cheConditions.isStrongBearish &&
|
cheConditions.isStrongBearish &&
|
||||||
cBar.high < pvConditions.fib4s[cIndex]
|
cBar.high < pvConditions.fib4s[cIndex]
|
||||||
@@ -1558,7 +1562,7 @@ public:
|
|||||||
{
|
{
|
||||||
//
|
//
|
||||||
type = POSITION_TYPE_SELL;
|
type = POSITION_TYPE_SELL;
|
||||||
sl = pvConditions.fib3s[cIndex];
|
sl = pvConditions.fib4s[cIndex];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1874,6 +1878,7 @@ private:
|
|||||||
chhkInputs.hcPeriod = hcPeriod;
|
chhkInputs.hcPeriod = hcPeriod;
|
||||||
|
|
||||||
//
|
//
|
||||||
|
chhkInputs.ignoreShadows = true;
|
||||||
chhkInputs.showCurrent = false;
|
chhkInputs.showCurrent = false;
|
||||||
chhkInputs.showShort = false;
|
chhkInputs.showShort = false;
|
||||||
chhkInputs.showMedium = false;
|
chhkInputs.showMedium = false;
|
||||||
|
|||||||
Reference in New Issue
Block a user