remove fibo lines from x121 indicator and also add support for rsi in data buffers ...

This commit is contained in:
2025-01-03 21:46:49 +03:30
parent a9ab5a6258
commit 6e03d6d993
8 changed files with 7722 additions and 948 deletions
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+3 -1
View File
@@ -46,11 +46,12 @@ input string eaSymbols = "EURUSDb,GBPUSDb,USDJPYb,USDCHFb"; // Trading Symbols
input group "Signalling";
input bool eaAllowLong = true; // Allow Long Signals
input bool eaAllowShort = true; // Allow Short Signals
input bool eaAllowTrade = true; // Allow Open Trade On Signals
input int eaMaxAllowedLongs = 5; // Max Allowed Long Signals
input int eaMaxAllowedShorts = 5; // Max Allowed Short Signals
input bool eaUseMaxAllowedSignalsPerSymbol = true; // Use Max Allowed Signal Types Per Symbol
input double eaLastPositionProfitForAcceptNextInPoint = 30; // Last Position Profit In Points for Accept new Signal
input int eaDelaysBetweenTwoSignalsInBar = 100; // Delay between two Signals in Bars
input int eaDelaysBetweenTwoSignalsInBar = 100; // Delay between two Signals in Bars
input double eaMaxAllowedSpread = 25; // Max Allowed Spread for Signalling
input int eaMinRequiredVerificationForSpreadPass = 20; // Minimum Spread Verification for Signalling
@@ -152,6 +153,7 @@ int OnInit()
// Signalling ...
eaExpert.AllowLong(eaAllowLong);
eaExpert.AllowShort(eaAllowShort);
eaExpert.AllowTrade(eaAllowTrade);
eaExpert.MaxAllowedLongs(eaMaxAllowedLongs);
eaExpert.MaxAllowedShorts(eaMaxAllowedShorts);
eaExpert.UseMaxAllowedSignalsPerSymbol(eaUseMaxAllowedSignalsPerSymbol);
+53 -644
View File
@@ -46,37 +46,35 @@ enum ENUM_X121_BUFFERS
X121_DON_LOW_LOWER_LINE = 16,
X121_DON_CLOSE_UPPER_LINE = 17,
X121_DON_CLOSE_LOWER_LINE = 18,
X121_FIB_LEVEL_1_LINE = 19,
X121_FIB_LEVEL_2_LINE = 20,
X121_FIB_LEVEL_3_LINE = 21,
X121_FIB_LEVEL_4_LINE = 22,
X121_FIB_LEVEL_5_LINE = 23,
//
// Data Buffers ...
//
// XPV Data ...
X121_CURRENT_HH_LINE = 24,
X121_CURRENT_LL_LINE = 25,
X121_SHORT_HH_LINE = 26,
X121_SHORT_LL_LINE = 27,
X121_MEDIUM_HH_LINE = 28,
X121_MEDIUM_LL_LINE = 29,
X121_LONG_HH_LINE = 30,
X121_LONG_LL_LINE = 31,
X121_HIND_HH_LINE = 32,
X121_HIND_LL_LINE = 33,
X121_CURRENT_HH_LINE = 19,
X121_CURRENT_LL_LINE = 20,
X121_SHORT_HH_LINE = 21,
X121_SHORT_LL_LINE = 22,
X121_MEDIUM_HH_LINE = 23,
X121_MEDIUM_LL_LINE = 24,
X121_LONG_HH_LINE = 25,
X121_LONG_LL_LINE = 26,
X121_HIND_HH_LINE = 27,
X121_HIND_LL_LINE = 28,
//
// VWAP Data ...
X121_VWAP_VOLUME_LINE = 34,
X121_VWAP_PRICE_LINE = 35,
X121_VWAP_FAST_STATE_LINE = 36,
X121_VWAP_MID_STATE_LINE = 37,
X121_VWAP_SLOW_STATE_LINE = 38,
X121_VWAP_VOLUME_LINE = 29,
X121_VWAP_PRICE_LINE = 30,
X121_VWAP_FAST_STATE_LINE = 31,
X121_VWAP_MID_STATE_LINE = 32,
X121_VWAP_SLOW_STATE_LINE = 33,
//
// ATR ...
X121_ATR_LINE = 39,
X121_ATR_UPPER_RAW_LINE = 40,
X121_ATR_LOWER_RAW_LINE = 41,
X121_ATR_LINE = 34,
X121_ATR_UPPER_RAW_LINE = 35,
X121_ATR_LOWER_RAW_LINE = 36,
//
// RSI ...
X121_RSI_LINE = 37
};
//
@@ -130,9 +128,10 @@ struct X121Inputs
//
// RSI ...
int rsiLength; // RSI Length
double rsiOverSoldLevel; // RSI Over Sold Level
double rsiOverBoughtLevel; // RSI Over Bought Level
int rsiLength; // Length
double rsiOverSoldLevel; // Over Sold Level
double rsiOverBoughtLevel; // Over Bought Level
ENUM_APPLIED_PRICE rsiAppliedTo; // Applied To
//
// Atr Detection ...
@@ -153,14 +152,6 @@ struct X121Inputs
// Donchain Detection ...
int donchainLength; // Donchain Length
//
// Fibonacci ...
double fiboLevel1; // Fibio 1st Level
double fiboLevel2; // Fibio 2st Level
double fiboLevel3; // Fibio 3rd Level
double fiboLevel4; // Fibio 4th Level
double fiboLevel5; // Fibio 5th Level
//
// Presentation ...
@@ -181,14 +172,6 @@ struct X121Inputs
bool showVWap; // Show VWap
bool showDonchain; // Show Donchain
//
// Fibonachi Presentation ...
bool showFibo1Levels; // Show Fibo 1st Level
bool showFibo2Levels; // Show Fibo 2nd Level
bool showFibo3Levels; // Show Fibo 3rd Level
bool showFibo4Levels; // Show Fibo 4th Level
bool showFibo5Levels; // Show Fibo 5th Level
//
// Atr Presentation ...
bool showAtrUpper; // Show Upper Zone
@@ -261,6 +244,7 @@ struct X121Inputs
rsiLength = 0;
rsiOverSoldLevel = 0;
rsiOverBoughtLevel = 0;
rsiAppliedTo = PRICE_CLOSE;
//
// Paraboli Sar Detection ...
@@ -286,14 +270,6 @@ struct X121Inputs
// Donchain Detection ...
donchainLength = 0;
//
// Fibonacci ...
fiboLevel1 = 0;
fiboLevel2 = 0;
fiboLevel3 = 0;
fiboLevel4 = 0;
fiboLevel5 = 0;
//
// Presentation ...
@@ -314,14 +290,6 @@ struct X121Inputs
showVWap = false;
showDonchain = false;
//
// Fibonachi Presentation ...
showFibo1Levels = false;
showFibo2Levels = false;
showFibo3Levels = false;
showFibo4Levels = false;
showFibo5Levels = false;
//
// Atr Presentation ...
showAtrUpper = false; // Show Upper Zone
@@ -385,6 +353,7 @@ struct X121Inputs
rsiLength = 14;
rsiOverSoldLevel = 30;
rsiOverBoughtLevel = 70;
rsiAppliedTo = PRICE_CLOSE;
//
// Paraboli Sar Detection ...
@@ -410,14 +379,6 @@ struct X121Inputs
// Donchain Detection ...
donchainLength = 40;
//
// Fibonacci ...
fiboLevel1 = 0.236;
fiboLevel2 = 0.382;
fiboLevel3 = 0.5;
fiboLevel4 = 0.618;
fiboLevel5 = 0.764;
//
// Presentation ...
@@ -438,14 +399,6 @@ struct X121Inputs
showVWap = true;
showDonchain = true;
//
// Fibonachi Presentation ...
showFibo1Levels = false;
showFibo2Levels = false;
showFibo3Levels = true;
showFibo4Levels = false;
showFibo5Levels = false;
//
// Atr Presentation ...
showAtrUpper = true; // Show Upper Zone
@@ -572,11 +525,6 @@ struct X121Conditions
double donHighLowerBuffer[];
double donLowUpperBuffer[];
double donLowLowerBuffer[];
double fl1Buffer[];
double fl2Buffer[];
double fl3Buffer[];
double fl4Buffer[];
double fl5Buffer[];
double cHHBuffer[];
double cLLBuffer[];
double sHHBuffer[];
@@ -687,37 +635,6 @@ struct X121Conditions
//
// bool isCloseLower
//
// XFIBONACCI ...
//
bool isOerFib1;
bool isOerFib2;
bool isOerFib3;
bool isOerFib4;
bool isOerFib5;
//
bool isUnderFib1;
bool isUnderFib2;
bool isUnderFib3;
bool isUnderFib4;
bool isUnderFib5;
//
bool isCloseOerFib1;
bool isCloseOerFib2;
bool isCloseOerFib3;
bool isCloseOerFib4;
bool isCloseOerFib5;
//
bool isCloseUnderFib1;
bool isCloseUnderFib2;
bool isCloseUnderFib3;
bool isCloseUnderFib4;
bool isCloseUnderFib5;
//
// Constructor ...
X121Conditions()
@@ -759,11 +676,6 @@ struct X121Conditions
Clean(donHighLowerBuffer);
Clean(donLowUpperBuffer);
Clean(donLowLowerBuffer);
Clean(fl1Buffer);
Clean(fl2Buffer);
Clean(fl3Buffer);
Clean(fl4Buffer);
Clean(fl5Buffer);
Clean(cHHBuffer);
Clean(cLLBuffer);
Clean(sHHBuffer);
@@ -801,11 +713,6 @@ struct X121Conditions
ArraySetAsSeries(donHighLowerBuffer, true);
ArraySetAsSeries(donLowUpperBuffer, true);
ArraySetAsSeries(donLowLowerBuffer, true);
ArraySetAsSeries(fl1Buffer, true);
ArraySetAsSeries(fl2Buffer, true);
ArraySetAsSeries(fl3Buffer, true);
ArraySetAsSeries(fl4Buffer, true);
ArraySetAsSeries(fl5Buffer, true);
ArraySetAsSeries(cHHBuffer, true);
ArraySetAsSeries(cLLBuffer, true);
ArraySetAsSeries(sHHBuffer, true);
@@ -912,37 +819,6 @@ struct X121Conditions
//
// XDON ...
//
// XFIBONACCI ...
//
isOerFib1 = false;
isOerFib2 = false;
isOerFib3 = false;
isOerFib4 = false;
isOerFib5 = false;
//
isUnderFib1 = false;
isUnderFib2 = false;
isUnderFib3 = false;
isUnderFib4 = false;
isUnderFib5 = false;
//
isCloseOerFib1 = false;
isCloseOerFib2 = false;
isCloseOerFib3 = false;
isCloseOerFib4 = false;
isCloseOerFib5 = false;
//
isCloseUnderFib1 = false;
isCloseUnderFib2 = false;
isCloseUnderFib3 = false;
isCloseUnderFib4 = false;
isCloseUnderFib5 = false;
}
/**
@@ -1030,6 +906,14 @@ struct X121Conditions
ToString("isNewValeOverLast", isNewValeOverLast, ignoreFalseConditions, separator) +
ToString("isNewValeUnderLast", isNewValeUnderLast, ignoreFalseConditions, separator) +
//
// RSI ...
ToString("isRSIOverBought", isRSIOverBought, ignoreFalseConditions, separator) +
ToString("isRSICrossedOverOverBought", isRSICrossedOverOverBought, ignoreFalseConditions, separator) +
ToString("isRSICrossedUnderOverBought", isRSICrossedUnderOverBought, ignoreFalseConditions, separator) +
ToString("isRSIOverSold", isRSIOverSold, ignoreFalseConditions, separator) +
ToString("isRSICrossedUnderOverSold", isRSICrossedUnderOverSold, ignoreFalseConditions, separator) +
ToString("isRSICrossedOverOverSold", isRSICrossedOverOverSold, ignoreFalseConditions, separator) +
//
// XVWAP ...
ToString("isVWapFastBullish", isVWapFastBullish, ignoreFalseConditions, separator) +
ToString("isVWapFastBearish", isVWapFastBearish, ignoreFalseConditions, separator) +
@@ -1055,28 +939,6 @@ struct X121Conditions
ToString("isVWapSwitchedToBearishState", isVWapSwitchedToBearishState, ignoreFalseConditions, separator) +
ToString("isVWapSwitchedToNeuturalState", isVWapSwitchedToNeuturalState, ignoreFalseConditions, separator) +
//
// XFIBONACCI ...
ToString("isOerFib1", isOerFib1, ignoreFalseConditions, separator) +
ToString("isOerFib2", isOerFib2, ignoreFalseConditions, separator) +
ToString("isOerFib3", isOerFib3, ignoreFalseConditions, separator) +
ToString("isOerFib4", isOerFib4, ignoreFalseConditions, separator) +
ToString("isOerFib5", isOerFib5, ignoreFalseConditions, separator) +
ToString("isUnderFib1", isUnderFib1, ignoreFalseConditions, separator) +
ToString("isUnderFib2", isUnderFib2, ignoreFalseConditions, separator) +
ToString("isUnderFib3", isUnderFib3, ignoreFalseConditions, separator) +
ToString("isUnderFib4", isUnderFib4, ignoreFalseConditions, separator) +
ToString("isUnderFib5", isUnderFib5, ignoreFalseConditions, separator) +
ToString("isCloseOerFib1", isCloseOerFib1, ignoreFalseConditions, separator) +
ToString("isCloseOerFib2", isCloseOerFib2, ignoreFalseConditions, separator) +
ToString("isCloseOerFib3", isCloseOerFib3, ignoreFalseConditions, separator) +
ToString("isCloseOerFib4", isCloseOerFib4, ignoreFalseConditions, separator) +
ToString("isCloseOerFib5", isCloseOerFib5, ignoreFalseConditions, separator) +
ToString("isCloseUnderFib1", isCloseUnderFib1, ignoreFalseConditions, separator) +
ToString("isCloseUnderFib2", isCloseUnderFib2, ignoreFalseConditions, separator) +
ToString("isCloseUnderFib3", isCloseUnderFib3, ignoreFalseConditions, separator) +
ToString("isCloseUnderFib4", isCloseUnderFib4, ignoreFalseConditions, separator) +
ToString("isCloseUnderFib5", isCloseUnderFib5, ignoreFalseConditions, separator) +
//
""
//
;
@@ -1136,7 +998,6 @@ class XCX121Helper : public XCBaseHelper
// Deconstructor ...
~XCX121Helper()
{
IndicatorRelease(mRSIHandler);
}
//
@@ -1193,11 +1054,6 @@ class XCX121Helper : public XCBaseHelper
ArraySetAsSeries(donHighLowerBuffer, true);
ArraySetAsSeries(donLowUpperBuffer, true);
ArraySetAsSeries(donLowLowerBuffer, true);
ArraySetAsSeries(fl1Buffer, true);
ArraySetAsSeries(fl2Buffer, true);
ArraySetAsSeries(fl3Buffer, true);
ArraySetAsSeries(fl4Buffer, true);
ArraySetAsSeries(fl5Buffer, true);
ArraySetAsSeries(cHHBuffer, true);
ArraySetAsSeries(cLLBuffer, true);
ArraySetAsSeries(sHHBuffer, true);
@@ -1254,6 +1110,11 @@ class XCX121Helper : public XCBaseHelper
mInputs.hhMode,
mInputs.llMode,
//
// Rsi Detection ...
"",
mInputs.rsiLength,
mInputs.rsiAppliedTo,
//
// Parabolic Sar Detection ...
"",
mInputs.sarStep,
@@ -1281,6 +1142,9 @@ class XCX121Helper : public XCBaseHelper
// Presentation ...
"",
mInputs.startCalculationForLastBars,
mInputs.sarArrowCode,
mInputs.peaksArrowCode,
mInputs.valesArrowCode,
//
// Commons ...
mInputs.showSar,
@@ -1290,14 +1154,6 @@ class XCX121Helper : public XCBaseHelper
mInputs.showVWap,
mInputs.showDonchain,
//
// Fibonachi Presentation ...
"",
mInputs.showFibo1Levels,
mInputs.showFibo2Levels,
mInputs.showFibo3Levels,
mInputs.showFibo4Levels,
mInputs.showFibo5Levels,
//
// Atr Presentation ...
"",
mInputs.showAtrUpper,
@@ -1318,20 +1174,6 @@ class XCX121Helper : public XCBaseHelper
mInputs.showClose,
mInputs.showLow
//
// Non Important Inpust ...
//
// Fibonacci ...
// "",
// mInputs.fiboLevel1,
// mInputs.fiboLevel2,
// mInputs.fiboLevel3,
// mInputs.fiboLevel4,
// mInputs.fiboLevel5,
// //
// mInputs.sarArrowCode,
// mInputs.peaksArrowCode,
// mInputs.valesArrowCode
//
);
result = mHandler != INVALID_HANDLE;
if (!result)
@@ -1339,19 +1181,6 @@ class XCX121Helper : public XCBaseHelper
return result;
}
//
mRSIHandler = iRSI(
symbol,
period,
mInputs.rsiLength,
PRICE_CLOSE //
);
result = mRSIHandler != INVALID_HANDLE;
if (!result)
{
return result;
}
//
return result;
}
@@ -1857,8 +1686,8 @@ class XCX121Helper : public XCBaseHelper
//
double GetHigherPeak(
double peak, // Peak Source
int barIndex = 0, // Bar Index
double peak, // Peak Source
int barIndex = 0, // Bar Index
int loopback = 576 // Max Allowed Loopback
)
{
@@ -1909,8 +1738,8 @@ class XCX121Helper : public XCBaseHelper
//
double GetLowerPeak(
double peak, // Peak Source
int barIndex = 0, // Bar Index
double peak, // Peak Source
int barIndex = 0, // Bar Index
int loopback = 576 // Max Allowed Loopback
)
{
@@ -1961,8 +1790,8 @@ class XCX121Helper : public XCBaseHelper
//
double GetHigherVale(
double vale, // Vale Source
int barIndex = 0, // Bar Index
double vale, // Vale Source
int barIndex = 0, // Bar Index
int loopback = 576 // Max Allowed Loopback
)
{
@@ -2013,8 +1842,8 @@ class XCX121Helper : public XCBaseHelper
//
double GetLowerVale(
double vale, // Vale Source
int barIndex = 0, // Bar Index
double vale, // Vale Source
int barIndex = 0, // Bar Index
int loopback = 576 // Max Allowed Loopback
)
{
@@ -3727,269 +3556,6 @@ class XCX121Helper : public XCBaseHelper
);
}
//
// FIBONACCHI ...
//
// LEVEL 1 ...
//
double GetFiboLevel1(
int barIndex // Bar Index
)
{
//
if (barIndex < 0)
{
barIndex = 0;
}
//
Calculate();
//
int count = ArraySize(fl1Buffer);
if (barIndex >= count)
{
barIndex = count - 1;
}
//
return fl1Buffer[barIndex];
}
//
int CopyFiboLevel1(
int start, // Start
int count, // Number of Items for read
double &buffer[], // Dest Buffer
bool forceClean = true // FiboLevel To Clean buffer
)
{
//
// Update Calculations ...
Calculate();
//
// Copy Items ...
return Copy(
start,
count,
fl1Buffer,
buffer,
forceClean
//
);
}
//
// LEVEL 2 ...
//
double GetFiboLevel2(
int barIndex // Bar Index
)
{
//
if (barIndex < 0)
{
barIndex = 0;
}
//
Calculate();
//
int count = ArraySize(fl2Buffer);
if (barIndex >= count)
{
barIndex = count - 1;
}
//
return fl2Buffer[barIndex];
}
//
int CopyFiboLevel2(
int start, // Start
int count, // Number of Items for read
double &buffer[], // Dest Buffer
bool forceClean = true // FiboLevel To Clean buffer
)
{
//
// Update Calculations ...
Calculate();
//
// Copy Items ...
return Copy(
start,
count,
fl2Buffer,
buffer,
forceClean
//
);
}
//
// LEVEL 3 ...
//
double GetFiboLevel3(
int barIndex // Bar Index
)
{
//
if (barIndex < 0)
{
barIndex = 0;
}
//
Calculate();
//
int count = ArraySize(fl3Buffer);
if (barIndex >= count)
{
barIndex = count - 1;
}
//
return fl3Buffer[barIndex];
}
//
int CopyFiboLevel3(
int start, // Start
int count, // Number of Items for read
double &buffer[], // Dest Buffer
bool forceClean = true // FiboLevel To Clean buffer
)
{
//
// Update Calculations ...
Calculate();
//
// Copy Items ...
return Copy(
start,
count,
fl3Buffer,
buffer,
forceClean
//
);
}
//
// LEVEL 4 ...
//
double GetFiboLevel4(
int barIndex // Bar Index
)
{
//
if (barIndex < 0)
{
barIndex = 0;
}
//
Calculate();
//
int count = ArraySize(fl4Buffer);
if (barIndex >= count)
{
barIndex = count - 1;
}
//
return fl4Buffer[barIndex];
}
//
int CopyFiboLevel4(
int start, // Start
int count, // Number of Items for read
double &buffer[], // Dest Buffer
bool forceClean = true // FiboLevel To Clean buffer
)
{
//
// Update Calculations ...
Calculate();
//
// Copy Items ...
return Copy(
start,
count,
fl4Buffer,
buffer,
forceClean
//
);
}
//
// LEVEL 5 ...
//
double GetFiboLevel5(
int barIndex // Bar Index
)
{
//
if (barIndex < 0)
{
barIndex = 0;
}
//
Calculate();
//
int count = ArraySize(fl5Buffer);
if (barIndex >= count)
{
barIndex = count - 1;
}
//
return fl5Buffer[barIndex];
}
//
int CopyFiboLevel5(
int start, // Start
int count, // Number of Items for read
double &buffer[], // Dest Buffer
bool forceClean = true // FiboLevel To Clean buffer
)
{
//
// Update Calculations ...
Calculate();
//
// Copy Items ...
return Copy(
start,
count,
fl5Buffer,
buffer,
forceClean
//
);
}
//
// Conditions Generation ...
@@ -4306,41 +3872,6 @@ class XCX121Helper : public XCBaseHelper
conditions.donLowLowerBuffer //
);
//
CopyFiboLevel1(
zIndex,
loopback,
conditions.fl1Buffer //
);
//
CopyFiboLevel2(
zIndex,
loopback,
conditions.fl2Buffer //
);
//
CopyFiboLevel3(
zIndex,
loopback,
conditions.fl3Buffer //
);
//
CopyFiboLevel4(
zIndex,
loopback,
conditions.fl4Buffer //
);
//
CopyFiboLevel5(
zIndex,
loopback,
conditions.fl5Buffer //
);
//
// Conditions ...
@@ -4513,39 +4044,6 @@ class XCX121Helper : public XCBaseHelper
//
// XDON ...
//
// XFIBONACCI ...
//
bool isOerFib1 = cBar.low > conditions.fl1Buffer[cIDX];
bool isOerFib2 = cBar.low > conditions.fl2Buffer[cIDX];
bool isOerFib3 = cBar.low > conditions.fl3Buffer[cIDX];
bool isOerFib4 = cBar.low > conditions.fl4Buffer[cIDX];
bool isOerFib5 = cBar.low > conditions.fl5Buffer[cIDX];
//
bool isUnderFib1 = cBar.high < conditions.fl1Buffer[cIDX];
bool isUnderFib2 = cBar.high < conditions.fl2Buffer[cIDX];
bool isUnderFib3 = cBar.high < conditions.fl3Buffer[cIDX];
bool isUnderFib4 = cBar.high < conditions.fl4Buffer[cIDX];
bool isUnderFib5 = cBar.high < conditions.fl5Buffer[cIDX];
//
bool isCloseOerFib1 = cBar.close > conditions.fl1Buffer[cIDX];
bool isCloseOerFib2 = cBar.close > conditions.fl2Buffer[cIDX];
bool isCloseOerFib3 = cBar.close > conditions.fl3Buffer[cIDX];
bool isCloseOerFib4 = cBar.close > conditions.fl4Buffer[cIDX];
bool isCloseOerFib5 = cBar.close > conditions.fl5Buffer[cIDX];
//
bool isCloseUnderFib1 = cBar.close < conditions.fl1Buffer[cIDX];
bool isCloseUnderFib2 = cBar.close < conditions.fl2Buffer[cIDX];
bool isCloseUnderFib3 = cBar.close < conditions.fl3Buffer[cIDX];
bool isCloseUnderFib4 = cBar.close < conditions.fl4Buffer[cIDX];
bool isCloseUnderFib5 = cBar.close < conditions.fl5Buffer[cIDX];
//
//
// Set ...
conditions.isRSIOverBought = isRSIOverBought;
@@ -4587,26 +4085,6 @@ class XCX121Helper : public XCBaseHelper
conditions.isVWapSwitchedToBullishState = isVWapSwitchedToBullishState;
conditions.isVWapSwitchedToBearishState = isVWapSwitchedToBearishState;
conditions.isVWapSwitchedToNeuturalState = isVWapSwitchedToNeuturalState;
conditions.isOerFib1 = isOerFib1;
conditions.isOerFib2 = isOerFib2;
conditions.isOerFib3 = isOerFib3;
conditions.isOerFib4 = isOerFib4;
conditions.isOerFib5 = isOerFib5;
conditions.isUnderFib1 = isUnderFib1;
conditions.isUnderFib2 = isUnderFib2;
conditions.isUnderFib3 = isUnderFib3;
conditions.isUnderFib4 = isUnderFib4;
conditions.isUnderFib5 = isUnderFib5;
conditions.isCloseOerFib1 = isCloseOerFib1;
conditions.isCloseOerFib2 = isCloseOerFib2;
conditions.isCloseOerFib3 = isCloseOerFib3;
conditions.isCloseOerFib4 = isCloseOerFib4;
conditions.isCloseOerFib5 = isCloseOerFib5;
conditions.isCloseUnderFib1 = isCloseUnderFib1;
conditions.isCloseUnderFib2 = isCloseUnderFib2;
conditions.isCloseUnderFib3 = isCloseUnderFib3;
conditions.isCloseUnderFib4 = isCloseUnderFib4;
conditions.isCloseUnderFib5 = isCloseUnderFib5;
//
return result;
@@ -4622,12 +4100,6 @@ class XCX121Helper : public XCBaseHelper
// Props ...
X121Inputs mInputs; // Inputs ...
//
// Buffers ...
//
int mRSIHandler; // RSI Handler ...
//
// Buffers ...
double peaksBuffer[];
@@ -4646,11 +4118,6 @@ class XCX121Helper : public XCBaseHelper
double donHighLowerBuffer[];
double donLowUpperBuffer[];
double donLowLowerBuffer[];
double fl1Buffer[];
double fl2Buffer[];
double fl3Buffer[];
double fl4Buffer[];
double fl5Buffer[];
double cHHBuffer[];
double cLLBuffer[];
double sHHBuffer[];
@@ -4692,8 +4159,8 @@ class XCX121Helper : public XCBaseHelper
//
// RSI ...
CopyBuffer(
mRSIHandler,
0,
mHandler,
X121_RSI_LINE,
0,
totalBars,
rsiBuffer
@@ -5005,64 +4472,6 @@ class XCX121Helper : public XCBaseHelper
//
);
//
// FIBONACCI ...
//
// LEVEL 1 ...
CopyBuffer(
mHandler,
X121_FIB_LEVEL_1_LINE,
0,
totalBars,
fl1Buffer
//
);
//
// LEVEL 2 ...
CopyBuffer(
mHandler,
X121_FIB_LEVEL_2_LINE,
0,
totalBars,
fl2Buffer
//
);
//
// LEVEL 3 ...
CopyBuffer(
mHandler,
X121_FIB_LEVEL_3_LINE,
0,
totalBars,
fl3Buffer
//
);
//
// LEVEL 4 ...
CopyBuffer(
mHandler,
X121_FIB_LEVEL_4_LINE,
0,
totalBars,
fl4Buffer
//
);
//
// LEVEL 5 ...
CopyBuffer(
mHandler,
X121_FIB_LEVEL_5_LINE,
0,
totalBars,
fl5Buffer
//
);
//
// XDON ...
+74 -278
View File
@@ -62,6 +62,11 @@ input group "Boundary Detection";
input ENUM_SERIESMODE hhMode = MODE_HIGH; // Highest High Calculation Method
input ENUM_SERIESMODE llMode = MODE_LOW; // Lowest Low Calculation Method
//
input group "Rsi Detection";
input int rsiLength = 14; // Length
input ENUM_APPLIED_PRICE rsiAppliedTo = PRICE_CLOSE; // Applied To
//
input group "Parabolic Sar Detection";
input double sarStep = 0.02; // Step
@@ -92,6 +97,11 @@ input group "Presentation";
//
input int startCalculationForLastBars = 1000; // Calculate Last n Bars
//
input int sarArrowCode = 159; // Parabolic Sar Arrow Code
input int peaksArrowCode = 159; // Peaks Arrow Code
input int valesArrowCode = 159; // Vales Arrow Code
//
input bool showSar = true; // Show Parabolic Sar
input bool showAtr = true; // Show Atr
@@ -100,14 +110,6 @@ input bool showVales = true; // Show Vales
input bool showVWap = true; // Show VWap
input bool showDonchain = true; // Show Donchain
//
input group "Fibonachi Presentation";
input bool showFibo1Levels = false; // Show Fibo 1st Level
input bool showFibo2Levels = false; // Show Fibo 2nd Level
input bool showFibo3Levels = false; // Show Fibo 3rd Level
input bool showFibo4Levels = false; // Show Fibo 4th Level
input bool showFibo5Levels = false; // Show Fibo 5th Level
//
input group "Atr Presentation";
input bool showAtrUpper = true; // Show Upper Zone
@@ -128,22 +130,6 @@ input bool showHigh = false; // Show High
input bool showClose = true; // Show Close
input bool showLow = false; // Show Low
//
// Non Important Inputs ...
//
input group "Fibonacci";
input double fiboLevel1 = 0.236; // Fibio 1st Level
input double fiboLevel2 = 0.382; // Fibio 2st Level
input double fiboLevel3 = 0.5; // Fibio 3rd Level
input double fiboLevel4 = 0.618; // Fibio 4th Level
input double fiboLevel5 = 0.764; // Fibio 5th Level
//
input int sarArrowCode = 159; // Parabolic Sar Arrow Code
input int peaksArrowCode = 159; // Peaks Arrow Code
input int valesArrowCode = 159; // Vales Arrow Code
//
// Buffers ...
@@ -157,8 +143,8 @@ input int valesArrowCode = 159; // Vales Arrow Code
#property indicator_chart_window
//
#property indicator_buffers 42
#property indicator_plots 21
#property indicator_buffers 38
#property indicator_plots 16
//
// PEAKS ...
@@ -382,89 +368,11 @@ double donCloseLowerBuffer[];
#property indicator_color16 clrCoral
#property indicator_width16 1
//
// FIBONACCI ...
//
// FIBBO Level 1 ...
//
#define fl1BufferIndex 19
double fl1Buffer[];
//
#define fl1PlotBufferIndex 16
#property indicator_label17 "X121 FL1"
#property indicator_type17 DRAW_LINE
#property indicator_color17 clrGold
#property indicator_style17 STYLE_DASHDOTDOT
#property indicator_width17 1
//
// FIBBO Level 2 ...
//
#define fl2BufferIndex 20
double fl2Buffer[];
//
#define fl2PlotBufferIndex 17
#property indicator_label18 "X121 FL2"
#property indicator_type18 DRAW_LINE
#property indicator_color18 clrGold
#property indicator_style18 STYLE_DASHDOTDOT
#property indicator_width18 1
//
// FIBBO Level 3 ...
//
#define fl3BufferIndex 21
double fl3Buffer[];
//
#define fl3PlotBufferIndex 18
#property indicator_label19 "X121 FL3"
#property indicator_type19 DRAW_LINE
#property indicator_color19 clrGold
#property indicator_style19 STYLE_DASHDOTDOT
#property indicator_width19 1
//
// FIBBO Level 4 ...
//
#define fl4BufferIndex 22
double fl4Buffer[];
//
#define fl4PlotBufferIndex 19
#property indicator_label20 "X121 FL4"
#property indicator_type20 DRAW_LINE
#property indicator_color20 clrGold
#property indicator_style20 STYLE_DASHDOTDOT
#property indicator_width20 1
//
// FIBBO Level 5 ...
//
#define fl5BufferIndex 23
double fl5Buffer[];
//
#define fl5PlotBufferIndex 20
#property indicator_label21 "X121 FL5"
#property indicator_type21 DRAW_LINE
#property indicator_color21 clrGold
#property indicator_style21 STYLE_DASHDOTDOT
#property indicator_width21 1
//
// Data Buffers ...
//
int mLastBufferIndex = 23;
int mLastBufferIndex = 18;
//
// CURRENT ...
@@ -522,7 +430,7 @@ double hHHBuffer[];
double hLLBuffer[];
//
// VOLUME ...
// VWAP ...
#define vwapVolumeBufferIndex mLastBufferIndex + 11
double vwapVolumeBuffer[];
@@ -558,6 +466,11 @@ double atrUpperRawBuffer[];
#define atrLowerRawBufferIndex mLastBufferIndex + 18
double atrLowerRawBuffer[];
//
// RSI ...
#define rsiBufferIndex mLastBufferIndex + 19
double rsiBuffer[];
//
// Variables, Properties and etc ...
@@ -568,6 +481,10 @@ int limit;
//
int maxLength;
//
// RSI Handler ...
int rsiHandler = INVALID_HANDLE;
//
// SAR Handler ...
int sarHandler = INVALID_HANDLE;
@@ -619,6 +536,20 @@ int OnInit()
//
// Initialize Indicator Handlers ...
//
// RSI ...
rsiHandler = iRSI(
_Symbol,
_Period,
rsiLength,
rsiAppliedTo //
);
bool isInited = rsiHandler != INVALID_HANDLE;
if (!isInited)
{
return INIT_FAILED;
}
//
// SAR ...
sarHandler = iSAR(
@@ -627,7 +558,7 @@ int OnInit()
sarStep,
sarMax //
);
bool isInited = sarHandler != INVALID_HANDLE;
isInited = sarHandler != INVALID_HANDLE;
if (!isInited)
{
return INIT_FAILED;
@@ -692,6 +623,7 @@ void OnDeinit(const int reason)
// REASON_CLOSE 9 Terminal closed
//
IndicatorRelease(rsiHandler);
IndicatorRelease(sarHandler);
IndicatorRelease(atrHandler);
}
@@ -749,6 +681,10 @@ int OnCalculate(
//
// Validate Calculated Bars ...
//
// RSI ...
int rsiCalculatedBars = BarsCalculated(rsiHandler);
//
// SAR ...
int sarCalculatedBars = BarsCalculated(sarHandler);
@@ -759,11 +695,14 @@ int OnCalculate(
//
bool isPassedRequiredCalculatedBars =
//
// RSI ...
rsiCalculatedBars >= maxLength &&
//
// SAR ...
sarCalculatedBars >= maxLength &&
//
// ATR...
// ATR ...
sarCalculatedBars >= maxLength
//
;
@@ -778,6 +717,10 @@ int OnCalculate(
//
// Buffers Copy ...
//
// RSI ...
int copiedRsis = CopyBuffer(rsiHandler, 0, 0, limit, rsiBuffer);
//
// SAR ...
int copiedSars = CopyBuffer(sarHandler, 0, 0, limit, sarBuffer);
@@ -791,8 +734,13 @@ int OnCalculate(
bool isPassedRequiredCopiedItems =
//
//
// RSI ...
copiedRsis > 0 &&
//
// SAR ...
copiedSars > 0 &&
//
// ATR ...
copiedAtrs > 0
//
;
@@ -835,6 +783,9 @@ bool ValidateInputs()
{
//
bool result =
//
// RSI ...
rsiLength > 0 &&
//
// PSAR ...
sarMax > 0 &&
@@ -891,6 +842,10 @@ int ExtractMaxLengthOfInputs()
// ATR ...
result = MathMax(result, atrLength);
//
// RSI ...
result = MathMax(result, rsiLength);
//
return result;
}
@@ -1096,59 +1051,6 @@ void DefineBuffers()
PlotIndexSetInteger(donLowLowerPlotBufferIndex, PLOT_SHOW_DATA, canShowCLowLower);
PlotIndexSetInteger(donLowLowerPlotBufferIndex, PLOT_DRAW_TYPE, donLowLowerDrawType);
//
// FIBONNACI ...
//
// LEVEL 1 ...
bool canShowFl1 = showFibo1Levels;
ENUM_DRAW_TYPE fl1DrawType = canShowFl1 ? DRAW_LINE : DRAW_NONE;
ArraySetAsSeries(fl1Buffer, true);
SetIndexBuffer(fl1BufferIndex, fl1Buffer, INDICATOR_DATA);
PlotIndexSetDouble(fl1PlotBufferIndex, PLOT_EMPTY_VALUE, EMPTY_VALUE);
PlotIndexSetInteger(fl1PlotBufferIndex, PLOT_SHOW_DATA, canShowFl1);
PlotIndexSetInteger(fl1PlotBufferIndex, PLOT_DRAW_TYPE, fl1DrawType);
//
// LEVEL 2 ...
bool canShowFl2 = showFibo2Levels;
ENUM_DRAW_TYPE fl2DrawType = canShowFl2 ? DRAW_LINE : DRAW_NONE;
ArraySetAsSeries(fl2Buffer, true);
SetIndexBuffer(fl2BufferIndex, fl2Buffer, INDICATOR_DATA);
PlotIndexSetDouble(fl2PlotBufferIndex, PLOT_EMPTY_VALUE, EMPTY_VALUE);
PlotIndexSetInteger(fl2PlotBufferIndex, PLOT_SHOW_DATA, canShowFl2);
PlotIndexSetInteger(fl2PlotBufferIndex, PLOT_DRAW_TYPE, fl2DrawType);
//
// LEVEL 3 ...
bool canShowFl3 = showFibo3Levels;
ENUM_DRAW_TYPE fl3DrawType = canShowFl3 ? DRAW_LINE : DRAW_NONE;
ArraySetAsSeries(fl3Buffer, true);
SetIndexBuffer(fl3BufferIndex, fl3Buffer, INDICATOR_DATA);
PlotIndexSetDouble(fl3PlotBufferIndex, PLOT_EMPTY_VALUE, EMPTY_VALUE);
PlotIndexSetInteger(fl3PlotBufferIndex, PLOT_SHOW_DATA, canShowFl3);
PlotIndexSetInteger(fl3PlotBufferIndex, PLOT_DRAW_TYPE, fl3DrawType);
//
// LEVEL 4 ...
bool canShowFl4 = showFibo4Levels;
ENUM_DRAW_TYPE fl4DrawType = canShowFl4 ? DRAW_LINE : DRAW_NONE;
ArraySetAsSeries(fl4Buffer, true);
SetIndexBuffer(fl4BufferIndex, fl4Buffer, INDICATOR_DATA);
PlotIndexSetDouble(fl4PlotBufferIndex, PLOT_EMPTY_VALUE, EMPTY_VALUE);
PlotIndexSetInteger(fl4PlotBufferIndex, PLOT_SHOW_DATA, canShowFl4);
PlotIndexSetInteger(fl4PlotBufferIndex, PLOT_DRAW_TYPE, fl4DrawType);
//
// LEVEL 5 ...
bool canShowFl5 = showFibo5Levels;
ENUM_DRAW_TYPE fl5DrawType = canShowFl5 ? DRAW_LINE : DRAW_NONE;
ArraySetAsSeries(fl5Buffer, true);
SetIndexBuffer(fl5BufferIndex, fl5Buffer, INDICATOR_DATA);
PlotIndexSetDouble(fl5PlotBufferIndex, PLOT_EMPTY_VALUE, EMPTY_VALUE);
PlotIndexSetInteger(fl5PlotBufferIndex, PLOT_SHOW_DATA, canShowFl5);
PlotIndexSetInteger(fl5PlotBufferIndex, PLOT_DRAW_TYPE, fl5DrawType);
//
// Data Buffers ...
@@ -1249,6 +1151,13 @@ void DefineBuffers()
//
ArraySetAsSeries(atrLowerRawBuffer, true);
SetIndexBuffer(atrLowerRawBufferIndex, atrLowerRawBuffer, INDICATOR_CALCULATIONS);
//
// RSI ...
//
ArraySetAsSeries(rsiBuffer, true);
SetIndexBuffer(rsiBufferIndex, rsiBuffer, INDICATOR_CALCULATIONS);
}
/**
@@ -1324,11 +1233,6 @@ void CalculateBuffers(
low //
);
//
CalculateFibonacci(
bar_index //
);
//
// Calculate Required VWAP Data Buffers ...
if (ratesTotal - bar_index <= maxLength)
@@ -1539,6 +1443,10 @@ void FillBuffersZero(int barIndex)
// SARS ...
sarBuffer[barIndex] = 0;
//
// RSIS ...
rsiBuffer[barIndex] = 0;
//
// ATRS ...
atrBuffer[barIndex] = 0;
@@ -1574,13 +1482,6 @@ void FillBuffersZero(int barIndex)
donHighLowerBuffer[barIndex] = 0;
donLowUpperBuffer[barIndex] = 0;
donLowLowerBuffer[barIndex] = 0;
//
fl1Buffer[barIndex] = 0;
fl2Buffer[barIndex] = 0;
fl3Buffer[barIndex] = 0;
fl4Buffer[barIndex] = 0;
fl5Buffer[barIndex] = 0;
}
/**
@@ -2213,109 +2114,4 @@ void CalculateAtrZones(
}
}
/**
* Calculate Fibonacci Levels ...
*
* @param bar_index: Integer, current Bar Index ...
*/
void CalculateFibonacci(
int bar_index //
)
{
//
double fiboUpper = 0;
double fiboLower = 0;
//
fiboUpper = peaksBuffer[bar_index];
fiboLower = valesBuffer[bar_index];
//
// Level 1 ...
bool canCalculateFiboLevel1 = fiboLevel1 > 0;
if (canCalculateFiboLevel1)
{
//
double iFib = GetFibonacciLevel(
fiboUpper,
fiboLower,
fiboLevel1,
1 //
);
//
fl1Buffer[bar_index] = iFib;
}
//
// Level 2 ...
bool canCalculateFiboLevel2 = fiboLevel2 > 0;
if (canCalculateFiboLevel2)
{
//
double iFib = GetFibonacciLevel(
fiboUpper,
fiboLower,
fiboLevel2,
1 //
);
//
fl2Buffer[bar_index] = iFib;
}
//
// Level 3 ...
bool canCalculateFiboLevel3 = fiboLevel3 > 0;
if (canCalculateFiboLevel3)
{
//
double iFib = GetFibonacciLevel(
fiboUpper,
fiboLower,
fiboLevel3,
1 //
);
//
fl3Buffer[bar_index] = iFib;
}
//
// Level 4 ...
bool canCalculateFiboLevel4 = fiboLevel4 > 0;
if (canCalculateFiboLevel4)
{
//
double iFib = GetFibonacciLevel(
fiboUpper,
fiboLower,
fiboLevel4,
1 //
);
//
fl4Buffer[bar_index] = iFib;
}
//
// Level 5 ...
bool canCalculateFiboLevel5 = fiboLevel5 > 0;
if (canCalculateFiboLevel5)
{
//
double iFib = GetFibonacciLevel(
fiboUpper,
fiboLower,
fiboLevel5,
1 //
);
//
fl5Buffer[bar_index] = iFib;
}
//
}
//
+92 -17
View File
@@ -165,6 +165,28 @@ class XC121SMCExpert : public XCBaseExpert
ReConfigure();
}
/**
* Get Allow Open Trade On Signals State ...
*
* @return ( bool )
*/
bool AllowTrade()
{
return mAllowTrade;
}
/**
* Set Allow Open Trade On Signals State ...
*
* @param value: Boolean ...
*/
void AllowTrade(bool value)
{
//
mAllowTrade = value;
ReConfigure();
}
/**
* Get Use Max Allowed Signal Types Per Symbol State ...
*
@@ -806,14 +828,63 @@ class XC121SMCExpert : public XCBaseExpert
datetime currentTime = TimeCurrent();
//
// Execute Signal Using Trade Handler ...
ENUM_X_SIGNAL_EXECUTION_RESULT state;
bool isExecuted = mTradeHandler.ExecuteSignal(
signal,
conditions,
state,
false // ignore Policies ...
);
// Chack Allow Trades ...
bool allowTrade = AllowTrade();
if (allowTrade)
{
//
// Execute Signal Using Trade Handler ...
ENUM_X_SIGNAL_EXECUTION_RESULT state;
bool isExecuted = mTradeHandler.ExecuteSignal(
signal,
conditions,
state,
false // ignore Policies ...
);
}
else
{
//
// Only Alert Signals ...
string msg = (IsLong(signal.type)
? "Long"
: "Short") +
" Signal Recieved: (" +
signal.provider + "," +
signal.symbol + "," +
ToString(signal.period) +
") ...";
//
Alert(msg);
//
// Draw Signals and Conditions ...
if (eaDrawer != NULL)
{
//
XCBaseObject *objects[];
XCSignalObject *signalObject;
bool isCreated = eaDrawer.DrawSignal(
signal,
signalObject //
);
DrawX121SMCStrategyConditions(
conditions,
objects,
eaDrawer,
true, // draw Market Structure ...
true, // Draw Price Zones ...
true // Draw Decision Zones ...
);
//
Add(
(XCBaseObject *)signalObject,
objects //
);
}
}
}
//
@@ -1034,7 +1105,7 @@ class XC121SMCExpert : public XCBaseExpert
//
// Parsers ...
XSymbolParser _symbolParser;
XCPOIDrawer *poiDrawer = NULL;
eaDrawer = NULL;
//
// Single Symbol ...
@@ -1052,11 +1123,11 @@ class XC121SMCExpert : public XCBaseExpert
);
//
if (poiDrawer == NULL)
if (eaDrawer == NULL)
{
//
poiDrawer = iX121SMCStrategy
.GetDrawer();
eaDrawer = iX121SMCStrategy
.GetDrawer();
}
//
@@ -1125,11 +1196,11 @@ class XC121SMCExpert : public XCBaseExpert
);
//
if (poiDrawer == NULL)
if (eaDrawer == NULL)
{
//
poiDrawer = iX121SMCStrategy
.GetDrawer();
eaDrawer = iX121SMCStrategy
.GetDrawer();
}
//
@@ -1144,9 +1215,9 @@ class XC121SMCExpert : public XCBaseExpert
}
//
if (poiDrawer != NULL)
if (eaDrawer != NULL)
{
mTradeHandler.SetDrawer(poiDrawer);
mTradeHandler.SetDrawer(eaDrawer);
}
//
@@ -1574,6 +1645,7 @@ class XC121SMCExpert : public XCBaseExpert
// Signalling Props ...
bool mAllowLong; // Allow Long Signals ...
bool mAllowShort; // Allow Short Signals ...
bool mAllowTrade; // Allow Open Trade On Signals ...
int mMaxAllowedLongs; // Max Allowed Long Signals ...
int mMaxAllowedShorts; // Max Allowed Short Signals ...
bool mUseMaxAllowedSignalsPerSymbol; // Use Max Allowed Signal Types Per Symbol ...
@@ -1602,6 +1674,9 @@ class XC121SMCExpert : public XCBaseExpert
double mHedgingMinVolumeStep; // Minimum Volume Step for Hedging ...
double mHedgeingMinRequiredProfitPerVolumeStep; // Minimum Required Profit Per Volume Step for Hedging ...
//
XCPOIDrawer *eaDrawer; // EA Drawer ...
//
double CalculateAdditionalVolumeMultiplier(XSignal &signal)
{
@@ -1226,6 +1226,11 @@ bool DetectX121SMCXTWPVSiganlTrigger(
}
//
// Ignore Target ...
target = 0;
//
// Filling Conditions Props ...
conditions.sl = sl;
conditions.target = target;
conditions.triggerTime = cTime;
@@ -623,23 +623,18 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
x121Inputs.hcMethod = hcMethod;
x121Inputs.hcPeriod = hcPeriod;
//
x121Inputs.showFibo2Levels = false;
x121Inputs.showFibo3Levels = false;
x121Inputs.showFibo4Levels = false;
//
x121Inputs.showSar = true;
x121Inputs.showPeaks = true;
x121Inputs.showVales = true;
x121Inputs.showVWap = false;
x121Inputs.showVWap = true;
x121Inputs.showDonchain = true;
//
x121Inputs.showOpen = false;
x121Inputs.showHigh = true;
x121Inputs.showHigh = false;
x121Inputs.showClose = true;
x121Inputs.showLow = true;
x121Inputs.showLow = false;
//
// Initialize Cycle Helpers ...