last refactor ...
This commit is contained in:
@@ -0,0 +1,200 @@
|
||||
//
|
||||
int zIndex = 0;
|
||||
int cIndex = zIndex + 1;
|
||||
int pIndex = cIndex + 1;
|
||||
int ppIndex = pIndex + 1;
|
||||
|
||||
//
|
||||
// Last Bar ...
|
||||
XOHCL cBar;
|
||||
result = cBar.Init(
|
||||
position.symbol,
|
||||
position.period,
|
||||
cIndex //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Previous Bar of Last Bar ...
|
||||
XOHCL pBar;
|
||||
result = cBar.GetPreviousBar(pBar);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Last Swing Low Bar ...
|
||||
XOHCL lastSwingLow;
|
||||
result = cBar.FindLastSwingLow(lastSwingLow);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Last Swing High Bar ...
|
||||
XOHCL lastSwingHigh;
|
||||
result = cBar.FindLastSwingHigh(lastSwingHigh);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Common Conditions For Bullish and Bearish Powers ...
|
||||
|
||||
//
|
||||
// For Trend ...
|
||||
XOHCL tmpHSW[];
|
||||
XOHCL tmpLSW[];
|
||||
|
||||
//
|
||||
// Detect Bullish/Bearish Patterns and Trends ...
|
||||
|
||||
//
|
||||
// Bullish ...
|
||||
bool hasBullishPower = cBar.HasBullishPower();
|
||||
bool hasBullishPattern = HasBullishPattern(cBar);
|
||||
bool hasBullishPressure = cBar.HasBullishPressure();
|
||||
bool isBullishTrend = cBar.HasBullishTrend(
|
||||
tmpHSW,
|
||||
tmpLSW,
|
||||
true //
|
||||
);
|
||||
bool isBullishTrend1 = cBar.HasBullishTrend(
|
||||
tmpHSW,
|
||||
tmpLSW,
|
||||
false //
|
||||
);
|
||||
bool hasBullishTrend =
|
||||
//
|
||||
isBullishTrend
|
||||
//
|
||||
||
|
||||
//
|
||||
isBullishTrend1
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
// Bearish ...
|
||||
bool hasBearishPower = cBar.HasBearishPower();
|
||||
bool hasBearishPattern = HasBearishPattern(cBar);
|
||||
bool hasBearishPressure = cBar.HasBearishPressure();
|
||||
bool isBearishTrend = cBar.HasBearishTrend(
|
||||
tmpHSW,
|
||||
tmpLSW,
|
||||
true //
|
||||
);
|
||||
bool isBearishTrend1 = cBar.HasBearishTrend(
|
||||
tmpHSW,
|
||||
tmpLSW,
|
||||
false //
|
||||
);
|
||||
bool hasBearishTrend =
|
||||
//
|
||||
isBearishTrend
|
||||
//
|
||||
||
|
||||
//
|
||||
isBearishTrend1
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
// Define Conditions ...
|
||||
MqlTick ticks[];
|
||||
int ticksCount = CopyTicks(
|
||||
position.symbol,
|
||||
ticks,
|
||||
COPY_TICKS_ALL,
|
||||
0,
|
||||
5 //
|
||||
);
|
||||
|
||||
//
|
||||
// TODO: Check Volume if Required ...
|
||||
|
||||
//
|
||||
bool isTicksBullishForLong =
|
||||
//
|
||||
GetTickExit(ticks[0], POSITION_TYPE_BUY, position.symbol) > GetTickExit(ticks[1], POSITION_TYPE_BUY, position.symbol) &&
|
||||
GetTickExit(ticks[1], POSITION_TYPE_BUY, position.symbol) > GetTickExit(ticks[2], POSITION_TYPE_BUY, position.symbol) &&
|
||||
GetTickExit(ticks[2], POSITION_TYPE_BUY, position.symbol) > GetTickExit(ticks[3], POSITION_TYPE_BUY, position.symbol)
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
bool isTicksBearishForLong =
|
||||
//
|
||||
GetTickExit(ticks[0], POSITION_TYPE_BUY, position.symbol) < GetTickExit(ticks[1], POSITION_TYPE_BUY, position.symbol) &&
|
||||
GetTickExit(ticks[1], POSITION_TYPE_BUY, position.symbol) < GetTickExit(ticks[2], POSITION_TYPE_BUY, position.symbol) &&
|
||||
GetTickExit(ticks[2], POSITION_TYPE_BUY, position.symbol) < GetTickExit(ticks[3], POSITION_TYPE_BUY, position.symbol)
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
bool isTicksBullishForShort =
|
||||
//
|
||||
GetTickExit(ticks[0], POSITION_TYPE_SELL, position.symbol) > GetTickExit(ticks[1], POSITION_TYPE_SELL, position.symbol) &&
|
||||
GetTickExit(ticks[1], POSITION_TYPE_SELL, position.symbol) > GetTickExit(ticks[2], POSITION_TYPE_SELL, position.symbol) &&
|
||||
GetTickExit(ticks[2], POSITION_TYPE_SELL, position.symbol) > GetTickExit(ticks[3], POSITION_TYPE_SELL, position.symbol)
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
bool isTicksBearishForShort =
|
||||
//
|
||||
GetTickExit(ticks[0], POSITION_TYPE_SELL, position.symbol) < GetTickExit(ticks[1], POSITION_TYPE_SELL, position.symbol) &&
|
||||
GetTickExit(ticks[1], POSITION_TYPE_SELL, position.symbol) < GetTickExit(ticks[2], POSITION_TYPE_SELL, position.symbol) &&
|
||||
GetTickExit(ticks[2], POSITION_TYPE_SELL, position.symbol) < GetTickExit(ticks[3], POSITION_TYPE_SELL, position.symbol)
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
bool hasBullishDecision =
|
||||
//
|
||||
cBar.IsBullishDecision()
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
bool hasBearishDecision =
|
||||
//
|
||||
cBar.IsBearishDecision()
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
bool hasBullishConditions =
|
||||
//
|
||||
(
|
||||
//
|
||||
hasBullishTrend &&
|
||||
hasBullishDecision &&
|
||||
(hasBullishPower ||
|
||||
hasBullishPattern ||
|
||||
hasBullishPressure)
|
||||
//
|
||||
)
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
bool hasBearishConditions =
|
||||
//
|
||||
(
|
||||
//
|
||||
hasBearishTrend &&
|
||||
hasBearishDecision &&
|
||||
(hasBearishPower ||
|
||||
hasBearishPattern ||
|
||||
hasBearishPressure)
|
||||
//
|
||||
)
|
||||
//
|
||||
;
|
||||
Reference in New Issue
Block a user