add support for xtrend indicator in x121 setup helper ...

This commit is contained in:
2025-02-09 22:51:56 +03:30
parent c79ee42d7c
commit 714a905a2a
5 changed files with 1416 additions and 71 deletions
+34 -10
View File
@@ -39,9 +39,9 @@ input group "Market";
input ENUM_APPLIED_PRICE trendPriceType = PRICE_CLOSE; // Detect Trend Price Type
input group "MA Detection";
input int maLength = 50; // MA Length
input ENUM_MA_METHOD maMethod = MODE_EMA; // MA Method
input ENUM_APPLIED_PRICE maAppliedTo; // MA Applied To
input int maLength = 50; // MA Length
input ENUM_MA_METHOD maMethod = MODE_EMA; // MA Method
input ENUM_APPLIED_PRICE maAppliedTo = PRICE_CLOSE; // MA Applied To
input group "ADX Detection";
input int adxLength = 14; // ADX Length
@@ -65,7 +65,7 @@ input bool showDownTrend = true; // Show Down Trend
#property indicator_chart_window
//
#property indicator_buffers 6
#property indicator_buffers 8
#property indicator_plots 2
//
@@ -113,6 +113,14 @@ double adxPBuffer[];
#define adxMBufferIndex mLastBufferIndex + 4
double adxMBuffer[];
//
#define upTBufferIndex mLastBufferIndex + 5
double upTBuffer[];
//
#define downTBufferIndex mLastBufferIndex + 6
double downTBuffer[];
//
// Variables, Properties and etc ...
@@ -469,6 +477,14 @@ void DefineBuffers()
//
ArraySetAsSeries(adxMBuffer, true);
SetIndexBuffer(adxMBufferIndex, adxMBuffer, INDICATOR_CALCULATIONS);
//
ArraySetAsSeries(upTBuffer, true);
SetIndexBuffer(upTBufferIndex, upTBuffer, INDICATOR_CALCULATIONS);
//
ArraySetAsSeries(downTBuffer, true);
SetIndexBuffer(downTBufferIndex, downTBuffer, INDICATOR_CALCULATIONS);
}
/**
@@ -602,18 +618,21 @@ void CalculateTrend(
// iValue = iLastValue;
// }
// //
// double iValue = low[bar_index] - points10;
//
double selectedValue = low[bar_index] - points10;
//
double iValue =
!IsBullish(lastTrendDir) ? low[bar_index] - points10
!IsBullish(lastTrendDir) ? selectedValue
: !showOnlyTrendStart
? lastValue
: 0;
//
upTrendBuffer[bar_index] = iValue;
upTBuffer[bar_index] = selectedValue;
//
downTrendBuffer[bar_index] = 0;
//
@@ -633,12 +652,12 @@ void CalculateTrend(
// iValue = iLastValue;
// }
// //
// double iValue = high[bar_index] + points10;
//
double selectedValue = high[bar_index] + points10;
//
double iValue =
!IsBearish(lastTrendDir) ? high[bar_index] + points10
!IsBearish(lastTrendDir) ? selectedValue
: !showOnlyTrendStart
? lastValue
: 0;
@@ -646,6 +665,7 @@ void CalculateTrend(
//
upTrendBuffer[bar_index] = 0;
downTrendBuffer[bar_index] = iValue;
downTBuffer[bar_index] = selectedValue;
//
lastValue = iValue;
@@ -669,6 +689,10 @@ void CalculateTrend(
upTrendBuffer[bar_index] = 0;
downTrendBuffer[bar_index] = 0;
//
upTBuffer[bar_index] = 0;
downTBuffer[bar_index] = 0;
//
lastValue = 0;
lastTrendDir = X_DIRECTION_NONE;