Indicators Used
Miscellaneous
0
Views
0
Downloads
0
Favorites
TMFI-3
// True MFI. Based on code RSI.mq4, Copyright © 2004, MetaQuotes Software Corp. http://www.metaquotes.net/
#property copyright "Copyright © 2004, MetaQuotes Software Corp., BECEMAL 2010"
#property link "http://www.becemal.ru/"
#property indicator_separate_window
#property indicator_minimum 0
#property indicator_maximum 100
#property indicator_level1 31.830988618379067153776752674503
#property indicator_level2 68.169011381620932846223247325497
#property indicator_buffers 3
#property indicator_color1 RoyalBlue
extern int TMFIPeriod=10;
double TMFIBuffer[];
double PosBuffer[];
double NegBuffer[];
bool init_flag=false;
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
bool prepare_buffer()
{
if(init_flag) return(true);
PosBuffer[0]=0;
NegBuffer[0]=0;
init_flag=true;
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int init()
{
string short_name="TMFI("+TMFIPeriod+")";
SetIndexBuffer(1,PosBuffer);
SetIndexBuffer(2,NegBuffer);
SetIndexStyle(0,DRAW_LINE);
SetIndexStyle(1,DRAW_NONE);
SetIndexStyle(2,DRAW_NONE);
SetIndexBuffer(0,TMFIBuffer);
IndicatorShortName(short_name);
SetIndexLabel(0,"KosherMFI");
SetIndexDrawBegin(0,TMFIPeriod);
init_flag=false;
return(0);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int start()
{
if(!init_flag) {prepare_buffer();}
int i,counted_bars=IndicatorCounted();
double rel,negative,positive,sumn,sump;
if(Bars<=TMFIPeriod) return(0);
if(counted_bars<1)
for(i=1;i<=TMFIPeriod;i++) TMFIBuffer[Bars-i]=50.0;
i=Bars-TMFIPeriod-1;
if(counted_bars>=TMFIPeriod) i=Bars-counted_bars-1;
while(i>=0)
{
sumn=0.0; sump=0.0;
rel = iMA(NULL,0,TMFIPeriod,0,MODE_EMA,PRICE_CLOSE,i) - iMA(NULL,0,TMFIPeriod,0,MODE_EMA,PRICE_CLOSE,i+3) + 8 * iMA(NULL,0,TMFIPeriod,0,MODE_EMA,PRICE_CLOSE,i+1) - 8 * iMA(NULL,0,TMFIPeriod,0,MODE_EMA,PRICE_CLOSE,i+2);
//rel=Close[i]-Close[i+1];
if(rel>0) sump=(Volume[i]+ 2 * Volume[i+1] + 2 * Volume[i+2] + Volume[i+3]);
else sumn=(Volume[i]+ 2 * Volume[i+1] + 2 * Volume[i+2] + Volume[i+3]);
positive=(PosBuffer[i+1]*(TMFIPeriod-1)+sump)/TMFIPeriod;
negative=(NegBuffer[i+1]*(TMFIPeriod-1)+sumn)/TMFIPeriod;
PosBuffer[i]=positive;
NegBuffer[i]=negative;
if(negative==0.0) TMFIBuffer[i]=0.0;
else TMFIBuffer[i]=100.0*(1.0-1.0/(1.0+positive/negative));
i--;
}
return(0);
}
//+------------------------------------------------------------------+
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
---