last works ...
This commit is contained in:
@@ -0,0 +1,191 @@
|
||||
//
|
||||
// Check Conditions For Signal ...
|
||||
bool HasSignal(
|
||||
XSignal &signal //
|
||||
) override
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
signal.Clean();
|
||||
|
||||
//
|
||||
double sl = 0;
|
||||
double tp = 0;
|
||||
double risk = 0;
|
||||
double entry = 0;
|
||||
double reward = 0;
|
||||
double r2r = R2R();
|
||||
ENUM_POSITION_TYPE type;
|
||||
ENUM_X_ORDER_MODES mode = X_ORDER_MODE_MARKET;
|
||||
|
||||
//
|
||||
// Check Signalling Direction ...
|
||||
result = mSignallingDirection != X_SIGNALLING_NONE;
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Check Conditions Exists ...
|
||||
result = HasRequirements();
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
// Prepare Conditions ...
|
||||
result = PrepareRequirements();
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Implement Signalling Conditions ...
|
||||
XOHCL cBar;
|
||||
result = cBar.Init(
|
||||
mSymbol,
|
||||
mPeriod,
|
||||
1 //
|
||||
);
|
||||
|
||||
//
|
||||
// Check Analyzing Period Contains a Trend or not ...
|
||||
|
||||
//
|
||||
// Detecting Trend ...
|
||||
bool isInBullishTrend = false;
|
||||
bool isInBearishTrend = false;
|
||||
|
||||
//
|
||||
isInBullishTrend = bar.HasBullishTrend(
|
||||
highSwingBars,
|
||||
lowSwingBars //
|
||||
);
|
||||
if (!isInBullishTrend)
|
||||
{
|
||||
//
|
||||
isInBearishTrend = bar.HasBearishTrend(
|
||||
highSwingBars,
|
||||
lowSwingBars //
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// Only Looks For Signals if aTrend Detected ...
|
||||
result = isInBullishTrend || isInBearishTrend;
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Here We have to Decide Trend or Reversal Act ...
|
||||
|
||||
//
|
||||
// Check Trend Direction Signal ...
|
||||
if (mSignallingDirection == X_SIGNALLING_BOTH_DIRECTIONS ||
|
||||
mSignallingDirection == X_SIGNALLING_TREND_DIRECTION)
|
||||
{
|
||||
//
|
||||
if (isInBullishTrend)
|
||||
{
|
||||
//
|
||||
// Find Long Signals ...
|
||||
// since we are in Bullish Trend and
|
||||
// we must do Trend Trading ...
|
||||
|
||||
//
|
||||
result =
|
||||
//
|
||||
false
|
||||
//
|
||||
;
|
||||
}
|
||||
else if (isInBearishTrend)
|
||||
{
|
||||
//
|
||||
// Find Short Signals ...
|
||||
// since we are in Bearish Trend and
|
||||
// we must do Trend Trading ...
|
||||
|
||||
//
|
||||
result =
|
||||
//
|
||||
false
|
||||
//
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Check Trend Reversal Direction Signal ...
|
||||
if (!result &&
|
||||
(mSignallingDirection == X_SIGNALLING_BOTH_DIRECTIONS ||
|
||||
mSignallingDirection == X_SIGNALIING_TREND_REVERSAL_DIRECTION))
|
||||
{
|
||||
//
|
||||
if (isInBullishTrend)
|
||||
{
|
||||
//
|
||||
// Find Short Signals ...
|
||||
// since we are in Bullish Trend and
|
||||
// we must do Trend Reversal Trading ...
|
||||
|
||||
//
|
||||
result =
|
||||
//
|
||||
false
|
||||
//
|
||||
;
|
||||
}
|
||||
else if (isInBearishTrend)
|
||||
{
|
||||
//
|
||||
// Find Long Signals ...
|
||||
// since we are in Bearish Trend and
|
||||
// we must do Trend Reversal Trading ...
|
||||
|
||||
//
|
||||
result =
|
||||
//
|
||||
false
|
||||
//
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Make Sure Signal Exists ...
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
CalculateTPSLBtPrice(
|
||||
sl,
|
||||
tp,
|
||||
type,
|
||||
entry,
|
||||
r2r //
|
||||
);
|
||||
|
||||
//
|
||||
result = signal.Prepare(
|
||||
mSymbol,
|
||||
GetTag(),
|
||||
mPeriod,
|
||||
type,
|
||||
mode,
|
||||
entry,
|
||||
mVolume,
|
||||
sl,
|
||||
tp //
|
||||
);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
Reference in New Issue
Block a user