Download MetaTrader 5
To add comments, please log in or register
No time to learn MQL5? Order your application from a developer!
MetaQuotes Software Corp.
Moderator
180316
MetaQuotes Software Corp. 2006.08.07 12:55 

TSI MACD:

TSI_MACD Indicator.

Author: Collector

Ramdass
12
Ramdass 2006.08.09 12:16  
TSI_MACD_true.
//+------------------------------------------------------------------+
//|                                                TSI_MACD_true.mq4 |
//|                      Copyright © 2006, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 Blue
#property indicator_color2 Red
#property indicator_maximum 110
#property indicator_minimum -110
#property indicator_level1 0
//---- input parameters
extern int Fast = 8;
extern int Slow = 21;
extern int Signal = 5;
extern int First_R = 8;
extern int Second_S = 5;
extern int SignalPeriod = 5;
extern int Mode_Smooth = 2;
//---- buffers
double TSI_Buffer[];
double SignalBuffer[];
double MTM_Buffer[];
double EMA_MTM_Buffer[];
double EMA2_MTM_Buffer[];
double ABSMTM_Buffer[];
double EMA_ABSMTM_Buffer[];
double EMA2_ABSMTM_Buffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   IndicatorBuffers(8);
   SetIndexBuffer(2, MTM_Buffer);
   SetIndexBuffer(3, EMA_MTM_Buffer);
   SetIndexBuffer(4, EMA2_MTM_Buffer);
   SetIndexBuffer(5, ABSMTM_Buffer);
   SetIndexBuffer(6, EMA_ABSMTM_Buffer);
   SetIndexBuffer(7, EMA2_ABSMTM_Buffer);
//----
   SetIndexStyle(0, DRAW_LINE);
   SetIndexBuffer(0, TSI_Buffer);
   SetIndexLabel(0, "TSI_MACD");
   SetIndexStyle(1, DRAW_LINE);
   SetIndexBuffer(1, SignalBuffer);
   SetIndexLabel(1, "Signal");
   IndicatorShortName("TSI_MACD(" + Fast + ", " + Slow + ", " + Signal + "; " + 
                      First_R + ", " + Second_S + ", " + SignalPeriod + ")");
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int counted_bars = IndicatorCounted(); 
   int limit, i;
   limit = Bars - counted_bars;
//----
   for(i = limit; i >= 0; i--)
     {
       MTM_Buffer[i]=iMACD(NULL,0,Fast,Slow,Signal,PRICE_CLOSE,MODE_MAIN,i)-
                     iMACD(NULL,0,Fast,Slow,Signal,PRICE_CLOSE,MODE_MAIN,i+1);
       ABSMTM_Buffer[i] = MathAbs(MTM_Buffer[i]);
     }
//----
   for(i=limit-1;i>=0;i--)
     {
       EMA_MTM_Buffer[i] = iMAOnArray(MTM_Buffer, 0, First_R, 0, MODE_EMA, i);
       EMA_ABSMTM_Buffer[i] = iMAOnArray(ABSMTM_Buffer, 0, First_R, 0, MODE_EMA, i);
     }
//----
   for(i = limit; i >= 0; i--)
     {
       EMA2_MTM_Buffer[i] = iMAOnArray(EMA_MTM_Buffer, 0, Second_S, 0, MODE_EMA, i);
       EMA2_ABSMTM_Buffer[i] = iMAOnArray(EMA_ABSMTM_Buffer, 0, Second_S, 0, MODE_EMA, i);
     }
//----
   for(i = limit; i >= 0; i--)
       {
       if (EMA2_ABSMTM_Buffer[i]!=0.0) TSI_Buffer[i] = 100.0*EMA2_MTM_Buffer[i] / EMA2_ABSMTM_Buffer[i];
       }
       
//----
   for(i = limit; i >= 0; i--)
     {
       SignalBuffer[i] = iMAOnArray(TSI_Buffer, 0, SignalPeriod, 0, Mode_Smooth, i);
     }
//----
   return(0);
  }
//+------------------------------------------------------------------+
MQL4 Comments
16319
MQL4 Comments 2008.08.17 17:29  

HI,

i got one question, why i can't see this indicator at 30min time frame?

Thanks
Jozef

MQL4 Comments
16319
MQL4 Comments 2010.04.01 00:32  
Hi there, I am using this indicator but when I call the first candle (mode_main value) via icustom in an ea I get a different value to that shown in the datawindow and on the chart. Though this is not always the case as some times after starting the ea the values are the same - thought is infrequent? Any ideas what might cause this. If it run the indicator on two or three charsts some times they are all correct, most times though one or two of them are incorrect.

How do I get an accurate value for my ea?

Thanks
Kevin Heard

/
To add comments, please log in or register