last ...
This commit is contained in:
@@ -27,6 +27,157 @@
|
||||
|
||||
//
|
||||
// Definitions ...
|
||||
enum ENUM_X_SCORE
|
||||
{
|
||||
X_SCORE_NONE = 0,
|
||||
X_SCORE_MIN = 1,
|
||||
X_SCORE_NORMAL = 2,
|
||||
X_SCORE_MAX = 3,
|
||||
};
|
||||
|
||||
//
|
||||
// State Handler Generic Functions ...
|
||||
#define DECLARE_STATE_FUNCTIONS(name, state_reader, bar_normalizer_func) \
|
||||
bool Is##name##Bullish(int barIndex = 0) \
|
||||
{ \
|
||||
barIndex = bar_normalizer_func(barIndex); \
|
||||
return state_reader(barIndex) >= 1; \
|
||||
} \
|
||||
bool Is##name##Bearish(int barIndex = 0) \
|
||||
{ \
|
||||
barIndex = bar_normalizer_func(barIndex); \
|
||||
return state_reader(barIndex) <= -1; \
|
||||
} \
|
||||
bool Is##name##SwitchedToBullish(int barIndex = 0) \
|
||||
{ \
|
||||
barIndex = bar_normalizer_func(barIndex); \
|
||||
return Is##name##Bullish(barIndex) && !Is##name##Bullish(barIndex + 1); \
|
||||
} \
|
||||
bool Is##name##SwitchedToBearish(int barIndex = 0) \
|
||||
{ \
|
||||
barIndex = bar_normalizer_func(barIndex); \
|
||||
return Is##name##Bearish(barIndex) && !Is##name##Bearish(barIndex + 1); \
|
||||
}
|
||||
|
||||
//
|
||||
// State Handler Based On Price Type Generic Functions ...
|
||||
#define DECLARE_PRICE_BASED_STATE_FUNCTIONS(name, value_reader, bar_normalizer_func, point_reader_func, price_reader_func) \
|
||||
bool Is##name##Bullish(int barIndex = 0, ENUM_X_PRICE priceType = X_PRICE_CLOSE, double tolerance = 2) \
|
||||
{ \
|
||||
barIndex = bar_normalizer_func(barIndex); \
|
||||
double threshold = point_reader_func() * tolerance; \
|
||||
return price_reader_func(barIndex, priceType) > value_reader(barIndex) + threshold || \
|
||||
price_reader_func(barIndex, priceType) > value_reader(barIndex) - threshold; \
|
||||
} \
|
||||
bool Is##name##Bearish(int barIndex = 0, ENUM_X_PRICE priceType = X_PRICE_CLOSE, double tolerance = 2) \
|
||||
{ \
|
||||
barIndex = bar_normalizer_func(barIndex); \
|
||||
double threshold = point_reader_func() * tolerance; \
|
||||
return price_reader_func(barIndex, priceType) < value_reader(barIndex) + threshold || \
|
||||
price_reader_func(barIndex, priceType) < value_reader(barIndex) - threshold; \
|
||||
} \
|
||||
bool Is##name##SwitchedToBullish(int barIndex = 0, ENUM_X_PRICE priceType = X_PRICE_CLOSE, double tolerance = 2) \
|
||||
{ \
|
||||
barIndex = bar_normalizer_func(barIndex); \
|
||||
return Is##name##Bullish(barIndex, priceType, tolerance) && !Is##name##Bullish(barIndex + 1, priceType, tolerance); \
|
||||
} \
|
||||
bool Is##name##SwitchedToBearish(int barIndex = 0, ENUM_X_PRICE priceType = X_PRICE_CLOSE, double tolerance = 2) \
|
||||
{ \
|
||||
barIndex = bar_normalizer_func(barIndex); \
|
||||
return Is##name##Bearish(barIndex, priceType, tolerance) && !Is##name##Bearish(barIndex + 1, priceType, tolerance); \
|
||||
}
|
||||
|
||||
//
|
||||
// Value Comparator Generic Functions ...
|
||||
#define DECLARE_VALUE_COMPARATOR_FUNCTIONS(name, value_reader, bar_normalizer_func, point_reader_func) \
|
||||
bool Is##name##OverLast(int barIndex = 0, double tolerance = 2) \
|
||||
{ \
|
||||
barIndex = bar_normalizer_func(barIndex); \
|
||||
return IsOver( \
|
||||
value_reader(barIndex), \
|
||||
value_reader(barIndex + 1), \
|
||||
point_reader_func() * tolerance); \
|
||||
} \
|
||||
bool Is##name##UnderLast(int barIndex = 0, double tolerance = 2) \
|
||||
{ \
|
||||
barIndex = bar_normalizer_func(barIndex); \
|
||||
return IsUnder( \
|
||||
value_reader(barIndex), \
|
||||
value_reader(barIndex + 1), \
|
||||
point_reader_func() * tolerance); \
|
||||
} \
|
||||
bool Is##name##SameAsLast(int barIndex = 0, double tolerance = 2) \
|
||||
{ \
|
||||
barIndex = bar_normalizer_func(barIndex); \
|
||||
return IsSame( \
|
||||
value_reader(barIndex), \
|
||||
value_reader(barIndex + 1), \
|
||||
point_reader_func() * tolerance); \
|
||||
} \
|
||||
bool Is##name##CrossedOverLast(int barIndex = 0, double tolerance = 2) \
|
||||
{ \
|
||||
barIndex = bar_normalizer_func(barIndex); \
|
||||
return Is##name##OverLast(barIndex, tolerance) && !Is##name##OverLast(barIndex + 1, tolerance); \
|
||||
} \
|
||||
bool Is##name##CrossedUnderLast(int barIndex = 0, double tolerance = 2) \
|
||||
{ \
|
||||
barIndex = bar_normalizer_func(barIndex); \
|
||||
return Is##name##UnderLast(barIndex, tolerance) && !Is##name##UnderLast(barIndex + 1, tolerance); \
|
||||
}
|
||||
|
||||
//
|
||||
// Price Comparator Generic Functions ...
|
||||
#define DECLARE_PRICE_COMPARATOR_FUNCTIONS(name, value_reader, bar_normalizer_func, price_reader_func) \
|
||||
bool IsPriceOver##name(int barIndex = 0, ENUM_X_PRICE priceType = X_PRICE_CLOSE) \
|
||||
{ \
|
||||
barIndex = bar_normalizer_func(barIndex); \
|
||||
return price_reader_func(barIndex, priceType) > value_reader(barIndex); \
|
||||
} \
|
||||
bool IsPriceUnder##name(int barIndex = 0, ENUM_X_PRICE priceType = X_PRICE_CLOSE) \
|
||||
{ \
|
||||
barIndex = bar_normalizer_func(barIndex); \
|
||||
return price_reader_func(barIndex, priceType) < value_reader(barIndex); \
|
||||
} \
|
||||
bool IsPriceCrossedOver##name(int barIndex = 0, ENUM_X_PRICE priceType = X_PRICE_CLOSE) \
|
||||
{ \
|
||||
barIndex = bar_normalizer_func(barIndex); \
|
||||
return IsPriceOver##name(barIndex, priceType) && !IsPriceOver##name(barIndex + 1, priceType); \
|
||||
} \
|
||||
bool IsPriceCrossedUnder##name(int barIndex = 0, ENUM_X_PRICE priceType = X_PRICE_CLOSE) \
|
||||
{ \
|
||||
barIndex = bar_normalizer_func(barIndex); \
|
||||
return IsPriceUnder##name(barIndex, priceType) && !IsPriceUnder##name(barIndex + 1, priceType); \
|
||||
}
|
||||
|
||||
//
|
||||
// Crossing Comparator Generic Functions ...
|
||||
#define DECLARE_CROSSING_COMPARATOR_FUNCTIONS(baseName, fastName, slowName, fast_reader_func, slow_reader_func, bar_normalizer_func, point_reader_func) \
|
||||
bool Is##baseName##fastName##Over##Slow(int barIndex = 0, double tolerance = 2) \
|
||||
{ \
|
||||
barIndex = bar_normalizer_func(barIndex); \
|
||||
double fast = fast_reader_func(barIndex); \
|
||||
double slow = slow_reader_func(barIndex); \
|
||||
double distance = tolerance * point_reader_func(); \
|
||||
return fast > slow && MathAbs(fast - slow) >= distance; \
|
||||
} \
|
||||
bool Is##baseName##fastName##Under##Slow(int barIndex = 0, double tolerance = 2) \
|
||||
{ \
|
||||
barIndex = bar_normalizer_func(barIndex); \
|
||||
double fast = fast_reader_func(barIndex); \
|
||||
double slow = slow_reader_func(barIndex); \
|
||||
double distance = tolerance * point_reader_func(); \
|
||||
return fast < slow && MathAbs(fast - slow) >= distance; \
|
||||
} \
|
||||
bool Is##baseName##fastName##CrossedOver##Slow(int barIndex = 0, double tolerance = 2) \
|
||||
{ \
|
||||
barIndex = bar_normalizer_func(barIndex); \
|
||||
return Is##baseName##fastName##Over##Slow(barIndex, tolerance) && !Is##baseName##fastName##Over##Slow(barIndex + 1, tolerance); \
|
||||
} \
|
||||
bool Is##baseName##fastName##CrossedUnder##Slow(int barIndex = 0, double tolerance = 2) \
|
||||
{ \
|
||||
barIndex = bar_normalizer_func(barIndex); \
|
||||
return Is##baseName##fastName##Under##Slow(barIndex, tolerance) && !Is##baseName##fastName##Under##Slow(barIndex + 1, tolerance); \
|
||||
}
|
||||
|
||||
//
|
||||
// a Class for Handle base requirements ...
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -932,6 +932,10 @@ double GetPoints(
|
||||
//
|
||||
return result;
|
||||
}
|
||||
double GetXPoints(string mSymbol = NULL)
|
||||
{
|
||||
return GetPoints(mSymbol);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts Price to Point ...
|
||||
@@ -5316,7 +5320,8 @@ bool IsOver(
|
||||
double current,
|
||||
double previous,
|
||||
double tolerance = 2 //
|
||||
) {
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result =
|
||||
NotEmptyZero(current) &&
|
||||
@@ -5331,7 +5336,8 @@ bool IsUnder(
|
||||
double current,
|
||||
double previous,
|
||||
double tolerance = 2 //
|
||||
) {
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result =
|
||||
NotEmptyZero(current) &&
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -973,8 +973,7 @@ class XCX121XKIStrategy1Signaller : public XCX121XKIBaseSignaller
|
||||
}
|
||||
|
||||
//
|
||||
int scoreBullish = 0;
|
||||
int scoreBearish = 0;
|
||||
double score = 0;
|
||||
bool isBullish = false;
|
||||
bool isBearish = false;
|
||||
int barIndex = bar.Index() + 1;
|
||||
@@ -982,6 +981,31 @@ class XCX121XKIStrategy1Signaller : public XCX121XKIBaseSignaller
|
||||
//
|
||||
// TEST ...
|
||||
|
||||
//
|
||||
if (kiParser.IsKIFastBullish(barIndex))
|
||||
{
|
||||
DebugBreak();
|
||||
}
|
||||
|
||||
// //
|
||||
// bool hasTrend =
|
||||
// kiParser.HasCompositeTrend(
|
||||
// score,
|
||||
// dir,
|
||||
// barIndex,
|
||||
// 20, // Required Score ...
|
||||
// 2, // Tolerance ...
|
||||
// X_PRICE_CLOSE,
|
||||
// 55,
|
||||
// 45,
|
||||
// 70,
|
||||
// 30 //
|
||||
// );
|
||||
// if (hasTrend && IsXBearish(dir))
|
||||
// {
|
||||
// DebugBreak();
|
||||
// }
|
||||
|
||||
//
|
||||
return false;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user