-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14 from EA31337/dev
New indicators and improvements
- Loading branch information
Showing
28 changed files
with
2,305 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
#property indicator_buffers 4 | ||
#property indicator_separate_window | ||
|
||
extern int NumberOfBars = 100; | ||
extern double SlopeThreshold = 2.0; | ||
extern int SlopeMAPeriod = 7; | ||
extern int SlopeATRPeriod = 50; | ||
|
||
extern color SlopeColor = Gray; | ||
extern color LongColor = Lime; | ||
extern color ShortColor = Red; | ||
|
||
double Slope[]; | ||
double Long[]; | ||
double Short[]; | ||
double Flat[]; | ||
|
||
//+------------------------------------------------------------------+ | ||
//| Custom indicator initialization function | | ||
//+------------------------------------------------------------------+ | ||
int init() { | ||
IndicatorShortName(WindowExpertName()); | ||
|
||
SetIndexBuffer(0, Slope); | ||
SetIndexBuffer(1, Long); | ||
SetIndexBuffer(2, Short); | ||
SetIndexBuffer(3, Flat); | ||
|
||
SetIndexStyle(0, DRAW_LINE, STYLE_SOLID, 1, SlopeColor); | ||
SetIndexLabel(0, "Slope"); | ||
SetIndexStyle(1, DRAW_ARROW, STYLE_SOLID, 1, LongColor); | ||
SetIndexLabel(1, "Long"); | ||
SetIndexArrow(1, 159); | ||
SetIndexStyle(2, DRAW_ARROW, STYLE_SOLID, 1, ShortColor); | ||
SetIndexLabel(2, "Short"); | ||
SetIndexArrow(2, 159); | ||
SetIndexStyle(3, DRAW_ARROW, STYLE_SOLID, 1, SlopeColor); | ||
SetIndexLabel(3, "Flat"); | ||
SetIndexArrow(3, 159); | ||
|
||
#ifdef __MQL4__ | ||
SetLevelStyle(STYLE_SOLID, 1, SlopeColor); | ||
SetLevelValue(0, SlopeThreshold * 0.5); | ||
SetLevelValue(1, -SlopeThreshold * 0.5); | ||
#endif | ||
|
||
return (INIT_SUCCEEDED); | ||
} | ||
|
||
int start() { | ||
int prev_calculated = IndicatorCounted(); | ||
int rates_total = Bars; | ||
int limit = MathMin(NumberOfBars, rates_total - prev_calculated); | ||
if (limit == rates_total) | ||
limit--; | ||
|
||
for (int shift = limit; shift >= 0; shift--) { | ||
Slope[shift] = 0; | ||
|
||
double dblTma, dblPrev; | ||
double atr = iATR(NULL, PERIOD_CURRENT, SlopeATRPeriod, shift + 10) / 10; | ||
|
||
if (atr != 0) { | ||
dblTma = iMA(NULL, PERIOD_CURRENT, SlopeMAPeriod, 0, MODE_LWMA, | ||
PRICE_CLOSE, shift); | ||
dblPrev = (iMA(NULL, PERIOD_CURRENT, SlopeMAPeriod, 0, MODE_LWMA, | ||
PRICE_CLOSE, shift + 1) * | ||
231 + | ||
iClose(NULL, (int)PERIOD_CURRENT, shift) * 20) / | ||
251; | ||
Slope[shift] = (dblTma - dblPrev) / atr; | ||
} | ||
|
||
Long[shift] = EMPTY_VALUE; | ||
Short[shift] = EMPTY_VALUE; | ||
Flat[shift] = EMPTY_VALUE; | ||
|
||
if (Slope[shift] > SlopeThreshold * 0.5) | ||
Long[shift] = Slope[shift]; | ||
else if (Slope[shift] < -SlopeThreshold * 0.5) | ||
Short[shift] = Slope[shift]; | ||
else | ||
Flat[shift] = Slope[shift]; | ||
} | ||
|
||
return (0); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
/** | ||
* @file | ||
* Implements indicator under MQL5. | ||
*/ | ||
|
||
// Defines indicator properties. | ||
#property indicator_separate_window | ||
|
||
#property indicator_buffers 4 | ||
#property indicator_plots 4 | ||
|
||
// Define indicator properties | ||
#property indicator_type1 DRAW_LINE | ||
#property indicator_color1 Gray | ||
#property indicator_label1 "Slope" | ||
|
||
#property indicator_type2 DRAW_ARROW | ||
#property indicator_color2 Lime | ||
#property indicator_label2 "Long" | ||
|
||
#property indicator_type3 DRAW_ARROW | ||
#property indicator_color3 Red | ||
#property indicator_label3 "Short" | ||
|
||
#property indicator_type4 DRAW_ARROW | ||
#property indicator_color4 Gray | ||
#property indicator_label4 "Flat" | ||
|
||
#property indicator_level1 0.0 | ||
|
||
// Includes EA31337 framework. | ||
#include <EA31337-classes/Draw.mqh> | ||
#include <EA31337-classes/Indicator.mqh> | ||
#include <EA31337-classes/Indicators/Indi_ATR.mqh> | ||
#include <EA31337-classes/Indicators/Indi_MA.mqh> | ||
|
||
// Defines macros. | ||
#define extern input | ||
#define Bars (ChartStatic::iBars(_Symbol, _Period)) | ||
|
||
// Includes the main file. | ||
#include "ATR_MA_Slope.mq4" | ||
|
||
// Custom indicator initialization function. | ||
void OnInit() { | ||
init(); | ||
if (!ArrayGetAsSeries(Slope)) { | ||
ArraySetAsSeries(Slope, true); | ||
ArraySetAsSeries(Long, true); | ||
ArraySetAsSeries(Short, true); | ||
ArraySetAsSeries(Flat, true); | ||
} | ||
PlotIndexSetDouble(1, PLOT_EMPTY_VALUE, EMPTY_VALUE); | ||
PlotIndexSetDouble(2, PLOT_EMPTY_VALUE, EMPTY_VALUE); | ||
PlotIndexSetDouble(3, PLOT_EMPTY_VALUE, EMPTY_VALUE); | ||
PlotIndexSetInteger(0, PLOT_DRAW_BEGIN, SlopeMAPeriod); | ||
PlotIndexSetInteger(1, PLOT_DRAW_BEGIN, SlopeMAPeriod); | ||
PlotIndexSetInteger(2, PLOT_DRAW_BEGIN, SlopeMAPeriod); | ||
PlotIndexSetInteger(3, PLOT_DRAW_BEGIN, SlopeMAPeriod); | ||
} | ||
|
||
// Custom indicator iteration function. | ||
int OnCalculate(const int rates_total, const int prev_calculated, | ||
const int begin, const double &price[]) { | ||
IndicatorCounted(fmin(prev_calculated, Bars)); | ||
ResetLastError(); | ||
return start() >= 0 ? rates_total : 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# Arrow-like Oscillators | ||
|
||
Arrow-like oscillators are a category of technical indicators that | ||
provide trading signals in the form of arrows or other visual markers | ||
on a chart. These indicators are designed to generate signals for both | ||
long (buy) and short (sell) positions, indicating potential entry and | ||
exit points for traders. | ||
|
||
Here are the key characteristics of arrow-like oscillators: | ||
|
||
- Signal Generation: Arrow-like oscillators generate signals by | ||
analyzing price movements, trends, and other relevant market | ||
conditions. When a specific set of criteria is met, these indicators | ||
plot an arrow pointing up (for long/buy) or down (for short/sell) on | ||
the chart, indicating a potential trade entry or exit point. | ||
|
||
- Trend Reversals: These indicators often focus on identifying | ||
potential trend reversals. When the market is transitioning from an | ||
upward trend to a downward trend (or vice versa), arrow-like | ||
oscillators aim to capture these turning points and provide traders | ||
with signals to take advantage of the changing trend. | ||
|
||
- Confirmation: Traders often use arrow-like oscillators in | ||
conjunction with other technical analysis tools to confirm their | ||
trading decisions. These indicators can help traders avoid false | ||
signals by waiting for confirmation from multiple sources before | ||
entering a trade. | ||
|
||
- User-Defined Parameters: Many arrow-like oscillators allow traders | ||
to customize their parameters, such as sensitivity levels, timeframes, | ||
and overbought/oversold thresholds. This customization enables | ||
traders to tailor the indicator to their specific trading style and | ||
preferences. | ||
|
||
- Risk Management: While these indicators provide entry and exit | ||
signals, traders should still employ proper risk management | ||
techniques, such as setting stop-loss and take-profit levels, to | ||
protect their capital. | ||
|
||
Arrow-like oscillators are particularly popular among traders who | ||
prefer visual signals for their trading decisions. They simplify | ||
the process of identifying potential trade opportunities and can | ||
enhance the efficiency of a trader's decision-making process. |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# Oscillator indicators | ||
|
||
Oscillators are a category of technical indicators used in financial markets | ||
analysis. They are designed to identify overbought or oversold conditions and | ||
potential trend reversals. Oscillators typically oscillate within a specific | ||
range or between certain values, indicating the momentum or strength of a price | ||
movement. | ||
|
||
Oscillators are considered a subset of indicators since they are technical | ||
tools used to analyze price data and generate signals. They differ from other | ||
types of indicators like trend-following or volume-based indicators because | ||
oscillators are designed to provide information about the short-term price | ||
behavior rather than long-term trends or volume patterns. | ||
|
||
Common examples of oscillators include the Relative Strength Index (RSI), | ||
Stochastic Oscillator, Moving Average Convergence Divergence (MACD), and | ||
the Williams %R. These indicators generate values that fluctuate within | ||
predefined boundaries, typically between 0 and 100 or -100 and +100, | ||
indicating the relative strength or weakness of price movements. | ||
|
||
Traders and analysts use oscillators to identify potential buying or | ||
selling opportunities, divergences, and to gauge market conditions such | ||
as overbought or oversold levels. They can be helpful in identifying | ||
potential trend reversals or determining the strength of an ongoing | ||
trend. | ||
|
||
In summary, oscillators are a type of indicator used in technical | ||
analysis that measure price momentum and provide insights into | ||
overbought or oversold conditions. They are considered a subset of | ||
indicators due to their specific function and characteristics. | ||
|
||
## TDI (Traders Dynamic Index) | ||
|
||
The Traders Dynamic Index (TDI) is a versatile trading indicator designed to | ||
aid traders in analyzing market conditions related to trend direction, market | ||
strength, and volatility. It combines RSI, Moving Averages, and volatility | ||
bands to offer insights into trend direction, market strength, and volatility | ||
which gives comprehensive overview of the market's behavior. |
File renamed without changes.
File renamed without changes.
Oops, something went wrong.