last works ...
adding some tools to ch helper classes ...
This commit is contained in:
@@ -2107,6 +2107,55 @@ public:
|
||||
.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 ...
|
||||
int GetPositions(
|
||||
@@ -4198,6 +4247,18 @@ public:
|
||||
mAllowHedging = value;
|
||||
}
|
||||
|
||||
//
|
||||
bool OnlyHedgeSupportedPositions()
|
||||
{
|
||||
return mOnlyHedgeSupportedPositions;
|
||||
}
|
||||
|
||||
//
|
||||
void OnlyHedgeSupportedPositions(bool value)
|
||||
{
|
||||
mOnlyHedgeSupportedPositions = value;
|
||||
}
|
||||
|
||||
//
|
||||
double HedgeVolumeFactor()
|
||||
{
|
||||
@@ -4456,7 +4517,9 @@ public:
|
||||
{
|
||||
//
|
||||
// Check Values Validation ...
|
||||
if (count > 1 &&
|
||||
if ((count > 1 ||
|
||||
(count == 1 &&
|
||||
mOnlyHedgeSupportedPositions)) &&
|
||||
mHedgeVolumeFactor > 0 &&
|
||||
mHedgeMinProfitPerVolumeFactor > 0)
|
||||
{
|
||||
@@ -4492,12 +4555,17 @@ public:
|
||||
//
|
||||
string msg = ToString(positionsCount) + " Closed Due Hedge Action in: " + ToString(profits) + " ...";
|
||||
Alert(msg);
|
||||
|
||||
//
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
//
|
||||
// Do Force Closing ...
|
||||
|
||||
@@ -4529,6 +4597,17 @@ public:
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
// Allow Trail Only for Positions Which
|
||||
// doesnt Have Any Support ...
|
||||
bool iHasSupport = mTrader.HasSupport(
|
||||
ticket //
|
||||
);
|
||||
if (iHasSupport)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
// Trail ...
|
||||
if (mData[i].allowTrailStop)
|
||||
@@ -4562,8 +4641,8 @@ public:
|
||||
// Calculate new Level SL ...
|
||||
double sl =
|
||||
isLong
|
||||
? iPosition.entry + (trailStepInPoints * points)
|
||||
: iPosition.entry - (trailStepInPoints * points);
|
||||
? iPosition.entry + (mData[i].trailLevel * (trailStepInPoints * points))
|
||||
: iPosition.entry - (mData[i].trailLevel * (trailStepInPoints * points));
|
||||
sl = NormalizePrice(
|
||||
sl,
|
||||
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:
|
||||
@@ -4729,6 +4832,7 @@ protected:
|
||||
//
|
||||
// Hedging ...
|
||||
bool mAllowHedging; // Hedge Trades
|
||||
bool mOnlyHedgeSupportedPositions; // Only Hedge Supported Positions
|
||||
double mHedgeVolumeFactor; // Hedging 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
|
||||
|
||||
//
|
||||
int eaMaxAllowedLongs = 1; // Max Allowed Long Positions
|
||||
int eaMaxAllowedShorts = 1; // Max Allowed Short Positions
|
||||
int eaMaxAllowedLongs = 0; // Max Allowed Long Positions
|
||||
int eaMaxAllowedShorts = 0; // Max Allowed Short Positions
|
||||
|
||||
//
|
||||
input double eaTPPoint = 200; // Static TP Point
|
||||
@@ -250,13 +250,14 @@ bool InitialEA()
|
||||
// Configure Hedging ...
|
||||
eaTradeHandler.AllowHedging(false);
|
||||
eaTradeHandler.HedgeVolumeFactor(eaVolume);
|
||||
eaTradeHandler.HedgeMinProfitPerVolumeFactor(0.2);
|
||||
eaTradeHandler.OnlyHedgeSupportedPositions(false);
|
||||
eaTradeHandler.HedgeMinProfitPerVolumeFactor(0.3);
|
||||
|
||||
//
|
||||
// Configure Trailing ...
|
||||
eaTradeHandler.AllowTrailStops(false);
|
||||
eaTradeHandler.TrailStepInPoint(25);
|
||||
eaTradeHandler.TrailStartInPoint(50);
|
||||
eaTradeHandler.TrailStepInPoint(10);
|
||||
eaTradeHandler.TrailStartInPoint(20);
|
||||
eaTradeHandler.IgnoreTPOnTrail(true);
|
||||
eaTradeHandler.TrailBasedOnProfit(true);
|
||||
|
||||
@@ -267,7 +268,7 @@ bool InitialEA()
|
||||
bool drawAreas = false;
|
||||
|
||||
//
|
||||
bool useEURUSD = true;
|
||||
bool useEURUSD = false;
|
||||
bool useUSDCHF = false;
|
||||
bool useUSDJPY = false;
|
||||
bool useGBPUSD = false;
|
||||
@@ -276,7 +277,7 @@ bool InitialEA()
|
||||
//
|
||||
bool useXTest = false;
|
||||
bool useXDTD = false;
|
||||
bool useXCHKM = true;
|
||||
bool useXCHKM = false;
|
||||
|
||||
//
|
||||
// EURUSD ...
|
||||
@@ -382,30 +383,30 @@ bool InitialEA()
|
||||
}
|
||||
|
||||
//
|
||||
// XSCXDTDStrategy *xTDTStrategy;
|
||||
// xTDTStrategy = new XSCXDTDStrategy(
|
||||
// _Symbol,
|
||||
// _Period,
|
||||
// eaVolume,
|
||||
// eaR2R, // R2R ...
|
||||
// eaSlippage,
|
||||
// eaMagicNumber,
|
||||
// true, // Ignore Signal Execution
|
||||
// true, // Use TP SL Point
|
||||
// false, // Use Max
|
||||
// eaTPPoint, // TP
|
||||
// eaSLPoint, // SL
|
||||
// eaIgnoreTP,
|
||||
// eaIgnoreSL,
|
||||
// eaAllowLong,
|
||||
// eaAllowShort,
|
||||
// eaMaxAllowedLongs, // Max Longs
|
||||
// eaMaxAllowedShorts // Max Shorts
|
||||
// );
|
||||
// xTDTStrategy.SetAlertLogAlerts(true);
|
||||
// xTDTStrategy.SetAlertEnableAlerts(true);
|
||||
// xTDTStrategy.AddSignalEventHandler(OnSignalRecieved);
|
||||
// RegisterStrategy(xTDTStrategy);
|
||||
XSCXCHKMStrategy *xchmStrategy;
|
||||
xchmStrategy = new XSCXCHKMStrategy(
|
||||
_Symbol,
|
||||
_Period,
|
||||
eaVolume,
|
||||
eaR2R, // R2R ...
|
||||
eaSlippage,
|
||||
eaMagicNumber,
|
||||
true, // Ignore Signal Execution
|
||||
false, // Use TP SL Point
|
||||
false, // Use Max
|
||||
eaTPPoint, // TP
|
||||
eaSLPoint, // SL
|
||||
eaIgnoreTP,
|
||||
false, // eaIgnoreSL,
|
||||
eaAllowLong,
|
||||
eaAllowShort,
|
||||
eaMaxAllowedLongs, // Max Longs
|
||||
eaMaxAllowedShorts // Max Shorts
|
||||
);
|
||||
xchmStrategy.SetAlertLogAlerts(true);
|
||||
xchmStrategy.SetAlertEnableAlerts(true);
|
||||
xchmStrategy.AddSignalEventHandler(OnSignalRecieved);
|
||||
RegisterStrategy(xchmStrategy);
|
||||
|
||||
//
|
||||
return result;
|
||||
@@ -470,6 +471,7 @@ void HandleTradeState()
|
||||
void OnSignalRecieved(XSignal &signal)
|
||||
{
|
||||
//
|
||||
// Check Max Allowed ...
|
||||
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;
|
||||
bool isExecuted = eaTrader.ExecuteSignal(
|
||||
|
||||
@@ -98,11 +98,12 @@ struct XCHHKInputs
|
||||
|
||||
//
|
||||
// Presentation ...
|
||||
bool showCurrent; // Show Current Cycle
|
||||
bool showShort; // Show Short Cycle
|
||||
bool showMedium; // Show Medium Cycle
|
||||
bool showLong; // Show Long Cycle
|
||||
bool showHind; // Show Hind Cycle
|
||||
bool ignoreShadows; // Ignore Bar Shadows
|
||||
bool showCurrent; // Show Current Cycle
|
||||
bool showShort; // Show Short Cycle
|
||||
bool showMedium; // Show Medium Cycle
|
||||
bool showLong; // Show Long Cycle
|
||||
bool showHind; // Show Hind Cycle
|
||||
|
||||
//
|
||||
// Constructor(s) ...
|
||||
@@ -133,6 +134,7 @@ struct XCHHKInputs
|
||||
hcPeriod = NULL;
|
||||
|
||||
//
|
||||
ignoreShadows = false;
|
||||
showCurrent = false;
|
||||
showShort = false;
|
||||
showMedium = false;
|
||||
@@ -158,6 +160,7 @@ struct XCHHKInputs
|
||||
hcPeriod = NULL;
|
||||
|
||||
//
|
||||
ignoreShadows = false;
|
||||
showCurrent = true;
|
||||
showShort = true;
|
||||
showMedium = true;
|
||||
@@ -790,6 +793,7 @@ public:
|
||||
//
|
||||
// Presentation ...
|
||||
"",
|
||||
mInputs.ignoreShadows,
|
||||
mInputs.showCurrent,
|
||||
mInputs.showShort,
|
||||
mInputs.showMedium,
|
||||
@@ -2453,6 +2457,863 @@ public:
|
||||
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 ...
|
||||
|
||||
@@ -2569,9 +3430,9 @@ public:
|
||||
|
||||
//
|
||||
bool isCSwitchedToBullish = isCBullish &&
|
||||
!isCBullishPrev;
|
||||
!isCBullishPrev;
|
||||
bool isCSwitchedToBearish = isCBearish &&
|
||||
!isCBearishPrev;
|
||||
!isCBearishPrev;
|
||||
|
||||
//
|
||||
bool isCloseOverCHigh = cBar.close > conditions.cBars[cIndex].high;
|
||||
@@ -2600,9 +3461,9 @@ public:
|
||||
|
||||
//
|
||||
bool isSSwitchedToBullish = isSBullish &&
|
||||
!isSBullishPrev;
|
||||
!isSBullishPrev;
|
||||
bool isSSwitchedToBearish = isSBearish &&
|
||||
!isSBearishPrev;
|
||||
!isSBearishPrev;
|
||||
|
||||
//
|
||||
bool isCloseOverSHigh = cBar.close > conditions.sBars[cIndex].high;
|
||||
@@ -2631,9 +3492,9 @@ public:
|
||||
|
||||
//
|
||||
bool isMSwitchedToBullish = isMBullish &&
|
||||
!isMBullishPrev;
|
||||
!isMBullishPrev;
|
||||
bool isMSwitchedToBearish = isMBearish &&
|
||||
!isMBearishPrev;
|
||||
!isMBearishPrev;
|
||||
|
||||
//
|
||||
bool isCloseOverMHigh = cBar.close > conditions.mBars[cIndex].high;
|
||||
@@ -2662,9 +3523,9 @@ public:
|
||||
|
||||
//
|
||||
bool isLSwitchedToBullish = isLBullish &&
|
||||
!isLBullishPrev;
|
||||
!isLBullishPrev;
|
||||
bool isLSwitchedToBearish = isLBearish &&
|
||||
!isLBearishPrev;
|
||||
!isLBearishPrev;
|
||||
|
||||
//
|
||||
bool isCloseOverLHigh = cBar.close > conditions.lBars[cIndex].high;
|
||||
@@ -2693,9 +3554,9 @@ public:
|
||||
|
||||
//
|
||||
bool isHSwitchedToBullish = isHBullish &&
|
||||
!isHBullishPrev;
|
||||
!isHBullishPrev;
|
||||
bool isHSwitchedToBearish = isHBearish &&
|
||||
!isHBearishPrev;
|
||||
!isHBearishPrev;
|
||||
|
||||
//
|
||||
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(
|
||||
XCHMConditions &conditions, //
|
||||
|
||||
@@ -61,12 +61,15 @@ input ENUM_TIMEFRAMES hcPeriod = NULL; // Time Period
|
||||
// Presentation ...
|
||||
input group "Presentation";
|
||||
|
||||
//
|
||||
input bool ignoreShadows = false; // Ignore Bar Shadows
|
||||
|
||||
//
|
||||
input bool showCurrent = true; // Show Current Cycle
|
||||
input bool showShort = true; // Show Short Cycle
|
||||
input bool showMedium = true; // Show Medium Cycle
|
||||
input bool showLong = true; // Show Long Cycle
|
||||
input bool showHind = true; // Show Hind Cycle
|
||||
input bool showShort = true; // Show Short Cycle
|
||||
input bool showMedium = true; // Show Medium Cycle
|
||||
input bool showLong = true; // Show Long Cycle
|
||||
input bool showHind = true; // Show Hind Cycle
|
||||
|
||||
//
|
||||
// Buffers ...
|
||||
@@ -968,28 +971,6 @@ void CalculateCycle(
|
||||
open //
|
||||
);
|
||||
|
||||
//
|
||||
// High ...
|
||||
int calculatedSMHighs = ExponentialMAOnBuffer(
|
||||
ratesTotal,
|
||||
prevCalculated,
|
||||
0,
|
||||
length,
|
||||
highBuffer,
|
||||
high //
|
||||
);
|
||||
|
||||
//
|
||||
// Low ...
|
||||
int calculatedSMLows = ExponentialMAOnBuffer(
|
||||
ratesTotal,
|
||||
prevCalculated,
|
||||
0,
|
||||
length,
|
||||
lowBuffer,
|
||||
low //
|
||||
);
|
||||
|
||||
//
|
||||
// Close ...
|
||||
int calculatedSMCloses = ExponentialMAOnBuffer(
|
||||
@@ -1001,6 +982,58 @@ void CalculateCycle(
|
||||
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 ...
|
||||
int mNumberOfItems = MathMin(calculatedSMOpens, calculatedSMHighs);
|
||||
|
||||
@@ -1522,7 +1522,9 @@ public:
|
||||
hasLong =
|
||||
//
|
||||
hasBullishPower &&
|
||||
cBar.IsBullish() &&
|
||||
hasBullishPressure &&
|
||||
chhkConditions.isHBullish &&
|
||||
chstrConditions.isHBullish &&
|
||||
cheConditions.isStrongBullish &&
|
||||
cBar.low > pvConditions.fib2s[cIndex]
|
||||
@@ -1534,7 +1536,7 @@ public:
|
||||
{
|
||||
//
|
||||
type = POSITION_TYPE_BUY;
|
||||
sl = pvConditions.fib3s[cIndex];
|
||||
sl = pvConditions.fib2s[cIndex];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1546,7 +1548,9 @@ public:
|
||||
hasShort =
|
||||
//
|
||||
hasBearishPower &&
|
||||
cBar.IsBearish() &&
|
||||
hasBearishPressure &&
|
||||
chhkConditions.isHBearish &&
|
||||
chstrConditions.isHBearish &&
|
||||
cheConditions.isStrongBearish &&
|
||||
cBar.high < pvConditions.fib4s[cIndex]
|
||||
@@ -1558,7 +1562,7 @@ public:
|
||||
{
|
||||
//
|
||||
type = POSITION_TYPE_SELL;
|
||||
sl = pvConditions.fib3s[cIndex];
|
||||
sl = pvConditions.fib4s[cIndex];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1874,6 +1878,7 @@ private:
|
||||
chhkInputs.hcPeriod = hcPeriod;
|
||||
|
||||
//
|
||||
chhkInputs.ignoreShadows = true;
|
||||
chhkInputs.showCurrent = false;
|
||||
chhkInputs.showShort = false;
|
||||
chhkInputs.showMedium = false;
|
||||
|
||||
Reference in New Issue
Block a user