Indicators Used
Miscellaneous
0
Views
0
Downloads
0
Favorites
RSI_DynZ_TDI_mtf
//+------------------------------------------------------------------+
//| RSI_DynamicZone_TDI(mtf) Traders Dynamic Index.mq4 |
//| Copyright © 2006, Dean Malone |
//| www.compassfx.com |
//+------------------------------------------------------------------+
//mtf2008ForexTSD mladen f.la ki
//+------------------------------------------------------------------+
//| |
//| Traders Dynamic Index |
//| |
//| This hybrid indicator is developed to assist traders in their |
//| ability to decipher and monitor market conditions related to |
//| trend direction, market strength, and market volatility. |
//| |
//| Even though comprehensive, the T.D.I. is easy to read and use. |
//| |
//| Green line = RSI Price line |
//| Red line = Trade Signal line |
//| Blue lines = Volatility Band |
//| Yellow line = Market Base Line |
//| |
//| Trend Direction - Immediate and Overall |
//| Immediate = Green over Red...price action is moving up. |
//| Red over Green...price action is moving down. |
//| |
//| Overall = Yellow line trends up and down generally between the |
//| lines 32 & 68. Watch for Yellow line to bounces off |
//| these lines for market reversal. Trade long when |
//| price is above the Yellow line, and trade short when |
//| price is below. |
//| |
//| Market Strength & Volatility - Immediate and Overall |
//| Immediate = Green Line - Strong = Steep slope up or down. |
//| Weak = Moderate to Flat slope. |
//| |
//| Overall = Blue Lines - When expanding, market is strong and |
//| trending. When constricting, market is weak and |
//| in a range. When the Blue lines are extremely tight |
//| in a narrow range, expect an economic announcement |
//| or other market condition to spike the market. |
//| |
//| |
//| Entry conditions |
//| Scalping - Long = Green over Red, Short = Red over Green |
//| Active - Long = Green over Red & Yellow lines |
//| Short = Red over Green & Yellow lines |
//| Moderate - Long = Green over Red, Yellow, & 50 lines |
//| Short= Red over Green, Green below Yellow & 50 line |
//| |
//| Exit conditions* |
//| Long = Green crosses below Red |
//| Short = Green crosses above Red |
//| * If Green crosses either Blue lines, consider exiting when |
//| when the Green line crosses back over the Blue line. |
//| |
//| |
//| IMPORTANT: The default settings are well tested and proven. |
//| But, you can change the settings to fit your |
//| trading style. |
//| |
//| |
//| Price & Line Type settings: |
//| RSI Price settings |
//| 0 = Close price [DEFAULT] (COHLMTW) |
//| 1 = Open price. |
//| 2 = High price. |
//| 3 = Low price. |
//| 4 = Median price, (high+low)/2. |
//| 5 = Typical price, (high+low+close)/3. |
//| 6 = Weighted close price, (high+low+close+close)/4. |
//| |
//| RSI Price Line & Signal Line Type settings |
//| 0 = Simple moving average [DEFAULT] |
//| 1 = Exponential moving average |
//| 2 = Smoothed moving average |
//| 3 = Linear weighted moving average |
//| SMA EMA SMMA LWMA |
//| Good trading, |
//| |
//| Dean |
//+------------------------------------------------------------------+
#property indicator_separate_window
#property indicator_buffers 6
#property indicator_color1 Black
#property indicator_color2 MediumBlue
#property indicator_color3 Goldenrod
#property indicator_color4 MediumBlue
#property indicator_color5 Green
#property indicator_color6 Red
#property indicator_width5 2
#property indicator_width6 1
#property indicator_level1 76.4
#property indicator_level2 61.8
#property indicator_level3 50.0
#property indicator_level4 38.2
#property indicator_level5 23.6
#property indicator_levelstyle 2
#property indicator_levelcolor C'60,75,33'
//--
extern int RSI_Period = 13; //8-25
extern int RSI_Price = 0; //0-6 (COHLMTW)
extern int Volatility_Band = 34; //20-40
extern int RSI_Price_Line_Period = 2;
extern int RSI_Price_Line_Type = 0; //0-3
extern int Trade_Signal_Line_Period = 7;
extern int Trade_Signal_Line_Type = 0; //0-3 (SMA EMA SMMA LWMA)
extern int timeFrame = 0;
extern string note_timeFrames = "M1;5,15,30,60H1;240H4;1440D1;10080W1;43200MN|0currentTF";
extern string appliedPrice_ = "0C 1O 2H 3L 4Md 5Tp 6WghC, Md(HL/2)4,Tp(HLC/3)5,Wgh(HLCC/4)6";
extern string MA_Type_ = "SMA0 EMA1 SMMA2 LWMA3";
string IndicatorFileName;
double RSIBuf[],UpZone[],MdZone[],DnZone[],MaBuf[],MbBuf[];
//+------------------------------------------------------------------+
int init()
{
SetIndexBuffer(0,RSIBuf);
SetIndexBuffer(1,UpZone);
SetIndexBuffer(2,MdZone);
SetIndexBuffer(3,DnZone);
SetIndexBuffer(4,MaBuf);
SetIndexBuffer(5,MbBuf);
SetIndexStyle(0,DRAW_NONE);
SetIndexStyle(1,DRAW_LINE);
SetIndexStyle(2,DRAW_LINE);
SetIndexStyle(3,DRAW_LINE);
SetIndexStyle(4,DRAW_LINE);
SetIndexStyle(5,DRAW_LINE);
SetIndexLabel(0,NULL);
SetIndexLabel(1,"VolBand("+Volatility_Band+") High");
SetIndexLabel(2,"MarketBaseLine(VolBand"+Volatility_Band+")");
SetIndexLabel(3,"VolBand("+Volatility_Band+") Low");
SetIndexLabel(4,"RSI("+RSI_Period+","+RSI_Price_Line_Period+") Price Line");
SetIndexLabel(5,"Trade RSI_Signal_Line("+Trade_Signal_Line_Period+")");
switch(timeFrame)
{
case 1: string TimeFrameStr = "M1"; break;
case 5 : TimeFrameStr = "M5"; break;
case 15 : TimeFrameStr = "M15"; break;
case 30 : TimeFrameStr = "M30"; break;
case 60 : TimeFrameStr = "H1"; break;
case 240 : TimeFrameStr = "H4"; break;
case 1440 : TimeFrameStr = "D1"; break;
case 10080 : TimeFrameStr = "W1"; break;
case 43200 : TimeFrameStr = "MN1"; break;
default : TimeFrameStr = "TF0";
}
IndicatorShortName("DynRSI_TDI["+TimeFrameStr+"] RSI("+RSI_Period+";"+RSI_Price_Line_Period+") SigL("+Trade_Signal_Line_Period+") B("+Volatility_Band+")");
IndicatorFileName = WindowExpertName();
if (timeFrame < Period()) timeFrame = Period();
return(0);
}
int start()
{
double MA,RSI[];
ArrayResize(RSI,Volatility_Band);
int counted_bars1=IndicatorCounted();
int limit1,i1;
if(counted_bars1 < 0) return(-1);
limit1 = Bars-counted_bars1;
//
//
// MTF mode operating
//
//
if (timeFrame != Period())
{
limit1 = MathMax(limit1,timeFrame/Period());
datetime TimeArray[];
ArrayCopySeries(TimeArray ,MODE_TIME ,NULL,timeFrame);
//
//
//
//
//
for(i1=0,int y=0; i1<limit1; i1++)
{
if(Time[i1]<TimeArray[y]) y++;
RSIBuf[i1] = iCustom(NULL,timeFrame,IndicatorFileName,
RSI_Period,RSI_Price,Volatility_Band,
RSI_Price_Line_Period,RSI_Price_Line_Type,
Trade_Signal_Line_Period,Trade_Signal_Line_Type,0,y);
UpZone[i1] = iCustom(NULL,timeFrame,IndicatorFileName,
RSI_Period,RSI_Price,Volatility_Band,
RSI_Price_Line_Period,RSI_Price_Line_Type,
Trade_Signal_Line_Period,Trade_Signal_Line_Type,1,y);
MdZone[i1] = iCustom(NULL,timeFrame,IndicatorFileName,
RSI_Period,RSI_Price,Volatility_Band,
RSI_Price_Line_Period,RSI_Price_Line_Type,
Trade_Signal_Line_Period,Trade_Signal_Line_Type,2,y);
DnZone[i1] = iCustom(NULL,timeFrame,IndicatorFileName,
RSI_Period,RSI_Price,Volatility_Band,
RSI_Price_Line_Period,RSI_Price_Line_Type,
Trade_Signal_Line_Period,Trade_Signal_Line_Type,3,y);
MaBuf[i1] = iCustom(NULL,timeFrame,IndicatorFileName,
RSI_Period,RSI_Price,Volatility_Band,
RSI_Price_Line_Period,RSI_Price_Line_Type,
Trade_Signal_Line_Period,Trade_Signal_Line_Type,4,y);
MbBuf[i1] = iCustom(NULL,timeFrame,IndicatorFileName,
RSI_Period,RSI_Price,Volatility_Band,
RSI_Price_Line_Period,RSI_Price_Line_Type,
Trade_Signal_Line_Period,Trade_Signal_Line_Type,5,y);
}
return(0);
}
//
//
//
//
//
int counted_bars=IndicatorCounted();
int limit = Bars-counted_bars-1;
for(int i=limit; i>=0; i--)
{
RSIBuf[i] = (iRSI(NULL,0,RSI_Period,RSI_Price,i));
MA = 0;
for(int x=i; x<i+Volatility_Band; x++) {
RSI[x-i] = RSIBuf[x];
MA += RSIBuf[x]/Volatility_Band;
}
UpZone[i] = (MA + (1.6185 * StDev(RSI,Volatility_Band)));
DnZone[i] = (MA - (1.6185 * StDev(RSI,Volatility_Band)));
MdZone[i] = ((UpZone[i] + DnZone[i])/2);
}
for (i=limit-1;i>=0;i--)
{
MaBuf[i] = (iMAOnArray(RSIBuf,0,RSI_Price_Line_Period,0,RSI_Price_Line_Type,i));
MbBuf[i] = (iMAOnArray(RSIBuf,0,Trade_Signal_Line_Period,0,Trade_Signal_Line_Type,i));
}
//----
return(0);
}
double StDev(double& Data[], int Per)
{return(MathSqrt(Variance(Data,Per)));
}
double Variance(double& Data[], int Per)
{double sum, ssum;
for (int i=0; i<Per; i++)
{sum += Data[i];
ssum += MathPow(Data[i],2);
}
return((ssum*Per - sum*sum)/(Per*(Per-1)));
}
//+------------------------------------------------------------------+
Comments
Markdown Formatting Guide
# H1
## H2
### H3
**bold text**
*italicized text*
[title](https://www.example.com)

`code`
```
code block
```
> blockquote
- Item 1
- Item 2
1. First item
2. Second item
---